main
ply4 git calls35 ms42 KiB2 cachedprotocol v2
67 lines2.9 KiBRaw
1export type ApiRefs = {
2 readonly head: string | null
3 readonly refs: Readonly<Record<string, string>>
4 readonly peeled?: Readonly<Record<string, string>>
5}
7export type RefJudgement = { readonly ok: true } | { readonly ok: false; readonly detail: string }
9const OID = /^[0-9a-f]{40}$/
11export function parseShowRef(text: string): Map<string, string> {
12 const map = new Map<string, string>()
13 for (const line of text.split('\n')) {
14 const match = /^([0-9a-f]{40})\s+(\S+)$/.exec(line.trim())
15 if (match?.[1] && match[2]) map.set(match[2], match[1])
16 }
17 return map
20/** Exit 0, and no error/fatal/missing/bad/corrupt/broken line. Dangling and unreachable objects are allowed. */
21export function judgeFsck(code: number, stdout: string, stderr: string): RefJudgement {
22 if (code !== 0) return { ok: false, detail: `git fsck exited ${code}` }
23 for (const line of `${stdout}\n${stderr}`.split('\n')) {
24 const trimmed = line.trim()
25 if (!trimmed || /dangling|unreachable/i.test(trimmed)) continue
26 if (/\b(error|fatal|missing|bad|corrupt|broken)\b/i.test(trimmed)) return { ok: false, detail: trimmed }
27 }
28 return { ok: true }
31/**
32 * `/v1/refs` against `git show-ref`, `git rev-parse ref^{}`, and `git symbolic-ref HEAD`.
33 * An annotated tag's ref oid is the tag object. The peeled commit is a separate map.
34 */
35export function judgeRefs(
36 api: ApiRefs,
37 showRef: ReadonlyMap<string, string>,
38 peeled: ReadonlyMap<string, string>,
39 symbolicHead: string,
40): RefJudgement {
41 if (api.head !== symbolicHead) return { ok: false, detail: `head ${api.head ?? 'null'}, git symbolic-ref ${symbolicHead}` }
42 for (const [name, oid] of showRef) {
43 if (api.refs[name] !== oid) return { ok: false, detail: `${name} is ${api.refs[name] ?? 'absent'} in /v1/refs and ${oid} in git` }
44 }
45 for (const [name, oid] of Object.entries(api.refs)) {
46 if (showRef.get(name) !== oid) return { ok: false, detail: `${name} is ${oid} in /v1/refs and ${showRef.get(name) ?? 'absent'} in git` }
47 }
48 for (const [name, oid] of peeled) {
49 if (!OID.test(oid)) return { ok: false, detail: `${name} peeled to ${oid}` }
50 const target = showRef.get(name)
51 if (target === undefined) return { ok: false, detail: `${name} peeled but is not a ref` }
52 if (oid === target) {
53 if (api.peeled && name in api.peeled && api.peeled[name] !== oid) {
54 return { ok: false, detail: `${name} peeled to its own oid but /v1/refs says ${api.peeled[name]}` }
55 }
56 continue
57 }
58 if (api.peeled?.[name] !== oid) {
59 return { ok: false, detail: `${name} peels to ${oid}, /v1/refs peeled ${api.peeled?.[name] ?? 'absent'}` }
60 }
61 if (api.refs[name] === oid) return { ok: false, detail: `${name} returned the peeled commit instead of the tag object` }
62 }
63 for (const [name, oid] of Object.entries(api.peeled ?? {})) {
64 if (peeled.get(name) !== oid) return { ok: false, detail: `${name} peeled ${oid} in /v1/refs and ${peeled.get(name) ?? 'absent'} in git` }
65 }
66 return { ok: true }
Diagnostics4 git calls · 35 ms
CallStatusSizeTime035 ms
discover200152 B4 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=4
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 B5 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=5
git.response.bytes=145
git.response.cache=UPDATING
git.response.duration_ms=5
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 1020040 KiB · hit8 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=41349
git.response.cache=HIT
git.response.duration_ms=8
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=526b305930b8ef382f2d7a1f9c0238730a585921
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=41349
git.pkt.payload.max=41254
git.sideband.band1.bytes=41253
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=61
git.pack.bytes=41253
git.pack.ofs_delta=0
git.pack.ref_delta=0
git.pack.chain.max=0
git.pack.trailer=ab60efef4b7243678c75de64a4386986ee885c1c
git.pack.full=61
Open pack map
fetch2001.1 KiB · hit22 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=22
git.response.bytes=1083
git.response.cache=HIT
git.response.duration_ms=22
git.fetch.wants=ba2b53fc75987a568e1dec045f0f8102a99d287d
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=1083
git.pkt.payload.max=1062
git.sideband.band1.bytes=1061
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-web.git
Ref
refs/heads/main
Commit
526b305930b8ef382f2d7a1f9c0238730a585921
cf-ray
a5e2b9fdcf88cf33
Request
2f953617…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format