GitHubivarvong
ply
main
1// The tree-entry name checks (src/validate.ts isDotGitName, isDotFileName, and isHfsDot through checkoutPathRefusal)
2// answer exactly what they answered before #207 made them allocation-free (test/oracle/dotnames-ref.ts, the c91c9cf
3// code): every byte string up to two bytes, short strings over the bytes the checks branch on, every spelling × prefix ×
4// tail with its truncations, one-byte substitutions, deletions, doublings and ignorables inserted, and random names.
5// Under the mutation run (MUTATION=1) the same generators at smaller sizes. The large campaign (every 3-byte string,
6// 4 bytes over the branch bytes, every head and tail, 10^7 random names) is test/fuzz/dotnames.mjs. Both sides are
7// held to git by test/space/fsck-tree.test.js.
8import { test } from 'vitest';
9import assert from 'node:assert/strict';
10import { ALPHABET, ALL_BYTES, BRANCH_BYTES, BYTE_TAILS, exhaustive, targeted, rng, randomName, judge, hfsGitmodules } from './dotnames-corpus.js';
11import { checkoutPathRefusal } from '../src/validate.js';
12import { unwrap } from './unwrap.js';
14const QUICK = process.env.MUTATION === '1';
15const agree = (names, label, minHits = 0) => {
16 const stats = { n: 0, hits: 0 };
17 const bad = judge(names, stats);
18 assert.equal(bad, null, `${label}: ${JSON.stringify(bad)}`);
19 assert.ok(stats.hits >= minHits, `${label}: only ${stats.hits} of ${stats.n} names spell anything (expected ≥ ${minHits}): the corpus is vacuous`);
20 return stats;
21};
23test('every byte string up to 2 bytes (1 under mutation)', () => {
24 agree(exhaustive(ALL_BYTES, QUICK ? 1 : 2), 'all bytes');
25});
27test('every string up to 3 bytes over the bytes the checks branch on', () => {
28 // no spelling is that short: this holds the first-byte exit and the tail and NUL branches on near misses
29 agree(exhaustive(QUICK ? BRANCH_BYTES : ALPHABET.subarray(0, 40), 3), 'branch bytes ≤ 3');
30});
32test('every spelling, truncated, substituted, shortened, doubled and with ignorables inserted', () => {
33 if (QUICK) {
34 // every spelling with the short tails, substituted by the branch bytes; the UTF-8 byte tails after one of each kind
35 const s = agree(targeted([''], ['', ':x', '\\x'], BRANCH_BYTES, []), 'targeted', 1_000);
36 const u = agree(targeted([''], [], BRANCH_BYTES.subarray(0, 0), BYTE_TAILS, ['.git', 'git~1', '.gitmodules', 'gitmod~1', 'gi7eba~1', '~1234567']), 'targeted utf-8 tails', 100);
37 assert.ok(s.n + u.n > 50_000, `targeted corpus is ${s.n + u.n} names`);
38 return;
39 }
40 const s = agree(targeted(['', 'a\\'], ['', '. .', ':x', '\\x', '\0', 'x']), 'targeted', 10_000);
41 assert.ok(s.n > 500_000, `targeted corpus is ${s.n} names`);
42});
44test('random names from spelling fragments (seeded)', () => {
45 const r = rng(Number(process.env.DOTNAMES_SEED ?? 207));
46 const n = QUICK ? 5_000 : 30_000;
47 agree((function* () { for (let i = 0; i < n; i++) yield randomName(r); })(), 'random', QUICK ? 10 : 100);
48});
50test('checkoutPathRefusal reads isHfsDot(.gitmodules) as before, on every targeted name it can be asked about', () => {
51 let asked = 0, hits = 0;
52 for (const b of targeted([''], QUICK ? ['', 'x'] : ['', '. .', ':x', '\\x', 'x'], BRANCH_BYTES, QUICK ? [] : BYTE_TAILS)) {
53 const v = hfsGitmodules(b);
54 if (v === null) continue;
55 asked++; if (v.want) hits++;
56 assert.equal(v.got, v.want, [...b].map(x => x.toString(16)).join(' '));
57 }
58 assert.ok(asked > 10_000 && hits > 20, `asked ${asked}, ${hits} spell .gitmodules on HFS+`);
59});
61test('checkoutPathRefusal: a symlink at a spelling of .gitmodules, by platform and position', () => {
62 const why = (path, mode, platform) => { const r = unwrap(checkoutPathRefusal(path, mode, platform)); return r.tag === 'some' ? r.value : null; };
63 const LINK = 'a symlink at a spelling of .gitmodules';
64 // exactly .gitmodules (any case), anywhere, any platform
65 assert.equal(why('a/.GITMODULES', '120000', 'linux'), LINK);
66 assert.equal(why('.gitmodules/x', '120000', 'linux'), LINK);
67 // not a symlink: no refusal
68 assert.equal(why('.gitmodules', '100644', 'darwin'), null);
69 assert.equal(why('.gitmodules', '100644', 'darwin'), null);
70 // the HFS+ spelling: on macOS only, at any component
71 assert.equal(why('.gitmodules/x', '120000', 'darwin'), LINK);
72 assert.equal(why('.gitmodules/x', '120000', 'linux'), null);
73 // the NTFS spellings: at the last component only (and the HFS+ one there, on every platform)
74 assert.equal(why('a/gitmod~1', '120000', 'linux'), LINK);
75 assert.equal(why('gitmod~1/x', '120000', 'linux'), null);
76 assert.equal(why('a/.gitmodules', '120000', 'linux'), LINK);
77 assert.equal(why('x/.gitmodulesx', '120000', 'darwin'), null);
78});
Diagnostics6 git calls · 104 ms
CallStatusSizeTime0104 ms
discover200191 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=1 git.response.bytes=191 git.server.agent=git/github-9922ec520325-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=191 git.pkt.payload.max=36
ls-refs20012 KiB1 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=1 git.response.bytes=11990 git.response.cache=UPDATING git.response.duration_ms=1 git.protocol.version=2 git.pkt.frames=152 git.pkt.data=151 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=11990 git.pkt.payload.max=122 git.ls_refs.count=151 git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 102004.2 KiB · hit1 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=4347 git.response.cache=HIT git.response.duration_ms=1 git.fetch.filter=tree:0 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=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=4347 git.pkt.payload.max=4247 git.sideband.band1.bytes=4247 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=4247 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=a6caf8e129bea82c9bae4cbc7c130c9205add400 git.pack.full=10Open pack map
fetchtree:0200919 B · 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=919 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=800d30ba8923860bfc460ca884b7f9ba22083588 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=919 git.pkt.payload.max=892 git.sideband.band1.bytes=892 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=892 git.pack.trailer=5323b9266eea5ded637285d1c5320699f12be76eOpen pack map
fetchtree:02005.6 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=97 git.response.bytes=5724 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=tree:0 git.fetch.wants=58fabb6768b3f737ee9cd8bac647bdc27405fb4d 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=5724 git.pkt.payload.max=5697 git.sideband.band1.bytes=5697 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=1 git.pack.bytes=5697 git.pack.trailer=be7e0453974a5fe832f9065a33bb7e3434c10e9bOpen pack map
fetch2001.9 KiB97 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1979 git.response.cache=MISS git.response.duration_ms=97 git.fetch.wants=638fcb8af9ab6ece478b826038af489dc4dfe2f9 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1979 git.pkt.payload.max=1952 git.sideband.band1.bytes=1952 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://github.com/ivarvong/ply
- Ref
- refs/heads/main
- Commit
- 19912563f540228593df0c489082e5e2508e21e4
- cf-ray
- a5e15f4f1f22725b
- Request
- c36324bd…
- Protocol
- v2 · sha1
- Agent
- git/github-9922ec520325-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format