@yaks/git 0.0.0-stage → 0.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +754 -2
- package/_dist/address.d.ts +6 -0
- package/_dist/address.d.ts.map +1 -0
- package/_dist/checkout_vocab.d.ts +3 -0
- package/_dist/checkout_vocab.d.ts.map +1 -0
- package/_dist/cites.d.ts +48 -0
- package/_dist/cites.d.ts.map +1 -0
- package/_dist/commit.d.ts +36 -0
- package/_dist/commit.d.ts.map +1 -0
- package/_dist/comp.d.ts +29 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/door.d.ts +29 -0
- package/_dist/door.d.ts.map +1 -0
- package/_dist/format.d.ts +2 -0
- package/_dist/format.d.ts.map +1 -0
- package/_dist/hold.d.ts +6 -0
- package/_dist/hold.d.ts.map +1 -0
- package/_dist/host.d.ts +126 -0
- package/_dist/host.d.ts.map +1 -0
- package/_dist/http.d.ts +33 -0
- package/_dist/http.d.ts.map +1 -0
- package/_dist/import.d.ts +13 -0
- package/_dist/import.d.ts.map +1 -0
- package/_dist/index.d.ts +80 -0
- package/_dist/index.d.ts.map +1 -0
- package/_dist/land.d.ts +77 -0
- package/_dist/land.d.ts.map +1 -0
- package/_dist/mod.d.ts +73 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/objects.d.ts +40 -0
- package/_dist/objects.d.ts.map +1 -0
- package/_dist/oid.d.ts +24 -0
- package/_dist/oid.d.ts.map +1 -0
- package/_dist/pack-store.d.ts +9 -0
- package/_dist/pack-store.d.ts.map +1 -0
- package/_dist/pack.d.ts +26 -0
- package/_dist/pack.d.ts.map +1 -0
- package/_dist/pkt.d.ts +14 -0
- package/_dist/pkt.d.ts.map +1 -0
- package/_dist/placement.d.ts +4 -0
- package/_dist/placement.d.ts.map +1 -0
- package/_dist/plugin.d.ts +43 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/project.d.ts +20 -0
- package/_dist/project.d.ts.map +1 -0
- package/_dist/push.d.ts +42 -0
- package/_dist/push.d.ts.map +1 -0
- package/_dist/refs.d.ts +81 -0
- package/_dist/refs.d.ts.map +1 -0
- package/_dist/rewrite.d.ts +35 -0
- package/_dist/rewrite.d.ts.map +1 -0
- package/_dist/service.d.ts +35 -0
- package/_dist/service.d.ts.map +1 -0
- package/_dist/sha1.d.ts +11 -0
- package/_dist/sha1.d.ts.map +1 -0
- package/_dist/source.d.ts +12 -0
- package/_dist/source.d.ts.map +1 -0
- package/_dist/tools.d.ts +11 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/tree.d.ts +28 -0
- package/_dist/tree.d.ts.map +1 -0
- package/_dist/unpack.d.ts +5 -0
- package/_dist/unpack.d.ts.map +1 -0
- package/_dist/vocab.d.ts +8 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/workspace.d.ts +17 -0
- package/_dist/workspace.d.ts.map +1 -0
- package/address.js +9 -0
- package/address.js.map +1 -0
- package/address.ts +15 -0
- package/cache.js +9 -0
- package/cache.js.map +1 -0
- package/cache.ts +6 -0
- package/checkout.js +18 -0
- package/checkout.js.map +1 -0
- package/checkout.ts +24 -0
- package/checkout_vocab.js +14 -0
- package/checkout_vocab.js.map +1 -0
- package/checkout_vocab.ts +11 -0
- package/cites.js +189 -0
- package/cites.js.map +1 -0
- package/cites.ts +206 -0
- package/commit.js +128 -0
- package/commit.js.map +1 -0
- package/commit.ts +183 -0
- package/comp.js +94 -0
- package/comp.js.map +1 -0
- package/comp.ts +111 -0
- package/deno.json +1 -0
- package/door.js +88 -0
- package/door.js.map +1 -0
- package/door.ts +142 -0
- package/format.js +43 -0
- package/format.js.map +1 -0
- package/format.ts +49 -0
- package/hold.js +17 -0
- package/hold.js.map +1 -0
- package/hold.ts +21 -0
- package/host.js +1024 -0
- package/host.js.map +1 -0
- package/host.ts +1140 -0
- package/http.js +268 -0
- package/http.js.map +1 -0
- package/http.ts +329 -0
- package/import.js +141 -0
- package/import.js.map +1 -0
- package/import.ts +128 -0
- package/index.js +496 -0
- package/index.js.map +1 -0
- package/index.ts +634 -0
- package/land.js +788 -0
- package/land.js.map +1 -0
- package/land.ts +871 -0
- package/mod.js +73 -0
- package/mod.js.map +1 -0
- package/mod.ts +74 -0
- package/objects.js +331 -0
- package/objects.js.map +1 -0
- package/objects.ts +390 -0
- package/oid.js +50 -0
- package/oid.js.map +1 -0
- package/oid.ts +83 -0
- package/pack-index.js +103 -0
- package/pack-index.js.map +1 -0
- package/pack-index.ts +104 -0
- package/pack-store.js +216 -0
- package/pack-store.js.map +1 -0
- package/pack-store.ts +292 -0
- package/pack.js +121 -0
- package/pack.js.map +1 -0
- package/pack.ts +146 -0
- package/package.json +78 -4
- package/pkt.js +73 -0
- package/pkt.js.map +1 -0
- package/pkt.ts +93 -0
- package/placement.js +44 -0
- package/placement.js.map +1 -0
- package/placement.ts +38 -0
- package/plugin.js +66 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +88 -0
- package/process-cwd.py +57 -0
- package/project.js +142 -0
- package/project.js.map +1 -0
- package/project.ts +151 -0
- package/push.js +401 -0
- package/push.js.map +1 -0
- package/push.ts +451 -0
- package/refs.js +176 -0
- package/refs.js.map +1 -0
- package/refs.ts +285 -0
- package/rewrite.js +176 -0
- package/rewrite.js.map +1 -0
- package/rewrite.ts +173 -0
- package/service.js +104 -0
- package/service.js.map +1 -0
- package/service.ts +194 -0
- package/sha1.js +115 -0
- package/sha1.js.map +1 -0
- package/sha1.ts +146 -0
- package/source.js +100 -0
- package/source.js.map +1 -0
- package/source.ts +116 -0
- package/spare.js +108 -0
- package/spare.js.map +1 -0
- package/spare.ts +94 -0
- package/tools.js +278 -0
- package/tools.js.map +1 -0
- package/tools.ts +310 -0
- package/tree.js +105 -0
- package/tree.js.map +1 -0
- package/tree.ts +132 -0
- package/unpack.js +207 -0
- package/unpack.js.map +1 -0
- package/unpack.ts +210 -0
- package/vocab.js +20 -0
- package/vocab.js.map +1 -0
- package/vocab.json +386 -0
- package/vocab.ts +22 -0
- package/workspace.js +449 -0
- package/workspace.js.map +1 -0
- package/workspace.ts +445 -0
package/objects.ts
ADDED
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
// What a clone has to carry: every object reachable from the commits a client
|
|
2
|
+
// asked for, each one once, and the bytes of each — the other half of a
|
|
3
|
+
// packfile, which ./pack.ts writes without looking anything up.
|
|
4
|
+
//
|
|
5
|
+
// Two walks and a read. Commits are followed along `parent` edges; trees and
|
|
6
|
+
// a commit's own tree are read from their immutable bodies (`treeEntries`,
|
|
7
|
+
// ./tree.ts; `treeOf`, ./commit.ts). Each entry's mode says whether its child
|
|
8
|
+
// is a tree or a blob, without another query of the object index. Each
|
|
9
|
+
// object is listed once: the same tree under two commits, or one blob under
|
|
10
|
+
// two names, is one entry in the packfile.
|
|
11
|
+
//
|
|
12
|
+
// A `have` is subtraction, not negotiation. Everything the client reports it
|
|
13
|
+
// holds is walked first into the same seen set, so those objects are simply
|
|
14
|
+
// absent from the answer. One round, no deltas, no shallow clones: a first
|
|
15
|
+
// clone is the full reachable set, and a fetch after it is the difference
|
|
16
|
+
// (D-34943). A `have` naming an object this graph never held is ignored — the
|
|
17
|
+
// client may hold objects we do not.
|
|
18
|
+
//
|
|
19
|
+
// The frontier is read in batches because a query's any-of list becomes bound
|
|
20
|
+
// parameters and a database limits how many there may be. The commit walk
|
|
21
|
+
// follows the parent relation in the graph on the other side of that door.
|
|
22
|
+
|
|
23
|
+
import { type Blobs, streamOf } from '@yaks/blob'
|
|
24
|
+
import type { Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
25
|
+
import { type Line, line } from '@yaks/query'
|
|
26
|
+
import { WALK_LIMIT } from '@yaks/query/core'
|
|
27
|
+
import { commitParts, treeOf } from './commit.js'
|
|
28
|
+
import { BLOB, GITOBJ, PARENT } from './comp.js'
|
|
29
|
+
import type { Kind } from './oid.ts'
|
|
30
|
+
import { type Obj, pack } from './pack.js'
|
|
31
|
+
import { DIR, treeEntries } from './tree.js'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* What reading objects needs from a graph: a read, and nothing else — the read
|
|
35
|
+
* half of {@link Writes}, for the same reason (./index.ts). A packfile is
|
|
36
|
+
* served wherever the request arrived, which may be nowhere near the graph.
|
|
37
|
+
*/
|
|
38
|
+
export type Reads = Pick<Graph, 'read'>
|
|
39
|
+
|
|
40
|
+
/** Reading a graph's Git objects out, in the order a packfile lists them. */
|
|
41
|
+
export type Objects = {
|
|
42
|
+
/** every object these commits need, each once: commits, then trees, then
|
|
43
|
+
* blobs — minus whatever the client already has */
|
|
44
|
+
reach: (wants: string[], haves?: string[]) => Promise<string[]>
|
|
45
|
+
/** objects in the ref tips' snapshots, without walking prior commits */
|
|
46
|
+
snapshots?: (tips: string[]) => Promise<string[]>
|
|
47
|
+
/** Common commits offered by the client during fetch negotiation. */
|
|
48
|
+
common?: (wants: string[], haves: string[]) => Promise<string[]>
|
|
49
|
+
/** those objects' bytes, one at a time, in the order given */
|
|
50
|
+
read: (oids: string[]) => AsyncIterable<Obj>
|
|
51
|
+
/** both at once: the packfile that a clone of these commits consists of */
|
|
52
|
+
pack: (
|
|
53
|
+
wants: string[],
|
|
54
|
+
haves?: string[],
|
|
55
|
+
) => Promise<ReadableStream<Uint8Array>>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The outgoing links of every object reachable from a commit. */
|
|
59
|
+
export type Catalog = Map<string, string[]>
|
|
60
|
+
|
|
61
|
+
export let reachable = (from: Catalog, roots: string[]): Set<string> => {
|
|
62
|
+
let found = new Set<string>()
|
|
63
|
+
let next = [...roots]
|
|
64
|
+
while (next.length) {
|
|
65
|
+
let oid = next.pop()!
|
|
66
|
+
let links = from.get(oid)
|
|
67
|
+
if (!links || found.has(oid)) continue
|
|
68
|
+
found.add(oid)
|
|
69
|
+
for (let link of links) next.push(link)
|
|
70
|
+
}
|
|
71
|
+
return found
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type Membership = (oids: string[]) => Promise<Set<string>>
|
|
75
|
+
|
|
76
|
+
export type History = Objects & {
|
|
77
|
+
additions?: (tip: string, held: Membership) => Promise<{
|
|
78
|
+
links: Catalog
|
|
79
|
+
met: Set<string>
|
|
80
|
+
}>
|
|
81
|
+
catalog: (tip: string, prior?: Catalog) => Promise<Catalog>
|
|
82
|
+
packObjects: (
|
|
83
|
+
oids: string[],
|
|
84
|
+
prior?: Parameters<typeof pack>[2],
|
|
85
|
+
) => ReadableStream<Uint8Array>
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type IndexedHistory = History & {
|
|
89
|
+
/** The bodies of a tip and its ancestors, except those `held` names. */
|
|
90
|
+
commits: (
|
|
91
|
+
tip: string,
|
|
92
|
+
held?: { has: (oid: string) => boolean },
|
|
93
|
+
) => Promise<Map<string, Uint8Array>>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// How many ids go into one query's any-of list.
|
|
97
|
+
let BITE = 100
|
|
98
|
+
|
|
99
|
+
let comp = (b: Bundle, name: string): Comp => (b[name] ?? {}) as Comp
|
|
100
|
+
|
|
101
|
+
/** Where an object's bytes are kept, what it is and how big. */
|
|
102
|
+
type Indexed = { sha: string; type: Kind; size: number }
|
|
103
|
+
|
|
104
|
+
/** An object reader over a graph that carries this package's components and
|
|
105
|
+
* the @yaks/blob store that holds the bytes — the same pair the index writes
|
|
106
|
+
* to. */
|
|
107
|
+
export let objects = (
|
|
108
|
+
g: Reads,
|
|
109
|
+
store: {
|
|
110
|
+
get: (sha: string, kind: Kind) => ReturnType<Blobs['get']>
|
|
111
|
+
open?: (sha: string, kind: Kind) => ReturnType<NonNullable<Blobs['open']>>
|
|
112
|
+
},
|
|
113
|
+
): IndexedHistory => {
|
|
114
|
+
// One query per batch of the frontier, with the results appended.
|
|
115
|
+
let some = async (
|
|
116
|
+
query: (list: string[]) => Line,
|
|
117
|
+
oids: string[],
|
|
118
|
+
): Promise<Bundle[]> => {
|
|
119
|
+
let out: Bundle[] = []
|
|
120
|
+
for (let i = 0; i < oids.length; i += BITE) {
|
|
121
|
+
out.push(...await g.read(query(oids.slice(i, i + BITE))))
|
|
122
|
+
}
|
|
123
|
+
return out
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Each object's index row, as this reader has read it: an object's id names
|
|
127
|
+
// its content, so its row never changes, and a walk that reads an object
|
|
128
|
+
// to follow its links leaves the row for the pack that carries it.
|
|
129
|
+
let known = new Map<string, Indexed>()
|
|
130
|
+
|
|
131
|
+
// The type of each of these objects — and, by absence, which we never had.
|
|
132
|
+
let kinds = async (oids: string[]): Promise<Map<string, Kind>> => {
|
|
133
|
+
let unread = oids.filter((oid) => !known.has(oid))
|
|
134
|
+
let read = new Map(
|
|
135
|
+
(await some((l) => line`.${GITOBJ}&.entity.eid=${l}`, unread))
|
|
136
|
+
.map((r) => [r.entity.eid, comp(r, GITOBJ).type as Kind]),
|
|
137
|
+
)
|
|
138
|
+
return new Map(oids.flatMap((oid) => {
|
|
139
|
+
let type = known.get(oid)?.type ?? read.get(oid)
|
|
140
|
+
return type ? [[oid, type]] : []
|
|
141
|
+
}))
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let ancestors = async (tip: string): Promise<string[]> => {
|
|
145
|
+
let rows = await g.read(line`.gitobj&.parent<-${tip}&.limit=${WALK_LIMIT}`)
|
|
146
|
+
let ids = rows.map((r) => r.entity.eid)
|
|
147
|
+
if (ids.length < WALK_LIMIT) return ids
|
|
148
|
+
// A capped query may have stopped at any boundary. Follow only the
|
|
149
|
+
// edges that leave the set it returned, then repeat at those parents.
|
|
150
|
+
let covered = new Set([tip, ...ids])
|
|
151
|
+
let edges = await some(
|
|
152
|
+
(l) => line`.${PARENT}&.edge.from=${l}`,
|
|
153
|
+
[...covered],
|
|
154
|
+
)
|
|
155
|
+
let next = new Set(edges.map((r) => String(comp(r, 'edge').to)))
|
|
156
|
+
for (let id of next) {
|
|
157
|
+
if (!covered.has(id)) ids.push(id, ...await ancestors(id))
|
|
158
|
+
}
|
|
159
|
+
return ids
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function* indexed(oids: string[]) {
|
|
163
|
+
for (let i = 0; i < oids.length; i += BITE) {
|
|
164
|
+
let bite = oids.slice(i, i + BITE)
|
|
165
|
+
// `?blob` is not decoration: a query returns the components it names,
|
|
166
|
+
// and a graph reached over @yaks/api's read endpoint returns exactly
|
|
167
|
+
// those — so a read that asked only for `.gitobj` came back with rows
|
|
168
|
+
// that did not include where the bytes were, and every object was
|
|
169
|
+
// reported missing.
|
|
170
|
+
let unread = bite.filter((oid) => !known.has(oid))
|
|
171
|
+
for (
|
|
172
|
+
let row of await some(
|
|
173
|
+
(l) => line`.${GITOBJ}&?${BLOB}&.entity.eid=${l}`,
|
|
174
|
+
unread,
|
|
175
|
+
)
|
|
176
|
+
) {
|
|
177
|
+
let { type, size } = comp(row, GITOBJ)
|
|
178
|
+
known.set(row.entity.eid, {
|
|
179
|
+
sha: String(comp(row, BLOB).sha),
|
|
180
|
+
type: type as Kind,
|
|
181
|
+
size: Number(size),
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
yield bite.map((oid) => {
|
|
185
|
+
let row = known.get(oid)
|
|
186
|
+
if (!row) throw new Error(`git: no object ${oid}`)
|
|
187
|
+
return row
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
let bytesOf = async (sha: string, type: Kind) => {
|
|
193
|
+
let bytes = await store.get(sha, type)
|
|
194
|
+
if (!bytes) throw new Error(`git: no bytes stored under ${sha}`)
|
|
195
|
+
return bytes
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async function* read(oids: string[]): AsyncIterable<Obj> {
|
|
199
|
+
let width = 6
|
|
200
|
+
for await (let bite of indexed(oids)) {
|
|
201
|
+
for (let at = 0; at < bite.length; at += width) {
|
|
202
|
+
let group = bite.slice(at, at + width)
|
|
203
|
+
yield* await Promise.all(group.map(async ({ type, sha }) => ({
|
|
204
|
+
type,
|
|
205
|
+
bytes: await bytesOf(sha, type),
|
|
206
|
+
})))
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function* streamed(oids: string[]) {
|
|
212
|
+
for await (let bite of indexed(oids)) {
|
|
213
|
+
for (let { type, sha, size } of bite) {
|
|
214
|
+
yield {
|
|
215
|
+
type,
|
|
216
|
+
size,
|
|
217
|
+
body: async () => {
|
|
218
|
+
if (!store.open) return streamOf(await bytesOf(sha, type)).stream
|
|
219
|
+
let object = await store.open(sha, type)
|
|
220
|
+
if (!object) throw new Error(`git: no bytes stored under ${sha}`)
|
|
221
|
+
return object.read()
|
|
222
|
+
},
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
let packObjects: History['packObjects'] = (oids, prior) =>
|
|
229
|
+
pack(oids.length + (prior?.count ?? 0), streamed(oids), prior)
|
|
230
|
+
|
|
231
|
+
// Walk immutable bodies only up to the packed frontier. A held tree
|
|
232
|
+
// covers its whole subtree, and a held commit covers its entire ancestry.
|
|
233
|
+
let additions: NonNullable<History['additions']> = async (tip, held) => {
|
|
234
|
+
let links: Catalog = new Map()
|
|
235
|
+
let met = new Set<string>()
|
|
236
|
+
let seen = new Set<string>()
|
|
237
|
+
let front = async (oids: string[]) => {
|
|
238
|
+
let fresh = oids.filter((oid) => !seen.has(oid) && (seen.add(oid), true))
|
|
239
|
+
let known = await held(fresh)
|
|
240
|
+
for (let oid of known) met.add(oid)
|
|
241
|
+
return fresh.filter((oid) => !known.has(oid))
|
|
242
|
+
}
|
|
243
|
+
let commits = [tip]
|
|
244
|
+
let trees: string[] = []
|
|
245
|
+
while (commits.length) {
|
|
246
|
+
let batch = await front(commits)
|
|
247
|
+
commits = []
|
|
248
|
+
let at = 0
|
|
249
|
+
for await (let obj of read(batch)) {
|
|
250
|
+
let { tree, parents } = commitParts(obj.bytes)
|
|
251
|
+
links.set(batch[at++], [tree, ...parents])
|
|
252
|
+
trees.push(tree)
|
|
253
|
+
for (let parent of parents) commits.push(parent)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
let blobs = new Set<string>()
|
|
257
|
+
while (trees.length) {
|
|
258
|
+
let batch = await front(trees)
|
|
259
|
+
trees = []
|
|
260
|
+
let at = 0
|
|
261
|
+
for await (let obj of read(batch)) {
|
|
262
|
+
let entries = treeEntries(obj.bytes)
|
|
263
|
+
links.set(batch[at++], entries.map((e) => e.oid))
|
|
264
|
+
for (let entry of entries) {
|
|
265
|
+
if (entry.mode == DIR) trees.push(entry.oid)
|
|
266
|
+
else blobs.add(entry.oid)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
for (let oid of await front([...blobs])) links.set(oid, [])
|
|
271
|
+
return { links, met }
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// One graph walk gets the commit frontier; its bodies name the tree
|
|
275
|
+
// frontier. Previously packed objects already carry their immutable links.
|
|
276
|
+
let catalog = async (tip: string, prior: Catalog = new Map()) => {
|
|
277
|
+
let links = new Map(prior)
|
|
278
|
+
let commits = prior.has(tip) ? [] : [
|
|
279
|
+
...new Set([
|
|
280
|
+
tip,
|
|
281
|
+
...await ancestors(tip),
|
|
282
|
+
]),
|
|
283
|
+
].filter((oid) => !links.has(oid))
|
|
284
|
+
let trees = new Set<string>()
|
|
285
|
+
let n = 0
|
|
286
|
+
for await (let obj of read(commits)) {
|
|
287
|
+
let { tree, parents } = commitParts(obj.bytes)
|
|
288
|
+
links.set(commits[n++], [tree, ...parents])
|
|
289
|
+
trees.add(tree)
|
|
290
|
+
}
|
|
291
|
+
while (trees.size) {
|
|
292
|
+
let front = [...trees].filter((oid) => !links.has(oid))
|
|
293
|
+
trees.clear()
|
|
294
|
+
let at = 0
|
|
295
|
+
for await (let obj of read(front)) {
|
|
296
|
+
let entries = treeEntries(obj.bytes)
|
|
297
|
+
links.set(front[at++], entries.map((e) => e.oid))
|
|
298
|
+
for (let entry of entries) {
|
|
299
|
+
if (entry.mode == DIR) trees.add(entry.oid)
|
|
300
|
+
else if (!links.has(entry.oid)) links.set(entry.oid, [])
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
let all = reachable(links, [tip])
|
|
305
|
+
let out: Catalog = new Map()
|
|
306
|
+
for (let oid of all) {
|
|
307
|
+
let children = links.get(oid)!
|
|
308
|
+
if (children.some((child) => !all.has(child))) {
|
|
309
|
+
throw new Error(`git: incomplete history at ${oid}`)
|
|
310
|
+
}
|
|
311
|
+
out.set(oid, children)
|
|
312
|
+
}
|
|
313
|
+
return out
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// The walk itself. `seen` comes in holding what the client has and goes out
|
|
317
|
+
// holding that plus every object this answer lists.
|
|
318
|
+
let walk = async (
|
|
319
|
+
roots: string[],
|
|
320
|
+
seen: Set<string>,
|
|
321
|
+
history = true,
|
|
322
|
+
): Promise<string[]> => {
|
|
323
|
+
let fresh = (oids: string[]) =>
|
|
324
|
+
oids.filter((o) => !seen.has(o) && (seen.add(o), true))
|
|
325
|
+
let kind = await kinds(roots)
|
|
326
|
+
let missing = roots.find((o) => !kind.has(o))
|
|
327
|
+
if (missing) throw new Error(`git: no object ${missing}`)
|
|
328
|
+
|
|
329
|
+
let found = fresh(roots.filter((o) => kind.get(o) == 'commit'))
|
|
330
|
+
if (history) {
|
|
331
|
+
for (let tip of [...found]) found.push(...fresh(await ancestors(tip)))
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// A commit's tree is in its body; a `want` that is a tree is its own root.
|
|
335
|
+
let tops = roots.filter((o) => kind.get(o) == 'tree')
|
|
336
|
+
for await (let o of read(found)) {
|
|
337
|
+
let tree = treeOf(o.bytes)
|
|
338
|
+
if (tree) tops.push(tree)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
let blobs = fresh(roots.filter((o) => kind.get(o) == 'blob'))
|
|
342
|
+
let front = fresh(tops)
|
|
343
|
+
while (front.length) {
|
|
344
|
+
found.push(...front)
|
|
345
|
+
let next: string[] = []
|
|
346
|
+
for await (let tree of read(front)) {
|
|
347
|
+
for (let entry of treeEntries(tree.bytes)) {
|
|
348
|
+
if (seen.has(entry.oid)) continue
|
|
349
|
+
seen.add(entry.oid)
|
|
350
|
+
if (entry.mode == DIR) next.push(entry.oid)
|
|
351
|
+
else blobs.push(entry.oid)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
front = next
|
|
355
|
+
}
|
|
356
|
+
return [...found, ...blobs]
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
let reach = async (wants: string[], haves: string[] = []) => {
|
|
360
|
+
let seen = new Set<string>()
|
|
361
|
+
// Only the haves we recognise: a client may hold objects we never had.
|
|
362
|
+
if (haves.length) await walk([...(await kinds(haves)).keys()], seen)
|
|
363
|
+
return walk(wants, seen)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return {
|
|
367
|
+
commits: async (tip, held) => {
|
|
368
|
+
let ids = [...new Set([tip, ...await ancestors(tip)])]
|
|
369
|
+
.filter((oid) => !held?.has(oid))
|
|
370
|
+
let found = new Map<string, Uint8Array>()
|
|
371
|
+
let i = 0
|
|
372
|
+
for await (let object of read(ids)) found.set(ids[i++], object.bytes)
|
|
373
|
+
return found
|
|
374
|
+
},
|
|
375
|
+
additions,
|
|
376
|
+
catalog,
|
|
377
|
+
common: async (wants, haves) => {
|
|
378
|
+
let known = new Set(wants)
|
|
379
|
+
for (let want of wants) {
|
|
380
|
+
for (let parent of await ancestors(want)) known.add(parent)
|
|
381
|
+
}
|
|
382
|
+
return haves.filter((oid) => known.has(oid))
|
|
383
|
+
},
|
|
384
|
+
reach,
|
|
385
|
+
snapshots: (tips) => walk(tips, new Set(), false),
|
|
386
|
+
read,
|
|
387
|
+
packObjects,
|
|
388
|
+
pack: async (wants, haves) => packObjects(await reach(wants, haves)),
|
|
389
|
+
}
|
|
390
|
+
}
|
package/oid.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// What a Git object is called: the digest of its own header and body.
|
|
2
|
+
//
|
|
3
|
+
// Every object in this package is named twice. `oid` is Git's SHA-1 object id
|
|
4
|
+
// — the one a `git clone` asks for, and the entity id of the row we keep about
|
|
5
|
+
// the object. `oid256` is the SHA-256 object id of the same object, computed
|
|
6
|
+
// from the first write so that a client asking for `object-format=sha256` is
|
|
7
|
+
// answered by a lookup rather than by converting the repository (Git's own
|
|
8
|
+
// hash-function transition, stored as @yaks/key rows instead of a
|
|
9
|
+
// loose-object index).
|
|
10
|
+
//
|
|
11
|
+
// The two ids are not two digests of the same bytes. A tree or a commit names
|
|
12
|
+
// its children by id, so the SHA-256 body is the SHA-1 body with every child
|
|
13
|
+
// id translated — which is why the builders here take the ids to write rather
|
|
14
|
+
// than the objects themselves, and why `Oids` is always a pair.
|
|
15
|
+
//
|
|
16
|
+
// SHA-1 is a name here, never a security claim: it is what the packfile format
|
|
17
|
+
// and Git's protocol specify, so it is what we compute. `crypto.subtle` is the
|
|
18
|
+
// only digest available that does both algorithms over bytes, and it is async,
|
|
19
|
+
// which makes writing an object async all the way up. That is the price of not
|
|
20
|
+
// shipping a second SHA-1 implementation.
|
|
21
|
+
/** The four types a Git object can have. */ let utf8 = new TextEncoder();
|
|
22
|
+
/** The bytes Git prefixes a body with before hashing it: `tree 42\0`. */ export let header = (type, size)=>utf8.encode(`${type} ${size}\0`);
|
|
23
|
+
/** Joins byte runs end to end — how every body in this package is assembled.
|
|
24
|
+
*
|
|
25
|
+
* The return type is `Uint8Array<ArrayBuffer>` because `crypto.subtle` refuses
|
|
26
|
+
* a view that might be over shared memory, and every body here ends up in a
|
|
27
|
+
* digest. A freshly allocated array never is. */ export let concat = (parts)=>{
|
|
28
|
+
let out = new Uint8Array(parts.reduce((n, p)=>n + p.length, 0));
|
|
29
|
+
let at = 0;
|
|
30
|
+
for (let p of parts){
|
|
31
|
+
out.set(p, at);
|
|
32
|
+
at += p.length;
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
36
|
+
/** A body as it is hashed: the header, then the body. */ export let framed = (type, body)=>concat([
|
|
37
|
+
header(type, body.length),
|
|
38
|
+
body
|
|
39
|
+
]);
|
|
40
|
+
/** Bytes as lowercase hex. Every id in this package is a hex string. */ export let hex = (bytes)=>Array.from(bytes, (b)=>b.toString(16).padStart(2, '0')).join('');
|
|
41
|
+
/** A hex id back as the raw bytes a tree body writes it with. */ export let bin = (id)=>Uint8Array.from({
|
|
42
|
+
length: id.length / 2
|
|
43
|
+
}, (_, i)=>parseInt(id.slice(i * 2, i * 2 + 2), 16));
|
|
44
|
+
/** The object id under one algorithm: `digest(algo, "<type> <size>\0<body>")`.
|
|
45
|
+
* {@link oid} and {@link oid256} are the two callers use. */ export let objectId = (algo)=>async (type, body)=>hex(new Uint8Array(await crypto.subtle.digest(algo, framed(type, body))));
|
|
46
|
+
/** Git's object id: the SHA-1 of the header and the body. */ export let oid = objectId('SHA-1');
|
|
47
|
+
/** The same object's SHA-256 object id. Pass it the SHA-256 body — the one
|
|
48
|
+
* whose children are named by their own `oid256` — or the result is the digest
|
|
49
|
+
* of an object nobody can ask for. */ export let oid256 = objectId('SHA-256');
|
|
50
|
+
//# sourceMappingURL=oid.js.map
|
package/oid.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oid.js","sources":["./oid.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,kEAAkE;AAClE,uBAAuB;AACvB,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,gEAAgE;AAChE,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,0CAA0C;AAE1C,0CAA0C,GAO1C,IAAI,OAAO,IAAI;AAEf,uEAAuE,GACvE,OAAO,IAAI,SAAS,CAAC,MAAY,OAC/B,KAAK,MAAM,CAAC,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAC;AAElC;;;;+CAI+C,GAC/C,OAAO,IAAI,SAAS,CAAC;EACnB,IAAI,MAAM,IAAI,WAAW,MAAM,MAAM,CAAC,CAAC,GAAG,IAAM,IAAI,EAAE,MAAM,EAAE;EAC9D,IAAI,KAAK;EACT,KAAK,IAAI,KAAK,MAAO;IACnB,IAAI,GAAG,CAAC,GAAG;IACX,MAAM,EAAE,MAAM;EAChB;EACA,OAAO;AACT,EAAC;AAED,uDAAuD,GACvD,OAAO,IAAI,SAAS,CAClB,MACA,OAC4B,OAAO;IAAC,OAAO,MAAM,KAAK,MAAM;IAAG;GAAK,EAAC;AAEvE,sEAAsE,GACtE,OAAO,IAAI,MAAM,CAAC,QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAM,EAAE,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,IAAG;AAEpE,+DAA+D,GAC/D,OAAO,IAAI,MAAM,CAAC,KAChB,WAAW,IAAI,CACb;IAAE,QAAQ,GAAG,MAAM,GAAG;EAAE,GACxB,CAAC,GAAG,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,KAChD;AAMH;2DAC2D,GAC3D,OAAO,IAAI,WACT,CAAC,OAAqC,OAAO,MAAM,OACjD,IAAI,IAAI,WAAW,MAAM,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,MAAM,SAAQ;AAE7E,2DAA2D,GAC3D,OAAO,IAAI,MAAa,SAAS,SAAQ;AAEzC;;oCAEoC,GACpC,OAAO,IAAI,SAAgB,SAAS,WAAU"}
|
package/oid.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// What a Git object is called: the digest of its own header and body.
|
|
2
|
+
//
|
|
3
|
+
// Every object in this package is named twice. `oid` is Git's SHA-1 object id
|
|
4
|
+
// — the one a `git clone` asks for, and the entity id of the row we keep about
|
|
5
|
+
// the object. `oid256` is the SHA-256 object id of the same object, computed
|
|
6
|
+
// from the first write so that a client asking for `object-format=sha256` is
|
|
7
|
+
// answered by a lookup rather than by converting the repository (Git's own
|
|
8
|
+
// hash-function transition, stored as @yaks/key rows instead of a
|
|
9
|
+
// loose-object index).
|
|
10
|
+
//
|
|
11
|
+
// The two ids are not two digests of the same bytes. A tree or a commit names
|
|
12
|
+
// its children by id, so the SHA-256 body is the SHA-1 body with every child
|
|
13
|
+
// id translated — which is why the builders here take the ids to write rather
|
|
14
|
+
// than the objects themselves, and why `Oids` is always a pair.
|
|
15
|
+
//
|
|
16
|
+
// SHA-1 is a name here, never a security claim: it is what the packfile format
|
|
17
|
+
// and Git's protocol specify, so it is what we compute. `crypto.subtle` is the
|
|
18
|
+
// only digest available that does both algorithms over bytes, and it is async,
|
|
19
|
+
// which makes writing an object async all the way up. That is the price of not
|
|
20
|
+
// shipping a second SHA-1 implementation.
|
|
21
|
+
|
|
22
|
+
/** The four types a Git object can have. */
|
|
23
|
+
export type Kind = 'blob' | 'tree' | 'commit' | 'tag'
|
|
24
|
+
|
|
25
|
+
/** One object's two ids: Git's SHA-1 id, and the SHA-256 id of the same
|
|
26
|
+
* object with its children's ids translated. */
|
|
27
|
+
export type Oids = { oid: string; oid256: string }
|
|
28
|
+
|
|
29
|
+
let utf8 = new TextEncoder()
|
|
30
|
+
|
|
31
|
+
/** The bytes Git prefixes a body with before hashing it: `tree 42\0`. */
|
|
32
|
+
export let header = (type: Kind, size: number): Uint8Array =>
|
|
33
|
+
utf8.encode(`${type} ${size}\0`)
|
|
34
|
+
|
|
35
|
+
/** Joins byte runs end to end — how every body in this package is assembled.
|
|
36
|
+
*
|
|
37
|
+
* The return type is `Uint8Array<ArrayBuffer>` because `crypto.subtle` refuses
|
|
38
|
+
* a view that might be over shared memory, and every body here ends up in a
|
|
39
|
+
* digest. A freshly allocated array never is. */
|
|
40
|
+
export let concat = (parts: Uint8Array[]): Uint8Array<ArrayBuffer> => {
|
|
41
|
+
let out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0))
|
|
42
|
+
let at = 0
|
|
43
|
+
for (let p of parts) {
|
|
44
|
+
out.set(p, at)
|
|
45
|
+
at += p.length
|
|
46
|
+
}
|
|
47
|
+
return out
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A body as it is hashed: the header, then the body. */
|
|
51
|
+
export let framed = (
|
|
52
|
+
type: Kind,
|
|
53
|
+
body: Uint8Array,
|
|
54
|
+
): Uint8Array<ArrayBuffer> => concat([header(type, body.length), body])
|
|
55
|
+
|
|
56
|
+
/** Bytes as lowercase hex. Every id in this package is a hex string. */
|
|
57
|
+
export let hex = (bytes: Uint8Array): string =>
|
|
58
|
+
Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('')
|
|
59
|
+
|
|
60
|
+
/** A hex id back as the raw bytes a tree body writes it with. */
|
|
61
|
+
export let bin = (id: string): Uint8Array =>
|
|
62
|
+
Uint8Array.from(
|
|
63
|
+
{ length: id.length / 2 },
|
|
64
|
+
(_, i) => parseInt(id.slice(i * 2, i * 2 + 2), 16),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
/** Computing an object id under one hash algorithm: the signature both
|
|
68
|
+
* {@link oid} and {@link oid256} have. */
|
|
69
|
+
export type Namer = (type: Kind, body: Uint8Array) => Promise<string>
|
|
70
|
+
|
|
71
|
+
/** The object id under one algorithm: `digest(algo, "<type> <size>\0<body>")`.
|
|
72
|
+
* {@link oid} and {@link oid256} are the two callers use. */
|
|
73
|
+
export let objectId =
|
|
74
|
+
(algo: 'SHA-1' | 'SHA-256'): Namer => async (type, body) =>
|
|
75
|
+
hex(new Uint8Array(await crypto.subtle.digest(algo, framed(type, body))))
|
|
76
|
+
|
|
77
|
+
/** Git's object id: the SHA-1 of the header and the body. */
|
|
78
|
+
export let oid: Namer = objectId('SHA-1')
|
|
79
|
+
|
|
80
|
+
/** The same object's SHA-256 object id. Pass it the SHA-256 body — the one
|
|
81
|
+
* whose children are named by their own `oid256` — or the result is the digest
|
|
82
|
+
* of an object nobody can ask for. */
|
|
83
|
+
export let oid256: Namer = objectId('SHA-256')
|
package/pack-index.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// An immutable radix index. A refresh loads and replaces only the leaves its
|
|
2
|
+
// frontier touches. Old roots still describe the exact packs they were read with.
|
|
3
|
+
import { ObjectChanged } from "@yaks/blob";
|
|
4
|
+
let LEAF = 512;
|
|
5
|
+
let encode = new TextEncoder();
|
|
6
|
+
let decode = new TextDecoder();
|
|
7
|
+
let groups = (items, digit)=>{
|
|
8
|
+
let by = {};
|
|
9
|
+
for (let item of items)(by[digit(item)] ??= []).push(item);
|
|
10
|
+
return Object.entries(by);
|
|
11
|
+
};
|
|
12
|
+
export let packIndex = (bucket, prefix)=>{
|
|
13
|
+
let kept = new Map();
|
|
14
|
+
let read = (id)=>{
|
|
15
|
+
let node = kept.get(id);
|
|
16
|
+
if (!node) {
|
|
17
|
+
node = bucket.read(prefix + id).then((bytes)=>{
|
|
18
|
+
if (!bytes) throw new ObjectChanged(prefix + id);
|
|
19
|
+
return JSON.parse(decode.decode(bytes));
|
|
20
|
+
});
|
|
21
|
+
kept.set(id, node);
|
|
22
|
+
}
|
|
23
|
+
return node;
|
|
24
|
+
};
|
|
25
|
+
let membership = (root)=>async (oids)=>{
|
|
26
|
+
let found = new Set();
|
|
27
|
+
let visit = async (id, at, names)=>{
|
|
28
|
+
if (!names.length) return;
|
|
29
|
+
let node = await read(id);
|
|
30
|
+
if ('entries' in node) {
|
|
31
|
+
let present = new Map(node.entries);
|
|
32
|
+
for (let oid of names){
|
|
33
|
+
if (present.has(oid)) found.add(oid);
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
await Promise.all(groups(names, (oid)=>oid[at]).map(([digit, names])=>{
|
|
38
|
+
let child = node.children[digit];
|
|
39
|
+
return child && visit(child, at + 1, names);
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
await visit(root, 0, oids);
|
|
43
|
+
return found;
|
|
44
|
+
};
|
|
45
|
+
let write = async (build, links, root)=>{
|
|
46
|
+
let grow = async (path, adds, id)=>{
|
|
47
|
+
let node = id ? await read(id) : {
|
|
48
|
+
entries: []
|
|
49
|
+
};
|
|
50
|
+
let at = path.length;
|
|
51
|
+
if ('entries' in node) {
|
|
52
|
+
let entries = [
|
|
53
|
+
...new Map([
|
|
54
|
+
...node.entries,
|
|
55
|
+
...adds
|
|
56
|
+
])
|
|
57
|
+
];
|
|
58
|
+
node = entries.length <= LEAF ? {
|
|
59
|
+
entries
|
|
60
|
+
} : {
|
|
61
|
+
children: {}
|
|
62
|
+
};
|
|
63
|
+
adds = entries;
|
|
64
|
+
}
|
|
65
|
+
if ('children' in node) {
|
|
66
|
+
let children = {
|
|
67
|
+
...node.children
|
|
68
|
+
};
|
|
69
|
+
for (let [digit, entries] of groups(adds, ([oid])=>oid[at])){
|
|
70
|
+
children[digit] = await grow(path + digit, entries, children[digit]);
|
|
71
|
+
}
|
|
72
|
+
node = {
|
|
73
|
+
children
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
let name = build + '/index/' + path;
|
|
77
|
+
await bucket.put(prefix + name, encode.encode(JSON.stringify(node)));
|
|
78
|
+
return name;
|
|
79
|
+
};
|
|
80
|
+
return await grow('', [
|
|
81
|
+
...links
|
|
82
|
+
], root);
|
|
83
|
+
};
|
|
84
|
+
let catalog = async (root)=>{
|
|
85
|
+
let links = new Map();
|
|
86
|
+
let visit = async (id)=>{
|
|
87
|
+
let node = await read(id);
|
|
88
|
+
if ('entries' in node) {
|
|
89
|
+
for (let [oid, children] of node.entries)links.set(oid, children);
|
|
90
|
+
} else {
|
|
91
|
+
for (let child of Object.values(node.children))await visit(child);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
await visit(root);
|
|
95
|
+
return links;
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
membership,
|
|
99
|
+
catalog,
|
|
100
|
+
write
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=pack-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pack-index.js","sources":["./pack-index.ts"],"names":[],"mappings":"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"}
|