Artifactspublic-v0

ply

main
ply4 git calls408 ms40 KiB1 cachedprotocol v2
116 lines7.1 KiBRaw
1// Parse once (#156): what the parsers return is branded, and the brand is still a string to a reader. `tsc --noEmit`
2// must pass; every @ts-expect-error must still be an error.
3import type { Oid } from '../../src/oid.js';
4import { hashObject, parseTree, type ObjType, type TreeEntry } from '../../src/objects.js';
5import { parseLsRefLine, type LsRef } from '../../src/lsrefs.js';
6import { readObjHeader, parsePack, resolvePack, parseDelta, describePack, type ObjBase, type ObjSize, type DeltaProgram, type PackObjectInput, type ResolvedObjType, type PackBase } from '../../src/packresolve.js';
7import { validateWire, type WireField } from '../../src/validate.js';
8import { fetchBody, fetchRequest, type FetchRequest } from '../../src/fetch.js';
9import { Sha1 } from '../../src/sha1.js';
11// object ids made from bytes in hand
12const hashed: Oid = hashObject('blob', new Uint8Array(0));
13const digest: Oid = new Sha1().hex();
14const text: string = hashed;
15void digest; void text;
16const tree = parseTree(new Uint8Array(0));
17if (tree.ok) for (const e of tree.value) { const entry: TreeEntry = e; const id: Oid = entry.oid; void id; }
18const line = parseLsRefLine('');
19if (line.ok && line.value !== null) { const r: LsRef = line.value; const id: Oid = r.oid; const peeled: Oid | null = r.peeled; void id; void peeled; }
21// a pack header's type is one of the six, and a parsed REF base is an Oid
22const header = readObjHeader(new Uint8Array(0), 0);
23if (header.ok) { const t: ObjType = header.value.type; void t; }
24if (header.ok) { const size: ObjSize = header.value.size; const n: number = size; void n; }
25// @ts-expect-error a plain number is not a checked object size
26const forgedSize: ObjSize = 3;
27void forgedSize;
28const pack = parsePack(new Uint8Array(0));
29if (pack.ok) {
30 for (const o of pack.value.objects) {
31 const t: ObjType = o.type;
32 const base: ObjBase = o.base;
33 if (base.tag === 'ref') { const id: Oid = base.oid; void id; }
34 if (base.tag === 'ofs') { const at: number = base.offset; void at; }
35 void t;
36 }
37 // a parsed pack is resolvePack's input as it is
38 void resolvePack(pack.value);
40// resolvePack also takes objects built by hand with plain values (parsed at its edge: an invalid one is bad_request)
41const handBuilt: PackObjectInput[] = [
42 { offset: 12, type: 3, data: new Uint8Array(0) },
43 { offset: 30, type: 6, data: new Uint8Array(0), base: { tag: 'ofs', offset: 12 } },
44 { offset: 40, type: 7, data: new Uint8Array(0), base: { tag: 'ref', oid: 'a'.repeat(40) } },
45];
46const resolved = resolvePack({ objects: handBuilt }, oid => (oid === 'a'.repeat(40) ? { type: 3, data: new Uint8Array(0) } : null));
47if (resolved.ok) for (const r of resolved.value.objects.values()) { const t: ResolvedObjType = r.type; const id: Oid = r.oid; void t; void id; }
48// @ts-expect-error a ref base is not a plain number
49const badBase: PackObjectInput = { offset: 1, type: 7, data: new Uint8Array(0), base: { tag: 'ref', oid: 1 } };
50void badBase;
51// a delta is parsed once into a program; only parseDelta makes one
52const program = parseDelta(new Uint8Array(0));
53if (program.ok) { const p: DeltaProgram = program.value; const n: number = p.dstSize; void n; }
54// @ts-expect-error a DeltaProgram is not built by hand
55const forgedProgram: DeltaProgram = { srcSize: 0, dstSize: 0, ops: { copy: 0, insert: 0, copyBytes: 0, insertBytes: 0 }, code: new Uint8Array(0), start: 0 };
56void forgedProgram;
57// describePack's rows: wire type, resolved type, ids and a tagged base
58const layout = describePack(new Uint8Array(0));
59if (layout.ok) for (const o of layout.value.objects) { const b: PackBase = o.base; const id: Oid | null = o.oid; const w: ObjType = o.wireType; void b; void id; void w; }
61// a wire field is made only by validateWire
62// @ts-expect-error a plain string is not a WireField
63const forged: WireField = 'x';
64void forged;
65const wire = validateWire('x', 'field');
66if (wire.ok) { const w: WireField = wire.value; const s: string = w; void s; }
68// FetchOpts stays plain strings in; the parsed request's wants, haves and shallows are Oids, the other tokens wire fields
69void fetchBody({ wants: ['a'.repeat(40)], haves: ['b'.repeat(40)], shallows: ['c'.repeat(40)], filter: 'blob:none', deepen: 1 });
70const req = fetchRequest({ wants: ['a'.repeat(40)] });
71if (req.ok) {
72 const r: FetchRequest = req.value;
73 for (const w of r.wants) { const want: Oid = w; void want; }
74 for (const h of r.haves) { const have: Oid = h; void have; }
75 for (const s of r.shallows) { const shallow: Oid = s; void shallow; }
76 for (const n of r.deepenNot) { const not: WireField = n; void not; }
78declare const someField: WireField;
79// @ts-expect-error a parsed have is an Oid, not just a wire field
80const haveField: FetchRequest['haves'][number] = someField;
81void haveField;
82// @ts-expect-error a FetchRequest is not built from plain strings
83const forgedReq: FetchRequest = { wants: ['x'], haves: [], shallows: [], deepenNot: [], filter: null, deepen: 0, deepenSince: 0, deepenRelative: false, thinPack: false, ofsDelta: true, includeTag: false, noProgress: true, done: true };
84void forgedReq;
86// part 2: listed names, parsed commits, tree entries, ids at the entries, the edit plan
87import type { ListedName } from '../../src/lsrefs.js';
88import { parseCommit, treeEntryOf, encodeEntries, type EntryOf, type Mode } from '../../src/objects.js';
89import { mergeBaseOf, type MergeBase } from '../../src/merge.js';
90import { objectAt } from '../../src/fetch.js';
91import { commitById } from '../../src/commit.js';
92import { validateSpec, type EditBase } from '../../src/edit.js';
93import type { Transport } from '../../src/transport.js';
94import { DEFAULT_LIMITS } from '../../src/limits.js';
95declare const tr: Transport;
96if (line.ok && line.value !== null) { const n: ListedName = line.value.name; const s: string = n; void s; }
97// @ts-expect-error a plain string is not a listed name
98const forgedName: ListedName = 'HEAD';
99void forgedName;
100const commit = parseCommit(new Uint8Array(0));
101if (commit.ok) { const tree: Oid = commit.value.tree; const parents: readonly Oid[] = commit.value.parents; void tree; void parents; }
102const entry = treeEntryOf({ mode: '100644', name: 'f', oid: 'a'.repeat(40) });
103if (entry.ok) { const e: EntryOf = entry.value; const m: Mode = e.mode; const id: Oid = e.oid; void m; void id; void encodeEntries([e]); }
104// @ts-expect-error encodeEntries takes parsed entries, not plain strings
105void encodeEntries([{ mode: '100644', name: 'f', oid: 'a'.repeat(40) }]);
106// @ts-expect-error the internals take an Oid
107void objectAt(tr, 'a'.repeat(40));
108// @ts-expect-error the internals take an Oid
109void commitById(tr, 'a'.repeat(40));
110// @ts-expect-error the internals take an Oid
111void mergeBaseOf(tr, 'a'.repeat(40), 'a'.repeat(40));
112if (header.ok) { void objectAt(tr, hashed); void commitById(tr, hashed); }
113const mb = await mergeBaseOf(tr, hashed, hashed);
114if (mb.ok) { const r: MergeBase = mb.value; const base: Oid | null = r.base; void base; for (const [k] of r.commits) { const id: Oid = k; void id; } }
115const plan = validateSpec({ path: 'a', find: 'x', replace: 'y', author: { name: 'n', email: 'e' }, message: 'm' }, DEFAULT_LIMITS);
116if (plan.ok) { const b: EditBase = plan.value.base; if (b.kind === 'commit') { const id: Oid = b.oid; void id; } const h: Oid | null = plan.value.head; void h; }
Diagnostics4 git calls · 408 ms
CallStatusSizeTime0408 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 B2 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=UPDATING
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=55
Open pack map
fetch2002.4 KiB404 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=404
git.response.bytes=2408
git.response.cache=MISS
git.response.duration_ms=404
git.fetch.wants=337d683c36421f199f6b938d8dd207a80f22654d
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=2408
git.pkt.payload.max=2387
git.sideband.band1.bytes=2386
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
a5e3024f1ae77929
Request
d864d11f…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format