main
1// Stock git's answers, classified the way ply's are (src/probe-evaluate.ts plyOutcome): `git push --porcelain` ref lines
2// and a `git fetch` exit, mapped onto ply's error-class names so wording differences between servers are normalized
3// before comparison. Only the in-repository runner (runner.mjs) runs stock git, so this stays out of `ply/probes`.
4import type { Classified } from '../../src/probe-evaluate.ts';
5import type { Outcome } from '../../src/probe-types.ts';
7// A refusal reason stock git printed for one ref, as the error class ply would give it. Wording differs between servers
8// ("failed to update ref", "stale ref", "incorrect old value provided"); the class is what is compared.
9// A refusal git makes itself because its advertisement already shows another writer's value ("stale info" for a lease,
10// "fetch first" for a create or update without force) is the same conflict the server's compare-and-swap reports when
11// git read the advertisement a moment earlier: which one a racing client sees is timing, so both are cas_conflict.
12export function gitReasonClass(reason: string, stderr: string): string {
13 if (/stale info|fetch first/.test(reason)) return 'cas_conflict';
14 if (/atomic push failure|atomic transaction failed/.test(reason)) return 'atomic_sibling';
15 if (/non-fast-forward/.test(reason)) return 'not_fast_forward';
16 if (/failed to update ref|failed to lock|cannot lock|incorrect old value|stale ref|already exists|does not exist|bad ref|reference/.test(reason)) return 'cas_conflict';
17 if (/exceeds maximum|too large|limit is|maximum allowed/i.test(`${reason}\n${stderr}`)) return 'limit_exceeded';
18 return 'push_rejected';
19}
21const OK_FLAGS = new Set([' ', '+', '-', '*', '=']);
22// `git push --porcelain`: a `<flag>\t<src>:<dst>\t<summary>` line per ref (git-push(1) OUTPUT). No ref line and a
23// non-zero exit is a push whose answer git never read: ambiguous.
24// `creates`: the refs the plan creates (zero old id). git refuses a create of a ref its advertisement already shows as
25// "non-fast-forward" (or "fetch first"): for a create that is the conflict, not a history rule.
26// `git fetch`: landed when it exits 0; a low-speed abort is the timeout class, anything else a failed fetch.
27export function gitFetchOutcome(status: number | null, stderr: string): Classified {
28 const tail = stderr.trim().split('\n').slice(-3).join(' | ').slice(0, 300);
29 if (status === 0) return { outcome: 'landed', error: null, detail: 'fetched' };
30 if (/too slow|timed out|Timeout was reached/i.test(stderr)) return { outcome: 'rejected', error: 'timeout', detail: tail };
31 return { outcome: 'rejected', error: 'fetch_failed', detail: tail };
32}
34export function gitOutcome(status: number | null, stdout: string, stderr: string, creates: ReadonlySet<string> = new Set()): Classified {
35 const refs = stdout.split('\n').filter(l => /^[ +\-*=!]\t[^\t]*:[^\t]*\t/.test(l)).map(l => {
36 const [flag = '!', spec = '', summary = ''] = l.split('\t');
37 const reason = /\(([^)]*)\)\s*$/.exec(summary)?.[1] ?? summary;
38 return { ok: OK_FLAGS.has(flag), reason: creates.has(spec.slice(spec.indexOf(':') + 1)) && reason === 'non-fast-forward' ? 'fetch first' : reason };
39 });
40 const tail = stderr.trim().split('\n').slice(-3).join(' | ').slice(0, 300);
41 if (refs.length === 0) return status === 0 ? { outcome: 'landed', error: null, detail: 'no ref lines' } : { outcome: 'ambiguous', error: 'ambiguous', detail: tail };
42 const bad = refs.filter(r => !r.ok);
43 if (bad.length === 0 && status === 0) return { outcome: 'landed', error: null, detail: 'ok' };
44 if (bad.length === 0) return { outcome: 'ambiguous', error: 'ambiguous', detail: tail };
45 if (bad.length < refs.length) return { outcome: 'partial', error: 'push_partial', detail: bad.map(b => b.reason).join('; ') };
46 const classes = bad.map(b => gitReasonClass(b.reason, stderr));
47 const error = classes.find(c => c !== 'atomic_sibling') ?? 'cas_conflict';
48 const outcome: Outcome = error === 'cas_conflict' ? 'conflict' : 'rejected';
49 return { outcome, error, detail: bad.map(b => b.reason).join('; ') };
50}
Diagnostics4 git calls · 399 ms
CallStatusSizeTime0399 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=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 · hit6 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=390 git.response.bytes=38434 git.response.cache=HIT git.response.duration_ms=6 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.7 KiB390 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1704 git.response.cache=MISS git.response.duration_ms=390 git.fetch.wants=f3a05be7b4655e7c648b0b2a14d99b044ac3e55f 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=1704 git.pkt.payload.max=1683 git.sideband.band1.bytes=1682 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
- a5e324ab8c1d98f1
- Request
- 30ca38b5…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format