main
1// Pack parsing and delta resolution (buffered, general-purpose): parsePack walks a whole pack verifying the trailer,
2// applyDelta is git's patch_delta, resolvePack resolves OFS/REF chains by dependency (a delta resolves when its base
3// lands) with external bases as a last resort, describePack reports that layout the way `git verify-pack -v` prints it (a thin base is data, not an error),
4// makeDelta is a general delta generator. The edit pipeline needs none of this (fetch.js/fetchObject +
5// deltaenc.js/spliceDelta); it is here for the general client and re-exported from pack.js for callers.
6import type { ErrorOf } from './errors.js';
7import { fail } from './errors.js';
8import type { Err, Result } from './result.js';
9import { ok, err, assertNever, flatMapOption, getOrElse } from './result.js';
10import { atOr, fromNullable, fromNullish, mapGet, readKey, type Input } from './absent.js';
11import type { Oid } from './oid.js';
12import { parseOid } from './oid.js';
13import { TYPE, TYPE_NAME, hashObject, nameOfTypeId } from './objects.js';
14import type { CheckedLimits, LimitKey, LimitsInput } from './limits.js';
15import { DEFAULT_LIMITS, LIMIT_OBJECT_OVERHEAD, limitError, checkLimit, parseLimits } from './limits.js';
16import { spliceDelta } from './deltaenc.js';
17import type { DeltaOp, SplicedDelta } from './deltaenc.js';
18import { shortRead } from './bytes.js';
19import type { ObjType, ObjectTypeName, PackKind } from './format.js';
20import type { InflateStats, ObjBase, ObjHeader, ObjSize, OfsDelta, PackCaps, PackError, PackPiece, PackScan } from './packstream.js';
21import { NO_BASE, packScanOpen, parsePackFeed, parsePackClose, parsePackPull, readObjHeader, readOfsDelta, readUint32BE, readVarint } from './packstream.js';
22import {
23 PACK_VERSION, DELTA_SIZE_MIN, DELTA_COPY, DELTA_COPY_MAX, DELTA_OFF4_FACTOR, DELTA_OFF_SHIFT,
24 DELTA_COPY_OFF1, DELTA_COPY_OFF2, DELTA_COPY_OFF3, DELTA_COPY_OFF4,
25 DELTA_COPY_LEN1, DELTA_COPY_LEN2, DELTA_COPY_LEN3, DELTA_BYTE2_SHIFT,
26} from './format.js';
28export type { PackKind, PackError, ObjBase, ObjHeader, ObjSize, OfsDelta, PackCaps };
29// The header readers live with the scan (packstream.ts); re-exported here, where callers have always found them.
30export { readObjHeader, readOfsDelta, readUint32BE };
31type Corrupt = ErrorOf<'pack_corrupt'>;
32const corrupt = (msg: string): Err<Corrupt> => fail('pack_corrupt', msg);
33const short = (buf: Uint8Array, p: number): Err<Corrupt> => err(shortRead('pack_corrupt', p, 1, buf.length));
35// A stored object's type (commit, tree, blob, tag): what a full object and a resolved delta are.
36export type ResolvedObjType = typeof TYPE.COMMIT | typeof TYPE.TREE | typeof TYPE.BLOB | typeof TYPE.TAG;
37function storedType(n: number): ResolvedObjType | null {
38 switch (n) {
39 case TYPE.COMMIT:
40 case TYPE.TREE:
41 case TYPE.BLOB:
42 case TYPE.TAG:
43 return n;
44 default:
45 return null;
46 }
47}
48const storedName = (type: ResolvedObjType): ObjectTypeName => TYPE_NAME[type];
50// ---- parse ----
51// The caller's limits record is parsed once (parseLimits: a key it gives must bound something, a key it leaves out is the
52// default). An override (maxObjects, maxInflatedTotal) is checked as that key would be: a missing one is the record's.
53function overrideOf(given: unknown, fallback: number, key: LimitKey): Result<number, ErrorOf<'bad_request'>> {
54 const g = fromNullable(given);
55 return g.tag === 'some' ? checkLimit(g.value, key) : ok(fallback);
56}
57// verify: check the trailer's SHA-1 (anything but false verifies); limits: the caps (any subset, DEFAULT_LIMITS for the
58// rest); maxObjects and maxInflatedTotal: a cap that overrides the one in limits.
59export type PackParseConfig = {
60 readonly verify: boolean;
61 readonly limits: LimitsInput;
62 readonly maxObjects: number;
63 readonly maxInflatedTotal: number;
64};
65export type PackParseOptions = Input<PackParseConfig>;
66// parsePack's options for `limits`: the record parsed, and the two pack caps read out of it.
67export type PackParseOpts = { readonly limits: CheckedLimits; readonly maxObjects: number; readonly maxInflatedTotal: number };
68export function packParseOpts(limits: LimitsInput = DEFAULT_LIMITS): Result<PackParseOpts, ErrorOf<'bad_request'>> {
69 const checked = parseLimits(limits);
70 if (!checked.ok) return checked;
71 return ok({ limits: checked.value, maxObjects: checked.value.maxPackObjects, maxInflatedTotal: checked.value.maxInflatedTotal });
72}
73// The caps parsePack's options give: the limits record parsed, then each override checked as its key would be.
74export function packCaps(opts: PackParseOptions): Result<PackCaps, ErrorOf<'bad_request'>> {
75 const limits = parseLimits(getOrElse<LimitsInput | null>(fromNullish(opts.limits), null));
76 if (!limits.ok) return limits;
77 const maxObjects = overrideOf(opts.maxObjects, limits.value.maxPackObjects, 'maxPackObjects');
78 if (!maxObjects.ok) return maxObjects;
79 const maxInflatedTotal = overrideOf(opts.maxInflatedTotal, limits.value.maxInflatedTotal, 'maxInflatedTotal');
80 if (!maxInflatedTotal.ok) return maxInflatedTotal;
81 return ok({ maxObjects: maxObjects.value, maxInflatedTotal: maxInflatedTotal.value, maxObjectSize: limits.value.maxObjectSize });
82}
84// One object as parsePack read it: its type is one of the six, its declared size within maxObjectSize, its base parsed
85// (a tagged ObjBase, a REF base an Oid), its data the inflated bytes (a delta's are its instructions).
86export type ParsedObject = {
87 readonly offset: number;
88 readonly headerBytes: number;
89 readonly type: ObjType;
90 readonly size: number;
91 readonly compressed: number;
92 readonly data: Uint8Array;
93 readonly base: ObjBase;
94 readonly inflate: InflateStats;
95};
96export type PackStats = {
97 readonly version: number;
98 readonly count: number;
99 full: number;
100 ofsDelta: number;
101 refDelta: number;
102 readonly byType: Record<string, number>;
103 compressed: number;
104 inflated: number;
105 readonly inflate: { blocks: number; stored: number; fixed: number; dynamic: number };
106};
107export type ParsedPack = { readonly objects: ParsedObject[]; readonly stats: PackStats; readonly trailer: string; readonly bytes: number };
109// What a collector over the scan keeps of one object: the object (its inflated bytes), or nothing (a dropped object
110// is still counted in the stats; a fetch that does not need it never holds it).
111export type ObjectSink = (header: ScannedHeader) => boolean;
112export type ScannedHeader = { readonly offset: number; readonly headerBytes: number; readonly type: ObjType; readonly size: ObjSize; readonly base: ObjBase };
113const keepAll: ObjectSink = () => true;
114// The object being collected: its header and the buffer its chunks land in (a declared size, so one buffer), or none
115// when the sink dropped it.
116type Collecting = { readonly header: ScannedHeader; readonly out: Uint8Array | null; at: number };
117const freshStats = (version: number, count: number): PackStats => ({ version, count, full: 0, ofsDelta: 0, refDelta: 0, byType: {}, compressed: 0, inflated: 0, inflate: { blocks: 0, stored: 0, fixed: 0, dynamic: 0 } });
118const kindOf = (type: ObjType): PackKind => nameOfTypeId(type);
119function countBase(stats: PackStats, base: ObjBase): void {
120 switch (base.tag) {
121 case 'none': stats.full++; return;
122 case 'ofs': stats.ofsDelta++; return;
123 case 'ref': stats.refDelta++; return;
124 }
125 // Stryker disable next-line ConditionalExpression,BlockStatement,CallExpression: unreachable, the compiler's exhaustiveness check
126 assertNever(base);
127}
129// A pack read through the scan (packstream.ts) piece by piece, the objects collected as their chunks arrive: the
130// collector is the only thing that holds an object, and only the ones `keep` asks for. Feed it with packCollectFeed and
131// finish it with packCollectEnd; parsePack is the two over a buffer in hand.
132export type PackCollector = {
133 readonly scan: PackScan;
134 readonly keep: ObjectSink;
135 objects: ParsedObject[];
136 stats: PackStats;
137 trailer: string;
138 bytes: number;
139 cur: Collecting | null;
140};
141export function packCollectOpen(caps: PackCaps, verify: boolean, keep: ObjectSink = keepAll): Result<PackCollector, PackError> {
142 const scan = packScanOpen(caps, verify);
143 if (!scan.ok) return scan;
144 // Stryker disable next-line StringLiteral: a placeholder, the trailer piece sets it before the end returns the pack
145 return ok({ scan: scan.value, keep, objects: [], stats: freshStats(0, 0), trailer: '', bytes: 0, cur: null });
146}
147const UNIT: Result<null, never> = ok(null);
148// One piece of the scan into the collector.
149// oxlint-disable-next-line complexity -- one case per scan event
150function collectPiece(c: PackCollector, p: PackPiece): void {
151 switch (p.kind) {
152 // collectDrain stops at `need` and `end`: neither reaches here, and neither carries anything to collect
153 // Stryker disable next-line all: see above
154 case 'need': case 'end': return;
155 case 'header': c.stats = freshStats(p.version, p.count); return;
156 case 'object': {
157 const header: ScannedHeader = { offset: p.offset, headerBytes: p.headerBytes, type: p.type, size: p.size, base: p.base };
158 countBase(c.stats, p.base);
159 c.cur = { header, out: c.keep(header) ? new Uint8Array(p.size) : null, at: 0 };
160 return;
161 }
162 case 'chunk': {
163 const cur = c.cur;
164 // a chunk always follows its object (cur is set), and a declared bound: the scan never yields past the object's
165 // size, which is out's length
166 // Stryker disable next-line ConditionalExpression: cur is never null here (above); a dropped object's out is
167 if (cur !== null && cur.out !== null) cur.out.set(p.bytes, cur.at);
168 // Stryker disable next-line ConditionalExpression: cur is never null here (above)
169 if (cur !== null) cur.at += p.bytes.length;
170 return;
171 }
172 case 'object-end': {
173 const cur = c.cur;
174 c.cur = null;
175 // an object-end always follows its object
176 // Stryker disable next-line ConditionalExpression,BlockStatement: see above
177 if (cur === null) return;
178 const { header } = cur;
179 const kind = kindOf(header.type);
180 c.stats.compressed += p.compressed; c.stats.inflated += header.size;
181 c.stats.inflate.blocks += p.stats.blocks; c.stats.inflate.stored += p.stats.stored; c.stats.inflate.fixed += p.stats.fixed; c.stats.inflate.dynamic += p.stats.dynamic;
182 c.stats.byType[kind] = getOrElse(readKey(c.stats.byType, kind), 0) + 1;
183 if (cur.out !== null) c.objects.push({ ...header, compressed: p.compressed, data: cur.out, inflate: p.stats });
184 return;
185 }
186 case 'trailer': c.trailer = p.trailer; return;
187 }
188 // Stryker disable next-line ConditionalExpression,BlockStatement,CallExpression: unreachable, the compiler's exhaustiveness check
189 assertNever(p);
190}
191// Pull until the scan wants more input or the pack has ended, or it is refused.
192function collectDrain(c: PackCollector): Result<null, PackError> {
193 for (;;) {
194 const r = parsePackPull(c.scan);
195 if (!r.ok) return r;
196 if (r.value.kind === 'need' || r.value.kind === 'end') return UNIT;
197 collectPiece(c, r.value);
198 }
199}
200// Append pack bytes and collect what they complete. The bytes may be dropped by the caller once this returns.
201export function packCollectFeed(c: PackCollector, bytes: Uint8Array): Result<null, PackError> {
202 parsePackFeed(c.scan, bytes);
203 c.bytes += bytes.length;
204 return collectDrain(c);
205}
206// The input is over: the pack, or where it was refused.
207export function packCollectEnd(c: PackCollector): Result<ParsedPack, PackError> {
208 parsePackClose(c.scan);
209 // a closed scan never asks for more: it ends or refuses
210 const r = collectDrain(c);
211 if (!r.ok) return r;
212 return ok({ objects: c.objects, stats: c.stats, trailer: c.trailer, bytes: c.bytes });
213}
215// A pack in hand, parsed: every object kept. The scan's refusals, in its order, are this one's.
216// @decoder parsePack prefix=pack
217export function parsePack(buf: Uint8Array, opts: PackParseOptions = {}): Result<ParsedPack, PackError> {
218 const caps = packCaps(opts);
219 if (!caps.ok) return caps;
220 const c = packCollectOpen(caps.value, opts.verify !== false);
221 // the caps passed packCaps, so the scan's inflate record opens (packScanOpen)
222 // Stryker disable next-line ConditionalExpression,BlockStatement: see above
223 if (!c.ok) return c;
224 // a refusal sticks on the scan: the end returns the feed's again
225 packCollectFeed(c.value, buf);
226 return packCollectEnd(c.value);
227}
229// ---- delta ----
230export type DeltaOps = { copy: number; insert: number; copyBytes: number; insertBytes: number };
231// A delta parsed once (parseDelta, #156): the source and result sizes from its header, its opcode counts, and its
232// instructions checked: no reserved opcode, nothing cut, every copy inside the source, every insert inside the delta,
233// exactly dstSize bytes out. The instructions stay in the delta's own bytes (`code`, from `start`): a record per op
234// would cost tens of bytes of heap where its encoding costs one to eight, and a hostile delta's op count is bounded only
235// by its length, so the parsed form would be an amplifier. Walking a parsed delta (deltaOps, applyProgram) cannot fail.
236declare const deltaBrand: unique symbol;
237export type DeltaProgram = {
238 readonly srcSize: number;
239 readonly dstSize: number;
240 readonly ops: DeltaOps;
241 readonly code: Uint8Array;
242 readonly start: number;
243 readonly [deltaBrand]: typeof deltaBrand;
244};
245// maxResult: the cap on the result's size (limits.maxDeltaResult when left out).
246export type DeltaOptions = Input<{ readonly maxResult: number }>;
247// The copy fields an opcode names, read from `p`: offset, length, and where the next opcode starts. Past the end a field
248// reads 0 and `next` passes code.length, which the parser refuses as a short read (there is no allocation per byte).
249type CopyOp = { readonly off: number; readonly len: number; readonly next: number };
250function copyFields(code: Uint8Array, op: number, from: number): CopyOp {
251 let p = from;
252 const byte = (): number => atOr(code, p++, 0);
253 // off and len are 0 until their first byte, so that byte is assigned, not or-ed in
254 let off = 0;
255 let len = 0;
256 if (op & DELTA_COPY_OFF1) off = byte();
257 if (op & DELTA_COPY_OFF2) off |= byte() << DELTA_OFF_SHIFT;
258 if (op & DELTA_COPY_OFF3) off |= byte() << DELTA_BYTE2_SHIFT;
259 if (op & DELTA_COPY_OFF4) off += byte() * DELTA_OFF4_FACTOR;
260 if (op & DELTA_COPY_LEN1) len = byte();
261 if (op & DELTA_COPY_LEN2) len |= byte() << DELTA_OFF_SHIFT;
262 if (op & DELTA_COPY_LEN3) len |= byte() << DELTA_BYTE2_SHIFT;
263 return { off, len: len === 0 ? DELTA_COPY_MAX : len, next: p };
264}
265// The last check, and the one that makes a parsed delta: the instructions produced exactly the result size.
266type Unchecked = { readonly srcSize: number; readonly dstSize: number; readonly ops: DeltaOps; readonly code: Uint8Array; readonly start: number };
267const producesExactly = (v: Unchecked, produced: number): v is DeltaProgram => produced === v.dstSize;
268// The delta's header and every instruction, checked once: git's patch_delta, in its order (the result size against the
269// cap, then the source size against the base when one is given, then the instructions).
270// @decoder parseDelta prefix=delta
271// oxlint-disable-next-line eslint/complexity -- one decoder: git's patch_delta, an opcode loop
272export function parseDelta(delta: Uint8Array, opts: DeltaOptions = {}, baseSize: number | null = null): Result<DeltaProgram, PackError> {
273 let maxResult = DEFAULT_LIMITS.maxDeltaResult;
274 const given = fromNullable(opts.maxResult);
275 if (given.tag === 'some') {
276 const m = checkLimit(given.value, 'maxDeltaResult');
277 if (!m.ok) return m;
278 maxResult = m.value;
279 }
280 if (delta.length < DELTA_SIZE_MIN) return corrupt('delta: shorter than DELTA_SIZE_MIN');
281 // readVarint's reads are bounded, so a header that runs past the buffer is a short read before p can pass the end.
282 const bs = readVarint(delta, 0, 'delta');
283 if (!bs.ok) return bs;
284 const rs = readVarint(delta, bs.value[1], 'delta');
285 if (!rs.ok) return rs;
286 const srcSize = bs.value[0];
287 const dstSize = rs.value[0];
288 const start = rs.value[1];
289 if (dstSize > maxResult) return err(limitError('delta result size', dstSize, maxResult));
290 if (baseSize !== null && srcSize !== baseSize) return corrupt(`delta: base size ${srcSize} != ${baseSize}`);
291 let p = start;
292 let o = 0;
293 const ops: DeltaOps = { copy: 0, insert: 0, copyBytes: 0, insertBytes: 0 };
294 while (p < delta.length) {
295 const c = delta[p++] as number; // oxlint-disable-line typescript/no-unsafe-type-assertion, typescript/non-nullable-type-assertion-style -- p < delta.length (the loop)
296 if (c & DELTA_COPY) {
297 const f = copyFields(delta, c, p);
298 p = f.next;
299 if (p > delta.length) return short(delta, delta.length);
300 if (f.off + f.len > srcSize || o + f.len > dstSize) return corrupt('delta: copy out of range');
301 o += f.len;
302 ops.copy++; ops.copyBytes += f.len;
303 } else if (c) {
304 if (p + c > delta.length || o + c > dstSize) return corrupt('delta: insert out of range');
305 o += c; p += c;
306 ops.insert++; ops.insertBytes += c;
307 } else return corrupt('delta: reserved opcode 0');
308 }
309 const program: Unchecked = { srcSize, dstSize, ops, code: delta, start };
310 if (!producesExactly(program, o)) return corrupt(`delta: produced ${o} != ${dstSize}`);
311 return ok(program);
312}
313// A parsed delta's instructions, in order. Nothing here can fail: parseDelta checked every one.
314export function* deltaOps(program: DeltaProgram): Generator<DeltaOp, void, unknown> {
315 const code = program.code;
316 let p = program.start;
317 while (p < code.length) {
318 const c = code[p++] as number; // oxlint-disable-line typescript/no-unsafe-type-assertion, typescript/non-nullable-type-assertion-style -- p < code.length (the loop)
319 if (c & DELTA_COPY) {
320 const f = copyFields(code, c, p);
321 p = f.next;
322 yield { tag: 'copy', off: f.off, len: f.len };
323 } else {
324 yield { tag: 'insert', bytes: code.subarray(p, p + c) };
325 p += c;
326 }
327 }
328}
329// A parsed delta over its base: the result, written into one buffer of dstSize bytes. The base must be srcSize bytes.
330export function applyProgram(base: Uint8Array, program: DeltaProgram): Result<Uint8Array<ArrayBuffer>, Corrupt> {
331 if (base.length !== program.srcSize) return corrupt(`delta: base size ${program.srcSize} != ${base.length}`);
332 const out = new Uint8Array(program.dstSize);
333 let o = 0;
334 for (const op of deltaOps(program)) {
335 switch (op.tag) {
336 // in range: parseDelta checked off + len against srcSize, which is base.length (above)
337 case 'copy': out.set(base.subarray(op.off, op.off + op.len), o); o += op.len; continue;
338 case 'insert': out.set(op.bytes, o); o += op.bytes.length; continue;
339 }
340 // Stryker disable next-line ConditionalExpression,BlockStatement,CallExpression: unreachable, the compiler's exhaustiveness check
341 assertNever(op);
342 }
343 return ok(out);
344}
345export type Patched = { out: Uint8Array; ops: DeltaOps };
346// git's patch_delta: the delta parsed against the base's size, then applied.
347// @decoder applyDelta prefix=delta
348export function applyDelta(base: Uint8Array, delta: Uint8Array, opts: DeltaOptions = {}): Result<Patched, PackError> {
349 const program = parseDelta(delta, opts, base.length);
350 if (!program.ok) return program;
351 const out = applyProgram(base, program.value);
352 return out.ok ? ok({ out: out.value, ops: program.value.ops }) : out;
353}
355// Common-prefix/suffix delta between two buffers: one copy of the prefix, the middle inserted, one copy of the suffix
356// (spliceDelta builds those instructions and encodes them).
357export function makeDelta(base: Uint8Array, target: Uint8Array): SplicedDelta {
358 let p = 0;
359 const max = Math.min(base.length, target.length);
360 while (p < max && base[p] === target[p]) p++;
361 let s = 0;
362 while (s < max - p && base[base.length - 1 - s] === target[target.length - 1 - s]) s++;
363 // p + s <= min(base.length, target.length) by the loops above: a view, it cannot be short
364 return spliceDelta({ baseLen: base.length, off: p, oldLen: base.length - p - s, insert: target.subarray(p, target.length - s) });
365}
367// ---- resolve ----
368// A base from outside the pack (a thin pack's), as the caller's `external` returns it: plain values, parsed where the
369// resolver reads them (externalBase).
370export type ExternalBase = { readonly type: number; readonly data: Uint8Array };
371// The caller's lookup of a thin base by id. Anything falsy (null, or a JavaScript function's bare `return`) is "not
372// here"; `void` is how a function type admits that bare return.
373// oxlint-disable-next-line typescript/no-invalid-void-type -- a JavaScript caller's lookup may return nothing (see above)
374export type ExternalLookup = (oid: Oid) => ExternalBase | null | void;
375// A full object as resolvePack returns it; a delta's result also carries its delta's opcode counts.
376export type ResolvedFull = {
377 readonly type: ResolvedObjType;
378 readonly data: Uint8Array;
379 readonly chain: number;
380 readonly oid: Oid;
381 readonly offset: number;
382 readonly size: number;
383 readonly compressed: number;
384 // Where the object sat in the pack it came from: none, an OFS_DELTA's offset there, or a REF_DELTA's base id. Not
385 // `base`: push reads `base` as its own input (pack.ts PackInputBase), and `data` here is the object whole (#217).
386 readonly packBase: ObjBase;
387};
388export type ResolvedDelta = ResolvedFull & { readonly deltaOps: DeltaOps };
389export type ResolvedObject = ResolvedFull | ResolvedDelta;
390// A base as a hand-built object may give it: the tagged form with plain values (an id as a string), parsed at the edge.
391export type BaseInput = { readonly tag: 'none' } | { readonly tag: 'ofs'; readonly offset: number } | { readonly tag: 'ref'; readonly oid: string };
392// One object as resolvePack takes it: parsePack's (a ParsedObject is one), or built by hand with plain values. A left-out
393// base is none; a left-out size or compressed count is the data's length and 0.
394export type PackObjectInput = { readonly offset: number; readonly type: number; readonly data: Uint8Array } & Input<{ readonly base: BaseInput; readonly size: number; readonly compressed: number }>;
395// What resolvePack reads of a parsed pack: parsePack's result, or a hand-built one (stats optional).
396export type PackToResolve = { readonly objects: readonly PackObjectInput[] } & Input<{ readonly stats: Input<{ readonly inflated: number }> }>;
397// stats: the longest chain resolved; REF_DELTAs resolved on a base the caller's lookup gave; REF_DELTA bases looked up by
398// id (one per REF_DELTA); entries the resolver visited (at most three per entry, whatever the pack's order).
399export type ResolvedPack = { readonly objects: Map<string, ResolvedObject>; readonly stats: { maxChain: number; externalBases: number; baseLookups: number; steps: number } };
400type Base = { readonly type: ResolvedObjType; readonly data: Uint8Array; readonly chain: number };
401// One object of the resolver's input, parsed (packEntry): a full object's type is a stored type, a delta's base tagged.
402type Entry =
403 | { readonly tag: 'full'; readonly offset: number; readonly type: ResolvedObjType; readonly data: Uint8Array; readonly size: number; readonly compressed: number; readonly base: ObjBase }
404 | { readonly tag: 'delta'; readonly offset: number; readonly data: Uint8Array; readonly size: number; readonly compressed: number; readonly base: ObjBase & { readonly tag: 'ofs' | 'ref' } };
406type BadRequest = ErrorOf<'bad_request'>;
407const badObject = (offset: unknown, why: string): Err<BadRequest> => fail('bad_request', `resolvePack: object at ${String(offset)} ${why}`, { what: 'object' });
408// A hand-built base, parsed: the tag one of the three, an OFS offset a non-negative safe integer, a REF id an Oid.
409function parseBase(offset: number, given: Input<{ readonly base: BaseInput }>): Result<ObjBase, BadRequest> {
410 const b = fromNullish(given.base);
411 if (b.tag === 'none') return ok(NO_BASE);
412 const base = b.value;
413 // a JavaScript caller's tag outside the three
414 if (base.tag !== 'none' && base.tag !== 'ofs' && base.tag !== 'ref') return badObject(offset, `has base tag ${JSON.stringify(Reflect.get(base, 'tag'))}`);
415 switch (base.tag) {
416 case 'none': return ok(NO_BASE);
417 case 'ofs':
418 if (!Number.isSafeInteger(base.offset) || base.offset < 0) return badObject(offset, `has ofs base ${String(base.offset)}`);
419 return ok({ tag: 'ofs', offset: base.offset });
420 case 'ref': {
421 const oid = parseOid(base.oid);
422 if (!oid.ok) return badObject(offset, `has ref base ${JSON.stringify(base.oid)}, not an object id`);
423 return ok({ tag: 'ref', oid: oid.value });
424 }
425 }
426 // Stryker disable next-line ConditionalExpression,BlockStatement,CallExpression: unreachable, the compiler's exhaustiveness check
427 return assertNever(base);
428}
429// The resolver's edge (#156): each object's plain values parsed once into an Entry. A full object's type is commit,
430// tree, blob or tag; a delta's type is not read (its result is its base's type).
431function packEntry(o: PackObjectInput): Result<Entry, BadRequest> {
432 const base = parseBase(o.offset, o);
433 if (!base.ok) return base;
434 // read once: the entry holds it from here
435 const data: unknown = o.data;
436 if (!(data instanceof Uint8Array)) return badObject(o.offset, 'has no data');
437 const size = getOrElse(fromNullish(o.size), data.length);
438 const compressed = getOrElse(fromNullish(o.compressed), 0);
439 const b = base.value;
440 if (b.tag !== 'none') return ok({ tag: 'delta', offset: o.offset, data, size, compressed, base: b });
441 const type = storedType(o.type);
442 if (type === null) return badObject(o.offset, `has type ${String(o.type)} and no base`);
443 return ok({ tag: 'full', offset: o.offset, type, data, size, compressed, base: b });
444}
446// A REF_DELTA whose base is not in the pack, kept instead of refused. `oid` is that missing base (the root its chain
447// waits on), in pack order of the objects that could not be resolved.
448export type UnresolvedBase = { readonly offset: number; readonly oid: Oid };
449export type CollectedPack = ResolvedPack & { readonly unresolved: readonly UnresolvedBase[] };
451// A thin REF base must be exactly the object git stored under that oid: the four stored types only
452// (commit, tree, blob, tag), and the SHA-1 of "type SP size NUL" + bytes must equal the named oid.
453// Anything else is pack_corrupt before applyDelta.
454function externalBase(oid: Oid, ext: ExternalBase): Result<Base, Corrupt> {
455 const type = storedType(ext.type);
456 // a delta type, 0, 5, or any other non-object id
457 if (type === null) return corrupt(`pack: ref delta base ${oid} has type ${ext.type}`);
458 const hashed = hashObject(storedName(type), ext.data);
459 if (hashed !== oid) return corrupt(`pack: ref delta base ${oid} hashes to ${hashed}`);
460 return ok({ type, data: ext.data, chain: 0 });
461}
463type DeltaEntry = Entry & { readonly tag: 'delta' };
464// What a delta that never resolved waits on: the REF_DELTA base id at the root of its OFS bases, and how many deltas
465// lie between that base and it (the REF_DELTA is 1, an OFS_DELTA on it 2).
466type Wait = { readonly oid: Oid; readonly depth: number };
467const LANDED: Result<null, never> = ok(null);
468const NONE_FILED: readonly DeltaEntry[] = [];
469// The dependants filed under `key`, removed: each delta waits in one list and is taken from it once.
470function take<K>(waiting: Map<K, DeltaEntry[]>, key: K): readonly DeltaEntry[] {
471 const list = mapGet(waiting, key);
472 if (list.tag === 'none') return NONE_FILED;
473 waiting.delete(key);
474 return list.value;
475}
476function file<K>(waiting: Map<K, DeltaEntry[]>, key: K, d: DeltaEntry): void {
477 const list = mapGet(waiting, key);
478 if (list.tag === 'some') list.value.push(d);
479 else waiting.set(key, [d]);
480}
482// The resolver: a dependency structure, not a rescan. Full objects resolve first, in pack order. Then every delta is
483// visited once, in pack order: its base has resolved (it is patched now) or it has not (the delta is filed under that
484// base: by offset for an OFS_DELTA, by id for a REF_DELTA). An object that resolves takes the deltas filed under its
485// offset and its id and resolves them, and theirs, from a queue (no recursion: a chain is as long as maxDeltaChain
486// allows, and the caller sets that). What is left waits on a base outside the pack: each such id is asked of `external`
487// once, and what it gives lands the same way. So an entry is visited at most three times whatever the pack's order
488// (stats.steps), and the bytes produced are the delta results, each charged to maxInflatedTotal before it exists: the
489// work is linear in entries plus bytes and bounded by the limits record.
490// `collectMissing` is describePack's path: a thin base is data, not an error. Without it a thin base the lookup does not
491// have is refused (`pack: ref delta base … not found`), which callers and the pack-cut space depend on.
492// oxlint-disable-next-line complexity -- the resolver's phases, one function so the maps and the budget are shared
493function fixpoint(parsed: PackToResolve, external: ExternalLookup, limits: CheckedLimits, collectMissing: boolean): Result<CollectedPack, PackError> {
494 const { maxDeltaChain: maxChain, maxDeltaResult: maxDelta, maxInflatedTotal: inflatedCap } = limits;
495 const entries: Entry[] = [];
496 for (const o of parsed.objects) {
497 const e = packEntry(o);
498 if (!e.ok) return e;
499 entries.push(e.value);
500 }
501 const byOffset = new Map(entries.map(o => [o.offset, o]));
502 // Resolved objects by id (a REF_DELTA's base is this lookup, not a scan of the objects) and by offset.
503 const resolved = new Map<string, ResolvedObject>();
504 const memo = new Map<number, ResolvedObject>();
505 // Deltas whose base has not resolved, under the base they rest on.
506 const onOffset = new Map<number, DeltaEntry[]>();
507 const onOid = new Map<Oid, DeltaEntry[]>();
508 const stats = { maxChain: 0, externalBases: 0, baseLookups: 0, steps: 0 };
509 // Bytes already held (inflated instructions and bases) plus each delta result, which is a new buffer, and
510 // LIMIT_OBJECT_OVERHEAD per object, as parsePack charged it. That one charge covers the object's resolved form too
511 // (measured: resolving adds 0.65 KiB per object, delta or not), so a delta result adds its bytes only.
512 const given = flatMapOption(fromNullish(parsed.stats), s => fromNullish(s.inflated));
513 let held = (given.tag === 'some' ? given.value : entries.reduce((n, o) => n + o.data.length, 0)) + entries.length * LIMIT_OBJECT_OVERHEAD;
514 function settle(obj: Entry, r: ResolvedObject): void {
515 if (r.chain > stats.maxChain) stats.maxChain = r.chain;
516 memo.set(obj.offset, r);
517 resolved.set(r.oid, r);
518 }
519 // A delta's resolved form: its base's bytes patched by its instructions.
520 function patch(obj: DeltaEntry, base: Base): Result<ResolvedObject, PackError> {
521 stats.steps++;
522 // Chain length from the full (or external) base, whatever order the links arrived in (#14). An external base is 0.
523 const chain = base.chain + 1;
524 if (chain > maxChain) return err(limitError('delta chain depth', chain, maxChain));
525 // The result buffer does not exist until the delta's header passes maxResult. Room is what the aggregate cap has left.
526 const room = inflatedCap - held;
527 if (room < 0) return err(limitError('pack inflated bytes', held, inflatedCap));
528 const patched = applyDelta(base.data, obj.data, { maxResult: Math.min(maxDelta, room) });
529 if (!patched.ok) return patched;
530 held += patched.value.out.length;
531 const out = patched.value.out;
532 const r: ResolvedObject = { type: base.type, data: out, chain, deltaOps: patched.value.ops, oid: hashObject(storedName(base.type), out), offset: obj.offset, size: obj.size, compressed: obj.compressed, packBase: obj.base };
533 settle(obj, r);
534 return ok(r);
535 }
536 // The deltas filed under `base` (one list of them), resolved on it and queued.
537 function wake(filed: readonly DeltaEntry[], base: ResolvedObject, landed: ResolvedObject[]): Result<null, PackError> {
538 for (const d of filed) {
539 // a second entry at an offset that has resolved (a hand-built input) is that object
540 if (memo.has(d.offset)) continue;
541 const r = patch(d, base);
542 if (!r.ok) return r;
543 landed.push(r.value);
544 }
545 return LANDED;
546 }
547 // `first` resolved: the deltas filed under it resolve, then the ones filed under those, in the order they land.
548 function land(first: ResolvedObject): Result<null, PackError> {
549 // nothing is filed in a pack whose bases all come first: no queue to run
550 if (onOffset.size === 0 && onOid.size === 0) return LANDED;
551 const landed: ResolvedObject[] = [first];
552 // the array grows as it is read: a queue
553 for (const base of landed) {
554 const atOffset = wake(take(onOffset, base.offset), base, landed);
555 if (!atOffset.ok) return atOffset;
556 const atOid = wake(take(onOid, base.oid), base, landed);
557 if (!atOid.ok) return atOid;
558 }
559 return LANDED;
560 }
561 // The base of a delta if it has resolved; if not, the delta is filed under it.
562 function findBase(d: DeltaEntry): Result<Base | null, PackError> {
563 const base = d.base;
564 switch (base.tag) {
565 case 'ofs': {
566 if (!byOffset.has(base.offset)) return corrupt(`pack: ofs delta base not at object boundary ${base.offset}`);
567 const b = mapGet(memo, base.offset);
568 if (b.tag === 'some') return ok(b.value);
569 file(onOffset, base.offset, d);
570 return ok(null);
571 }
572 case 'ref': {
573 stats.baseLookups++;
574 const b = mapGet(resolved, base.oid);
575 if (b.tag === 'some') return ok(b.value);
576 file(onOid, base.oid, d);
577 return ok(null);
578 }
579 }
580 // Stryker disable next-line ConditionalExpression,BlockStatement,CallExpression: unreachable, the compiler's exhaustiveness check
581 return assertNever(base);
582 }
583 // Full objects first: each is hashed once and registered, so a REF_DELTA finds it by id.
584 const deltas: DeltaEntry[] = [];
585 for (const o of entries) {
586 if (o.tag === 'delta') { deltas.push(o); continue; }
587 stats.steps++;
588 if (memo.has(o.offset)) continue;
589 settle(o, { type: o.type, data: o.data, chain: 0, oid: hashObject(storedName(o.type), o.data), offset: o.offset, size: o.size, compressed: o.compressed, packBase: o.base });
590 }
591 // Every delta once, in pack order: resolved on a base that is there, or filed under the one that is not.
592 for (const d of deltas) {
593 if (memo.has(d.offset)) continue;
594 const base = findBase(d);
595 if (!base.ok) return base;
596 if (base.value === null) { stats.steps++; continue; }
597 const r = patch(d, base.value);
598 if (!r.ok) return r;
599 const l = land(r.value);
600 if (!l.ok) return l;
601 }
602 // every delta that has not resolved is filed: none filed, none left
603 // Stryker disable next-line ConditionalExpression: a shortcut that cannot change the result. When both waiting maps are empty every delta is in memo, so `left` is empty, each loop below runs zero times, and the last return gives this same value
604 if (onOffset.size === 0 && onOid.size === 0) return ok({ objects: resolved, stats, unresolved: [] });
605 const left = deltas.filter(d => !memo.has(d.offset));
606 // What each remaining delta waits on, through its OFS bases, each walked once (the answer is kept per offset). A walk
607 // that comes back to itself is a cycle of OFS bases (a hand-built input): a chain with no end is past any limit.
608 const waits = new Map<number, Wait>();
609 function waitOf(start: DeltaEntry): Wait | null {
610 const path: DeltaEntry[] = [];
611 const onPath = new Set<number>();
612 let cur = start;
613 let found: Wait;
614 for (;;) {
615 const known = mapGet(waits, cur.offset);
616 if (known.tag === 'some') { found = known.value; break; }
617 stats.steps++;
618 if (cur.base.tag === 'ref') { found = { oid: cur.base.oid, depth: 1 }; waits.set(cur.offset, found); break; }
619 const b = mapGet(byOffset, cur.base.offset);
620 // the walk came back to a delta already on its path: a cycle of OFS bases
621 if (onPath.has(cur.offset)) return null;
622 // Stryker disable next-line ConditionalExpression,LogicalOperator,StringLiteral: narrows the type only, never true. `cur` is an unresolved delta that passed findBase's byOffset check, so there is an entry at its base offset; whole objects settle before any delta is visited, so a whole object there would have resolved `cur` (or ended the call with patch's error): its OFS base is an unresolved delta
623 if (b.tag === 'none' || b.value.tag !== 'delta') return null;
624 onPath.add(cur.offset);
625 path.push(cur);
626 cur = b.value;
627 }
628 for (const d of path.toReversed()) {
629 found = { oid: found.oid, depth: found.depth + 1 };
630 waits.set(d.offset, found);
631 }
632 return found;
633 }
634 // A delta more than maxDeltaChain deltas above a base that has not resolved is refused before that base is asked for
635 // (one link fewer is refused by patch if the base turns up: an external base is chain 0).
636 for (const d of left) {
637 const w = waitOf(d);
638 if (w === null || w.depth > maxChain + 1) return err(limitError('delta chain depth', maxChain + 1, maxChain));
639 }
640 // The caller's bases, each id asked once, in pack order of the REF_DELTAs that wait on it. A base that lands may
641 // resolve an object another REF_DELTA waits on: that one is in the pack after all, and is not asked for.
642 const asked = new Set<Oid>();
643 for (const d of left) {
644 if (d.base.tag !== 'ref' || memo.has(d.offset) || asked.has(d.base.oid)) continue;
645 asked.add(d.base.oid);
646 const ext = external(d.base.oid);
647 if (!ext) continue;
648 const checked = externalBase(d.base.oid, ext);
649 if (!checked.ok) return checked;
650 for (const w of take(onOid, d.base.oid)) {
651 // as in wake: a second entry at an offset that has resolved (a hand-built input) is that object
652 if (memo.has(w.offset)) continue;
653 stats.externalBases++;
654 const r = patch(w, checked.value);
655 if (!r.ok) return r;
656 const l = land(r.value);
657 if (!l.ok) return l;
658 }
659 }
660 // Still unresolved: the base is in neither the pack nor the caller's hands.
661 const unresolved: UnresolvedBase[] = [];
662 let missing: Oid | null = null;
663 for (const d of left) {
664 const w = mapGet(waits, d.offset);
665 // Stryker disable next-line ConditionalExpression,StringLiteral: `w.tag === 'none'` narrows the type only, never true. The chain-limit loop above called waitOf for every delta in `left`, and waitOf records a wait at the offset it starts from or the call ended there with limit_exceeded
666 if (memo.has(d.offset) || w.tag === 'none') continue;
667 unresolved.push({ offset: d.offset, oid: w.value.oid });
668 if (missing === null) missing = w.value.oid;
669 }
670 if (missing === null || collectMissing) return ok({ objects: resolved, stats, unresolved });
671 return corrupt(`pack: ref delta base ${missing} not found`);
672}
674// Stryker disable next-line ArrowFunction: null and a bare return both mean the base is not in the pack
675const noBase = (): null => null;
677// objects from parsePack (or built by hand, parsed here: an invalid one is bad_request); external(oid) -> {type, data}
678// for thin bases. A thin base the lookup does not have is refused.
679export function resolvePack(parsed: PackToResolve, external: ExternalLookup = noBase, limits: LimitsInput = DEFAULT_LIMITS): Result<ResolvedPack, PackError> {
680 const checked = parseLimits(limits);
681 if (!checked.ok) return checked;
682 const r = fixpoint(parsed, external, checked.value, false);
683 return r.ok ? ok({ objects: r.value.objects, stats: r.value.stats }) : r;
684}
685// resolvePack, keeping what a thin base it does not have leaves unresolved instead of refusing it: those objects'
686// offsets and the bases they wait on (a wide fetch that dropped blobs reads them as blobs; describePack as missingBases).
687export function resolvePackCollect(parsed: PackToResolve, external: ExternalLookup, limits: CheckedLimits): Result<CollectedPack, PackError> {
688 return fixpoint(parsed, external, limits, true);
689}
691// ---- layout (git verify-pack -v) ----
692// What verify-pack prints for one object, plus the wire type it does not print. `size` is the pack header's inflated
693// size (the delta or the object), not the resolved object. `type` is the resolved object type, which a missing thin
694// base hides. No span: this is a pure read of bytes already in hand; the span belongs to the fetch that received them.
695// A base: none (a full object); an OFS_DELTA's offset, and the base object's id once that object resolved; a REF_DELTA's
696// id, whether or not the object is in the pack.
697export type PackBase =
698 | { readonly tag: 'none' }
699 | { readonly tag: 'ofs'; readonly offset: number; readonly oid: Oid | null }
700 | { readonly tag: 'ref'; readonly oid: Oid };
701export type PackLayoutObject = {
702 readonly offset: number;
703 readonly headerBytes: number;
704 readonly compressed: number;
705 readonly size: number;
706 readonly wireType: ObjType;
707 readonly type: ResolvedObjType | null;
708 readonly oid: Oid | null;
709 readonly base: PackBase;
710 readonly depth: number;
711};
712export type PackLayout = {
713 readonly version: typeof PACK_VERSION;
714 readonly count: number;
715 readonly trailer: string;
716 readonly objects: readonly PackLayoutObject[];
717 // First-seen unique REF bases that are not in the pack, in pack order. These are the objects
718 // `git index-pack --fix-thin` appends.
719 readonly missingBases: readonly Oid[];
720};
722function baseOf(obj: ParsedObject, memo: ReadonlyMap<number, ResolvedObject>): PackBase {
723 switch (obj.base.tag) {
724 case 'none': return obj.base;
725 case 'ofs': {
726 const base = mapGet(memo, obj.base.offset);
727 return { tag: 'ofs', offset: obj.base.offset, oid: base.tag === 'some' ? base.value.oid : null };
728 }
729 case 'ref': return obj.base;
730 }
731 // Stryker disable next-line ConditionalExpression,BlockStatement,CallExpression: unreachable, the compiler's exhaustiveness check
732 return assertNever(obj.base);
733}
734// Depth of an object the resolver could not hash. That only happens when a REF base is outside the pack, and a
735// resolved base would have resolved this object too, so the walk never lands on a resolved object. An external base
736// is chain 0: a REF_DELTA on it is 1, and an OFS_DELTA on that object is one deeper. Same numbers verify-pack prints
737// once index-pack has appended the base. A loop over the OFS bases, each object's depth kept in `depths`: no recursion
738// (the chain is as long as maxDeltaChain allows) and no object walked twice.
739function chainDepth(obj: ParsedObject, byOffset: ReadonlyMap<number, ParsedObject>, depths: Map<number, number>): number {
740 const path: ParsedObject[] = [];
741 let cur = obj;
742 let depth: number;
743 for (;;) {
744 const known = mapGet(depths, cur.offset);
745 if (known.tag === 'some') { depth = known.value; break; }
746 if (cur.base.tag !== 'ofs') { depth = 1; depths.set(cur.offset, depth); break; }
747 const base = mapGet(byOffset, cur.base.offset);
748 // Stryker disable next-line ConditionalExpression: an ofs offset that is not an object is pack_corrupt before layout
749 if (base.tag === 'none') { depth = 0; break; }
750 path.push(cur);
751 cur = base.value;
752 }
753 for (const o of path.toReversed()) depths.set(o.offset, ++depth);
754 return depth;
755}
756function packLayout(parsed: ParsedPack, resolved: CollectedPack): PackLayout {
757 const memo = new Map<number, ResolvedObject>();
758 for (const r of resolved.objects.values()) memo.set(r.offset, r);
759 const byOffset = new Map(parsed.objects.map(o => [o.offset, o]));
760 const objects: PackLayoutObject[] = [];
761 const depths = new Map<number, number>();
762 for (const obj of parsed.objects) {
763 const found = mapGet(memo, obj.offset);
764 const r = found.tag === 'some' ? found.value : null;
765 objects.push({
766 offset: obj.offset,
767 headerBytes: obj.headerBytes,
768 compressed: obj.compressed,
769 size: obj.size,
770 wireType: obj.type,
771 type: r ? r.type : null,
772 oid: r ? r.oid : null,
773 base: baseOf(obj, memo),
774 depth: r ? r.chain : chainDepth(obj, byOffset, depths),
775 });
776 }
777 const missingBases: Oid[] = [];
778 const seenOid = new Set<Oid>();
779 for (const u of resolved.unresolved) {
780 if (seenOid.has(u.oid)) continue;
781 seenOid.add(u.oid);
782 missingBases.push(u.oid);
783 }
784 return { version: PACK_VERSION, count: parsed.stats.count, trailer: parsed.trailer, objects, missingBases };
785}
787// The pack's layout as `git verify-pack -v` prints it. A thin REF base is `missingBases`, not an error and not a
788// message to match. Limits are the same ones parse and resolve already enforce.
789export function describePack(buf: Uint8Array, limits: LimitsInput = DEFAULT_LIMITS): Result<PackLayout, PackError> {
790 const checked = parseLimits(limits);
791 if (!checked.ok) return checked;
792 const parsed = parsePack(buf, { limits: checked.value });
793 if (!parsed.ok) return parsed;
794 const resolved = fixpoint(parsed.value, noBase, checked.value, true);
795 if (!resolved.ok) return resolved;
796 return ok(packLayout(parsed.value, resolved.value));
797}
Diagnostics4 git calls · 185 ms
CallStatusSizeTime0185 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200145 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=145 git.pkt.payload.max=76 git.ls_refs.count=2 git.ls_refs.head=refs/heads/main
fetchblob:none · deepen 1020038 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=38434 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=19912563f540228593df0c489082e5e2508e21e4 git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=6 git.pkt.data=4 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=38434 git.pkt.payload.max=38339 git.sideband.band1.bytes=38338 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=63 git.pack.bytes=38338 git.pack.ofs_delta=0 git.pack.ref_delta=8 git.pack.chain.max=8 git.pack.trailer=0bc36ab7adf82d3109177f11f1ea93f1ce071f77 git.pack.full=55Open pack map
fetch20013 KiB181 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=181 git.response.bytes=13386 git.response.cache=MISS git.response.duration_ms=181 git.fetch.wants=1f10341460edae07e5d9ed99f610c612c8cf7eec git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=13386 git.pkt.payload.max=13365 git.sideband.band1.bytes=13364 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/ply.git
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e2c7a25dd94afc
- Request
- 858e9905…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format