main
1// Random trees for the differential test of parseTree (#207): src/objects.ts against the parser before it
2// (test/oracle/parsetree-ref.ts). Shared by test/parsetree.test.js and test/fuzz/parsetree.mjs.
3import { parseTree } from '../src/objects.js';
4import { parseTreeRef } from './oracle/parsetree-ref.ts';
5import { randomName, SPELLINGS } from './dotnames-corpus.js';
7const enc = s => new TextEncoder().encode(s);
8// Modes git writes, ones it canonicalizes, and ones fsck refuses (empty, zero-padded, not octal, not ASCII)
9const MODES = ['100644', '100755', '120000', '40000', '160000', '100664', '100700', '40755', '1', '7', '777777', '140000', '1040000',
10 '7100644', '300644', '777777777777777777777777040000', '0', '040000', '00', '', '8', 'g7', '1006 44', '10064é', '100644', '-1', '4000a'];
11const WORDS = ['a', 'b', 'd', 'd.x', 'd0', 'D', 'src', 'README.md', 'é', 'é', 'a/b', '.', '..', '', 'x'.repeat(4097), 'x'.repeat(4096), 'README'];
12const sortKey = e => [...e.name, ...(e.dir ? [0x2f] : [])];
13const cmp = (a, b) => { const x = sortKey(a), y = sortKey(b); for (let i = 0; i < Math.min(x.length, y.length); i++) if (x[i] !== y[i]) return x[i] - y[i]; return x.length - y.length; };
15export function randomTree(r) {
16 const n = r.int(4) === 0 ? r.int(3) : 1 + r.int(12);
17 const entries = [];
18 for (let i = 0; i < n; i++) {
19 const mode = r.int(5) === 0 ? r.pick(MODES) : r.pick(MODES.slice(0, 5));
20 const k = r.int(10);
21 const name = k < 4 ? enc(r.pick(WORDS)) : k < 6 ? randomName(r) : k < 7 ? enc(r.pick(SPELLINGS)) : enc(`f${r.int(1000)}`);
22 const oid = new Uint8Array(20);
23 if (r.int(20) !== 0) for (let j = 0; j < 20; j++) oid[j] = r.int(256);
24 const low = Number.parseInt(mode.slice(-6), 8) & 0xffff;
25 entries.push({ mode: enc(mode), name, oid, dir: /^[0-7]+$/.test(mode) && (low & 0o170000) === 0o40000 });
26 }
27 if (r.int(4) !== 0) entries.sort(cmp);
28 if (r.int(10) === 0 && entries.length > 0) entries.push(entries[r.int(entries.length)]);
29 const parts = [];
30 for (const e of entries) parts.push(...e.mode, ...(r.int(50) === 0 ? [] : [0x20]), ...e.name, ...(r.int(50) === 0 ? [] : [0]), ...e.oid);
31 let bytes = Uint8Array.from(parts);
32 if (r.int(15) === 0 && bytes.length > 0) bytes = bytes.subarray(0, r.int(bytes.length));
33 const limits = r.int(8) === 0 ? { maxTreeEntries: r.int(6) } : {};
34 return { bytes, limits };
35}
37const view = r => (r.ok ? { ok: true, entries: r.value.map(e => ({ mode: e.mode, name: e.name, oid: e.oid, oidOffset: e.oidOffset, entryOffset: e.entryOffset })) } : { ok: false, code: r.error.code, message: r.error.message });
38// The first tree on which the two parsers differ (a repro), or null; counts accepted and refused trees
39export function judgeTrees(trees, stats = { n: 0, accepted: 0, refused: {} }) {
40 for (const { bytes, limits } of trees) {
41 const want = view(parseTreeRef(bytes, limits));
42 const got = view(parseTree(bytes, limits));
43 stats.n++;
44 if (want.ok) stats.accepted++; else stats.refused[want.message.replace(/".*"/u, '"…"').replace(/\d+/gu, 'N')] = (stats.refused[want.message.replace(/".*"/u, '"…"').replace(/\d+/gu, 'N')] ?? 0) + 1;
45 if (JSON.stringify(want) !== JSON.stringify(got)) return { hex: Buffer.from(bytes).toString('hex'), limits, want, got };
46 }
47 return null;
48}
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 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 · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=3 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 · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=24 git.response.bytes=38434 git.response.cache=HIT git.response.duration_ms=3 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
fetch2001.5 KiB · hit24 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1533 git.response.cache=HIT git.response.duration_ms=24 git.fetch.wants=3f1a74f098d1db9bf3139f4cd479d63d4bc29e5e 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=1533 git.pkt.payload.max=1512 git.sideband.band1.bytes=1511 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
- a5e353ea0cdf994c
- Request
- 7d5b2105…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format