Artifactspublic-v0

ply

main
ply4 git calls375 ms39 KiB2 cachedprotocol v2
67 lines3.9 KiBRaw
1// Run `git pack-objects` exactly as upload-pack does for a v2 fetch, and return the
2// object set it produced. This is the exact-set oracle; the model gives the bound.
3import { execFileSync } from 'node:child_process';
4import { gitBuf } from '../server.js';
5import { parsePack, resolvePack } from '../../src/pack.js';
6import { effectiveHaves } from './dag.js';
7import { unwrap } from '../unwrap.js';
9// Git 2.56 moved the argv out of upload-pack.c create_pack_file into
10// odb/source-files.c odb_source_files_generate_pack. --thin follows --stdout, and
11// progress-none (ply sends no-progress by default) is spelled --quiet. Through 2.55
12// --thin precedes --stdout and a quiet client adds no flag.
13export const PACK_ARGV_QUIET = Object.freeze([2, 56, 0]);
15const atLeast = (version, floor) => version[0] > floor[0] || (version[0] === floor[0] && (version[1] > floor[1] || (version[1] === floor[1] && version[2] >= floor[2])));
17export function installedGitVersion() {
18 const s = execFileSync('git', ['--version'], { encoding: 'utf8' });
19 const m = /git version (\d+)\.(\d+)\.(\d+)/.exec(s);
20 if (!m) throw new Error(`unrecognized git version: ${s}`);
21 return [Number(m[1]), Number(m[2]), Number(m[3])];
24const INSTALLED_GIT = installedGitVersion();
26export function packObjectsOracle(bare, model, req, { shallowSet, unshallowed = [], inDepth = new Map(), external }) {
27 const { haves = [], filter, thinPack, ofsDelta = true } = req;
28 // send_unshallow(): an unshallowed client commit's parents become wants, the commit itself an extra edge.
29 // It sets object->parsed = 0 and re-parses, which appends the parents to the already-parsed list: each parent twice.
30 const wants = [...req.wants, ...unshallowed.flatMap(u => { const ps = model.commits.get(u).parents; return [...ps, ...ps]; })];
31 const peel = o => (model.tags.has(o) ? model.tags.get(o) : o);
32 const known = effectiveHaves(model, haves);
33 const shallows = [...shallowSet];
34 const extraEdges = new Set(unshallowed);
35 const { args, stdin } = reconstructInvocation({ wants, known, shallows, extraEdges, thinPack, ofsDelta, filter });
36 const pack = new Uint8Array(gitBuf(bare, ['pack-objects', ...args, '-q'], stdin));
37 if (pack.length === 0) return { objects: new Map(), count: 0 };
38 const parsed = unwrap(parsePack(pack));
39 const r = unwrap(resolvePack(parsed, external));
40 return { objects: r.objects, count: parsed.stats.count, parsed };
43// Argv in the order the installed git's upload-pack passes to pack-objects.
44export function packObjectsArgs({ thinPack, shallows, ofsDelta, includeTag, filter, version = INSTALLED_GIT }) {
45 const quiet = atLeast(version, PACK_ARGV_QUIET);
46 const args = ['--revs'];
47 if (thinPack && !quiet) args.push('--thin');
48 args.push('--stdout');
49 if (thinPack && quiet) args.push('--thin');
50 if (shallows.length) args.push('--shallow');
51 if (ofsDelta) args.push('--delta-base-offset');
52 if (includeTag) args.push('--include-tag');
53 if (quiet) args.push('--quiet');
54 if (filter) args.push(`--filter=${filter}`);
55 return args;
58export function reconstructInvocation({ wants, known, shallows, extraEdges, thinPack, ofsDelta, includeTag, filter, version }) {
59 const args = packObjectsArgs({ thinPack, shallows, ofsDelta, includeTag, filter, version });
60 // grafts are written in oid order (for_each_commit_graft walks a sorted list)
61 const stdin = [...[...shallows].sort().map(s => `--shallow ${s}`), ...wants, '--not', ...known, ...extraEdges, ''].join('\n') + '\n';
62 return { args, stdin };
64export function reconstructFor(model, req, { shallowSet, unshallowed = [] }) {
65 const wants = [...req.wants, ...unshallowed.flatMap(u => { const ps = model.commits.get(u).parents; return [...ps, ...ps]; })];
66 return reconstructInvocation({ wants, known: effectiveHaves(model, req.haves ?? []), shallows: [...shallowSet], extraEdges: unshallowed, thinPack: req.thinPack, ofsDelta: req.ofsDelta !== false, filter: req.filter });
Diagnostics4 git calls · 375 ms
CallStatusSizeTime0375 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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=2
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=55
Open pack map
fetch2001.6 KiB369 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=369
git.response.bytes=1622
git.response.cache=MISS
git.response.duration_ms=369
git.fetch.wants=69ea04e077f7825ed2966ec68e4a721d43cfcf07
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=1622
git.pkt.payload.max=1601
git.sideband.band1.bytes=1600
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
a5e251106b7eb071
Request
504fc5f9…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format