main
1// Node only (node:fs, node:path): push a local repository, with its history, to a smart-HTTP remote without a git
2// binary. Not part of any Workers bundle.
3//
4// pushRepo(dir, url, { refspecs, all, tags, force, dryRun, thin }, opts) → { upToDate, updates, current, objects, … }
5//
6// `dir` is a work tree (with `.git`, a directory or a `gitdir:` file) or a bare repository. What is pushed, as
7// `git push <url> <refspecs>` decides it: each refspec is `src`, `src:dst`, `+src:dst` (forced) or `:dst` (delete);
8// `src` is resolved as git resolves a name (`x`, `refs/x`, `refs/tags/x`, `refs/heads/x`, `refs/remotes/x`), `HEAD`
9// is the current branch, and a missing `dst` is the same ref. `all` adds every branch, `tags` every tag. With none of
10// these, the current branch goes to the same name (push.default=simple without an upstream).
11//
12// One ls-refs, then one receive-pack request for every command. The pack is what the remote lacks: everything
13// reachable from the new tips minus everything reachable from the remote's refs that this repository has (gitlinks
14// are not followed). Trees and blobs are delta-compressed against the previous version of the same path in the same
15// pack (delta.ts planDeltas: OFS_DELTA, chains of at most 50); `thin: true` also deltas the first version of a path
16// against the remote's copy (REF_DELTA). receive-pack accepts thin packs unless it was started with
17// --reject-thin-pack-for-testing, and `git push` sends them by default, but ply cannot prove that for a host it has
18// not seen, so it is opt-in.
19//
20// Refused locally, before anything is sent: a non-fast-forward update of a branch (or of a ref whose current tip this
21// repository does not have: git's "fetch first"), and any change to an existing tag, unless the refspec has `+` or
22// `force` is set. That is `not_fast_forward` (the code a server's own non-fast-forward refusal carries in push.ts),
23// naming every refused ref; none of the other commands are sent either. Every ref already at its target: nothing is
24// sent (no receive-pack request) and the result says `upToDate`. `dryRun`: the same decisions and object count, and
25// no receive-pack request.
26//
27// Memory: every packfile is read and resolved in memory (parsePack, resolvePack; no .idx is read), so this suits
28// repositories up to a few hundred MB. The resident set is bounded by limits.maxInflatedTotal (the objects held), the
29// object count by limits.maxPackObjects, each object by limits.maxObjectSize, the pack sent by limits.maxPackBytes and
30// the refs by limits.maxRefs: past any of them the answer is `limit_exceeded`, never a partial push. The defaults hold
31// a repository of about 256 MiB of objects whose packs are each at most 128 MiB; for a larger one raise
32// maxInflatedTotal, maxPackObjects and (for a single pack over 128 MiB) maxPackBytes. All of it is then held in
33// memory: a repository that does not fit goes through the range-reader pipeline instead (scanPackIndex,
34// resolvePackRange, planPackBatches, packSubset over a RangeSource), which holds no pack whole. A packfile is
35// held whole while it is parsed, so each is bounded by limits.maxPackBytes before a byte of it is read (its size from
36// the open handle; `limit_exceeded`, what: 'local pack bytes'; one exactly at the bound is read). No read call is
37// asked for more than 1 GiB (READ_CHUNK), so a pack of 2 GiB or more under a raised bound is read in pieces, and one
38// the runtime has no buffer for is `limit_exceeded`, what: 'local pack buffer bytes'. A packfile the file system will not give (EACCES, EIO,
39// EISDIR, …) is `unsupported`, kind 'filesystem', what: 'local pack', with the path, the operation and the system's
40// code in the message and the thrown error as `cause`: pushRepo never rejects with a node:fs error for a packfile.
41// Every other file read whole is bounded the same way, from its size, before a byte of it is read (readBounded; one
42// exactly at the bound is read): a loose object file by zlibBound(limits.maxObjectSize + 32), the longest zlib stream
43// of an object within the limit (`limit_exceeded`, what: 'local loose object bytes'); packed-refs and config by
44// limits.maxLsRefsBytes, the bound a ref listing has on the wire (what: 'local packed-refs bytes', 'local config
45// bytes'); a loose ref file, HEAD, commondir and a `.git` file, each one line, by 65 520 bytes (LINE_FILE_MAX, the
46// pkt-line maximum: what: 'local ref file bytes', 'local HEAD bytes', 'local commondir bytes', 'local .git file
47// bytes'). A text the runtime has no string for under a raised bound is `limit_exceeded` (what: '… buffer bytes').
48//
49// Refused as `bad_request` with `what`: SHA-256 repositories (objectFormat), reftable (refStorage), partial clones
50// (partialClone), objects/info/alternates (alternates) and shallow repositories (shallow).
51/* oxlint-disable no-await-in-loop -- the walks read one object at a time from the local repository, under the bounds */
52/* oxlint-disable import/max-dependencies -- an entry composes the protocol from one import per module */
53import { open, readdir, readlink, lstat, stat } from 'node:fs/promises';
54import type { FileHandle } from 'node:fs/promises';
55// oxlint-disable-next-line unicorn/import-style -- `path` names a tree path throughout this file
56import { join, resolve } from 'node:path';
57import { fail, plyError } from './errors.js';
58import type { ErrorOf, PlyError } from './errors.js';
59import { thrownCode } from './boundary.js';
60import { LIMIT_OBJECT_OVERHEAD, limitExceeded, limitsOf, lowered } from './limits.js';
61import type { CheckedLimits } from './limits.js';
62import { inflate } from './inflate.js';
63import { parsePack, resolvePack } from './packresolve.js';
64import { hashObject, parseCommit, parseTag, TYPE, TYPE_ID } from './objects.js';
65import { PKT_MAX_SIZE, ZERO_OID, zlibBound } from './format.js';
66import { lsRefs } from './lsrefs.js';
67import { push } from './push.js';
68import type { Command, Commands } from './push.js';
69import { operation } from './operation.js';
70import type { OperationOpts } from './operation.js';
71import type { ReadOptions } from './read.js';
72import { validatePushRef, validateRef } from './validate.js';
73import { planDeltas } from './delta.js';
74import type { DeltaCandidate, DeltaPlan, ThinBase } from './delta.js';
75import { children, missing, popped, reachable } from './packwalk.js';
76import type { Walk as PackWalk } from './packwalk.js';
77import type { Span } from './otel.js';
78import { decodeBytes } from './bytes.js';
79import { configCommentStart } from './transport.js';
80import type { Input } from './absent.js';
81import { at, isArgObject, mapGet, readKey, withDefaults } from './absent.js';
82import { err, getOrElse, ok } from './result.js';
83import type { Err, Option, Result } from './result.js';
85const OID = /^[0-9a-f]{40}$/u;
86const SYMREF = 'ref: ';
87const MAX_SYMREF_DEPTH = 5;
88const HEX_DIR = 2;
89// a loose object's header, "<type> <size>\0", is at most this long ("commit ", 20 digits, NUL)
90const HEADER_ROOM = 32;
91const OID_SHOWN = 40;
93// ---- the local repository: where it is, its format, its refs ----
94type Repo = {
95 readonly dir: string;
96 readonly gitDir: string;
97 readonly commonDir: string;
98 readonly refs: ReadonlyMap<string, string>;
99 // HEAD's branch (refs/heads/…) when it names one, else null; HEAD's commit when it has one, else null
100 readonly headRef: string | null;
101 readonly head: string | null;
102};
104const mapOrNone = <T>(v: T | null): Option<T> => (v === null ? { tag: 'none' } : { tag: 'some', value: v });
105// The most a one-line file of the repository holds (a loose ref, HEAD, commondir, a `.git` file): the pkt-line
106// maximum (gitprotocol-common), past which a ref's name or value could not be sent either.
107const LINE_FILE_MAX = PKT_MAX_SIZE;
108// oxlint-disable-next-line typescript/promise-function-async -- lstat's own promise, mapped to a boolean
109const exists = (path: string): Promise<boolean> => lstat(path).then(() => true, () => false);
111// A file system failure as a value: `unsupported`, kind 'filesystem' (the shape checkout-node.ts gives the same class
112// of failure), naming the file, the operation and the system's own code (EACCES, EISDIR, …); the thrown error is `cause`.
113type FilesystemError = ErrorOf<'unsupported'> & { readonly kind: 'filesystem' };
114const filesystem = (what: string, op: string, path: string, e: unknown): Err<FilesystemError> => {
115 const code = thrownCode(e);
116 const named = code.tag === 'some' && typeof code.value === 'string' ? code.value : 'no error code';
117 return err(Object.assign(plyError('unsupported', `${what}: ${op} of ${JSON.stringify(path)} failed (${named})`, { what, path, cause: e }), { kind: 'filesystem' as const }));
118};
120// The most one read call is asked for (1 GiB). node's fs binding takes the length as an int32 and aborts the process
121// on more (node_file.cc fs.Read: `args[3]->IsInt32()`, SIGABRT, which no caller can catch), so a file of 2 GiB or more
122// under a raised limit is read in pieces.
123const READ_CHUNK = 1024 * 1024 * 1024;
125// One buffer of `size` bytes, or null when the runtime will not give one (a RangeError: past the largest typed array,
126// or no memory for it).
127const allocate = (size: number): Uint8Array | null => {
128 try { return new Uint8Array(size); } catch { return null; }
129};
131// A local file's bytes, held to `max`: the size comes from the open handle, a file past the bound is refused before a
132// byte of it is read, and no more than the size seen is read even when the file grows meanwhile (one that shrank is
133// what was there). No read call is asked for more than READ_CHUNK, and a file one buffer cannot hold is
134// `limit_exceeded` (what: '<what> buffer bytes'). Never rejects.
135async function readBounded(path: string, max: number, what: string): Promise<Result<Uint8Array, PlyError>> {
136 let op = 'open';
137 let handle: FileHandle | null = null;
138 try {
139 handle = await open(path, 'r');
140 op = 'stat';
141 const { size } = await handle.stat();
142 if (size > max) return err(limitExceeded(`${what} bytes`, size, max));
143 op = 'read';
144 const buf = allocate(size);
145 if (buf === null) return fail('limit_exceeded', `${what}: no buffer of ${size} bytes could be allocated (the file is within the limit ${max}, the process cannot hold it)`, { what: `${what} buffer bytes`, got: size, max });
146 let got = 0;
147 while (got < size) {
148 const { bytesRead } = await handle.read(buf, got, Math.min(size - got, READ_CHUNK), got);
149 if (bytesRead === 0) break;
150 got += bytesRead;
151 }
152 return ok(buf.subarray(0, got));
153 } catch (e) {
154 return filesystem(what, op, path, e);
155 } finally {
156 if (handle !== null) await handle.close().then(() => null, () => null);
157 }
158}
160// A file a repository may lack, held to `max` before a byte of it is read: its bytes, null when it cannot be opened or
161// read (absent, a directory), `limit_exceeded` when it is past the bound. Never rejects.
162async function maybeRead(path: string, max: number, what: string): Promise<Result<Uint8Array | null, PlyError>> {
163 const read = await readBounded(path, max, what);
164 return read.ok || read.error.code === 'limit_exceeded' ? read : ok(null);
165}
167// That file as text (UTF-8, as it was read before the bound). A text the runtime has no string for (node: 512 MiB)
168// under a raised bound is `limit_exceeded` as well, never a thrown ERR_STRING_TOO_LONG.
169async function maybeText(path: string, max: number, what: string): Promise<Result<string | null, PlyError>> {
170 const read = await maybeRead(path, max, what);
171 if (!read.ok) return read;
172 const b = read.value;
173 if (b === null) return ok(null);
174 try {
175 return ok(Buffer.from(b.buffer, b.byteOffset, b.byteLength).toString('utf8'));
176 } catch {
177 return fail('limit_exceeded', `${what}: no string of ${b.length} bytes could be made (the file is within the limit ${max}, the runtime cannot hold it as text)`, { what: `${what} buffer bytes`, got: b.length, max });
178 }
179}
181// The git directory of a work tree (`.git`, a directory or a `gitdir:` file) or a bare repository; null for neither.
182async function findGitDir(dir: string): Promise<Result<string | null, PlyError>> {
183 const dot = join(dir, '.git');
184 const st = await lstat(dot).then(s => s, () => null);
185 if (st !== null && st.isDirectory()) return ok(dot);
186 if (st !== null && st.isFile()) {
187 const text = await maybeText(dot, LINE_FILE_MAX, 'local .git file');
188 if (!text.ok) return text;
189 const m = text.value === null ? null : /^gitdir: (.+)$/mu.exec(text.value);
190 return ok(m === null ? null : resolve(dir, getOrElse(at(m, 1), '')));
191 }
192 return ok((await exists(join(dir, 'HEAD'))) && (await exists(join(dir, 'objects'))) && (await exists(join(dir, 'refs'))) ? dir : null);
193}
195// git config as `section.key` → value (the last one wins), enough to read the format extensions. Subsections are kept
196// in the section name; keys and section names are case-insensitive.
197export function readConfig(text: string): Map<string, string> {
198 const out = new Map<string, string>();
199 let section = '';
200 for (const raw of text.split('\n')) {
201 const line = raw.slice(0, configCommentStart(raw)).trim();
202 const head = /^\[([^\]\s"]+)(\s+"([^"]*)")?\]$/u.exec(line);
203 if (head !== null) {
204 const sub = at(head, 3);
205 section = sub.tag === 'some' ? `${getOrElse(at(head, 1), '').toLowerCase()}.${sub.value}` : getOrElse(at(head, 1), '').toLowerCase();
206 continue;
207 }
208 const kv = /^([A-Za-z][\w-]*)\s*(=\s*(\S[^\n\r\u2028\u2029]*|))?$/u.exec(line);
209 if (kv !== null && section !== '') out.set(`${section}.${getOrElse(at(kv, 1), '').toLowerCase()}`, getOrElse(at(kv, 3), 'true').trim());
210 }
211 return out;
212}
214// Why ply will not push from this repository, or null: the format extensions and layouts it does not read.
215type Refusal = { readonly what: string; readonly why: string };
216const refuse = (what: string, why: string): Result<Refusal | null, PlyError> => ok({ what, why });
217async function unsupported(commonDir: string, limits: CheckedLimits): Promise<Result<Refusal | null, PlyError>> {
218 const text = await maybeText(join(commonDir, 'config'), limits.maxLsRefsBytes, 'local config');
219 if (!text.ok) return text;
220 const config = readConfig(getOrElse<string>(mapOrNone(text.value), ''));
221 const format = getOrElse(mapGet(config, 'extensions.objectformat'), 'sha1').toLowerCase();
222 if (format !== 'sha1') return refuse('objectFormat', `object format ${format} (ply reads SHA-1 repositories only)`);
223 const refStorage = getOrElse(mapGet(config, 'extensions.refstorage'), 'files').toLowerCase();
224 if (refStorage !== 'files') return refuse('refStorage', `ref storage ${refStorage} (ply reads loose and packed refs only)`);
225 if (config.has('extensions.partialclone')) return refuse('partialClone', 'a partial clone (objects may be missing locally)');
226 if (await exists(join(commonDir, 'objects', 'info', 'alternates'))) return refuse('alternates', 'objects/info/alternates (objects stored in another repository)');
227 if (await exists(join(commonDir, 'shallow'))) return refuse('shallow', 'a shallow repository (history is cut off)');
228 return ok(null);
229}
231// A ref's value to its id through at most five symbolic hops: the id, 'dangling' for a symbolic ref that ends nowhere
232// (git keeps one, as refs/remotes/origin/HEAD after its branch is gone), or null for a value that is neither.
233const followRef = (raw: ReadonlyMap<string, string>, value: string): string | null => {
234 let v = value;
235 for (let i = 0; i <= MAX_SYMREF_DEPTH; i++) {
236 if (OID.test(v)) return v;
237 if (!v.startsWith(SYMREF)) return i === 0 ? null : 'dangling';
238 v = getOrElse(mapGet(raw, v.slice(SYMREF.length).trim()), '');
239 }
240 return 'dangling';
241};
243// Every ref: packed-refs, then loose refs over them (a loose ref is newer). A symbolic ref is followed (refs/remotes/
244// origin/HEAD) and left out when it ends nowhere; a value that is neither an id nor `ref: <name>` is refused.
245async function readRefs(commonDir: string, limits: CheckedLimits): Promise<Result<Map<string, string>, PlyError>> {
246 const { maxRefs } = limits;
247 const raw = new Map<string, string>();
248 const packedText = await maybeText(join(commonDir, 'packed-refs'), limits.maxLsRefsBytes, 'local packed-refs');
249 if (!packedText.ok) return packedText;
250 const packed = getOrElse<string>(mapOrNone(packedText.value), '');
251 for (const line of packed.split('\n')) {
252 const m = /^([0-9a-f]{40}) (refs\/\S+)$/u.exec(line);
253 if (m !== null) raw.set(getOrElse(at(m, 2), ''), getOrElse(at(m, 1), ''));
254 }
255 const walk = async (rel: string): Promise<Result<null, PlyError>> => {
256 const entries = await readdir(join(commonDir, rel), { withFileTypes: true }).then(e => e, () => []);
257 for (const e of entries.toSorted((a, b) => (a.name < b.name ? -1 : 1))) {
258 // git looks at no entry, file or directory, whose name starts with '.' or ends in '.lock' (refs/files-backend.c
259 // loose_fill_ref_dir), and its ref iteration leaves out a file whose full name check-ref-format refuses: such a
260 // file (Finder's .DS_Store, an editor's backup) is not a ref, whatever it holds
261 if (e.name.startsWith('.') || e.name.endsWith('.lock')) continue;
262 const name = `${rel}/${e.name}`;
263 const path = join(commonDir, name);
264 // a symbolic link is what it points at, as git's get_dtype(follow) reads an entry; one that points nowhere, or
265 // at neither a file nor a directory, is not a ref
266 const link = e.isSymbolicLink();
267 const target = link ? await stat(path).then(s => s, () => null) : e;
268 if (target === null) continue;
269 if (target.isDirectory()) {
270 // git walks into a linked directory; a link can loop, and nothing but the path length bounds that walk, so
271 // ply refuses it by name rather than leave its refs out of the push unsaid
272 if (link) return fail('bad_request', `${name}: a symbolic link to a directory under refs/ is not read`, { what: 'ref', path: name });
273 const sub = await walk(name);
274 if (!sub.ok) return sub;
275 } else if (target.isFile() && validateRef(name).ok) {
276 // refs/files-backend.c files_read_raw_ref: a link whose target text is a ref name is a symbolic ref to that
277 // name; any other link is read as the file it points at
278 const text = link ? await readlink(path).then(t => t, () => '') : '';
279 if (text.startsWith('refs/') && validateRef(text).ok) raw.set(name, `${SYMREF}${text}`);
280 else {
281 const value = await maybeText(path, LINE_FILE_MAX, 'local ref file');
282 if (!value.ok) return value;
283 raw.set(name, getOrElse<string>(mapOrNone(value.value), '').trim());
284 }
285 }
286 if (raw.size > maxRefs) return ok(null);
287 }
288 return ok(null);
289 };
290 const walked = await walk('refs');
291 if (!walked.ok) return walked;
292 if (raw.size > maxRefs) return err(limitExceeded('local refs', raw.size, maxRefs));
293 const refs = new Map<string, string>();
294 for (const [name, value] of raw) {
295 const oid = followRef(raw, value);
296 if (oid === 'dangling') continue;
297 if (oid === null) return fail('bad_request', `${name}: not an object id or a symbolic ref to one (${value.slice(0, OID_SHOWN)})`, { what: 'ref', path: name });
298 refs.set(name, oid);
299 }
300 return ok(refs);
301}
303async function openRepo(dir: string, limits: CheckedLimits): Promise<Result<Repo, PlyError>> {
304 const found = typeof dir === 'string' && dir !== '' ? await findGitDir(dir) : ok(null);
305 if (!found.ok) return found;
306 const gitDir = found.value;
307 if (gitDir === null) return fail('bad_request', `${typeof dir === 'string' ? dir : '(not a string)'}: not a git repository (no .git, and not a bare repository)`, { what: 'dir' });
308 const common = await maybeText(join(gitDir, 'commondir'), LINE_FILE_MAX, 'local commondir');
309 if (!common.ok) return common;
310 const commonDir = common.value === null ? gitDir : resolve(gitDir, common.value.trim());
311 const refused = await unsupported(commonDir, limits);
312 if (!refused.ok) return refused;
313 if (refused.value !== null) return fail('bad_request', `${dir}: ${refused.value.why}`, { what: refused.value.what });
314 const refs = await readRefs(commonDir, limits);
315 if (!refs.ok) return refs;
316 const headFile = await maybeText(join(gitDir, 'HEAD'), LINE_FILE_MAX, 'local HEAD');
317 if (!headFile.ok) return headFile;
318 const headText = getOrElse<string>(mapOrNone(headFile.value), '').trim();
319 const headRef = headText.startsWith(`${SYMREF}refs/heads/`) ? headText.slice(SYMREF.length).trim() : null;
320 const head = OID.test(headText) ? headText : getOrElse<string | null>(mapGet(refs.value, getOrElse<string>(mapOrNone(headRef), '')), null);
321 return ok({ dir, gitDir, commonDir, refs: refs.value, headRef, head });
322}
324// ---- the object store: every pack resolved in memory, loose objects read as asked ----
325type Obj = { readonly type: number; readonly data: Uint8Array };
326type Store = {
327 readonly get: (oid: string) => Promise<Result<Obj | null, PlyError>>;
328 readonly stats: { packs: number; packed: number; loose: number; resident: number };
329};
330const TYPE_IDS: Readonly<Record<string, number>> = TYPE_ID;
332async function openStore(repo: Repo, limits: CheckedLimits): Promise<Result<Store, PlyError>> {
333 const { maxInflatedTotal: maxTotal, maxPackObjects: maxObjects, maxObjectSize: maxObject } = limits;
334 const objectsDir = join(repo.commonDir, 'objects');
335 const held = new Map<string, Obj>();
336 const stats = { packs: 0, packed: 0, loose: 0, resident: 0 };
337 // resident: the bytes held; charged: those plus LIMIT_OBJECT_OVERHEAD per object, what maxInflatedTotal bounds (#142)
338 let charged = 0;
339 const hold = (oid: string, o: Obj): Result<null, PlyError> => {
340 if (held.has(oid)) return ok(null);
341 held.set(oid, o);
342 stats.resident += o.data.length;
343 charged += o.data.length + LIMIT_OBJECT_OVERHEAD;
344 if (charged > maxTotal) return err(limitExceeded('local objects bytes', charged, maxTotal));
345 if (held.size > maxObjects) return err(limitExceeded('local objects', held.size, maxObjects));
346 return ok(null);
347 };
348 const packDir = join(objectsDir, 'pack');
349 const packs = (await readdir(packDir).then(n => n, () => [])).filter(n => n.endsWith('.pack')).toSorted();
350 for (const name of packs) {
351 const read = await readBounded(join(packDir, name), limits.maxPackBytes, 'local pack');
352 if (!read.ok) return read;
353 const buf = read.value;
354 // the room the packs and objects held so far leave: a pack that would pass the bound fails while it is parsed
355 const room = lowered(lowered(limits, 'maxInflatedTotal', maxTotal - charged), 'maxPackObjects', maxObjects - held.size);
356 const parsed = parsePack(buf, { limits: room });
357 if (!parsed.ok) return parsed;
358 const resolved = resolvePack(parsed.value, () => null, room);
359 if (!resolved.ok) return resolved;
360 stats.packs++;
361 for (const [oid, o] of resolved.value.objects) {
362 const h = hold(oid, { type: o.type, data: o.data });
363 if (!h.ok) return h;
364 stats.packed++;
365 }
366 }
367 const get = async (oid: string): Promise<Result<Obj | null, PlyError>> => {
368 const hit = mapGet(held, oid);
369 if (hit.tag === 'some') return ok(hit.value);
370 // the file is a zlib stream of the header and the object: none of an object within maxObjectSize is longer than
371 // zlibBound of both, so a longer file is refused from its size instead of being read whole and then inflated
372 const file = await maybeRead(join(objectsDir, oid.slice(0, HEX_DIR), oid.slice(HEX_DIR)), zlibBound(maxObject + HEADER_ROOM), 'local loose object');
373 if (!file.ok) return file;
374 const buf = file.value;
375 if (buf === null) return ok(null);
376 const z = inflate(buf, 0, { maxOutput: maxObject + HEADER_ROOM });
377 if (!z.ok) return z;
378 const out = z.value.out;
379 const nul = out.indexOf(0);
380 const header = /^(commit|tree|blob|tag) (\d+)$/u.exec(decodeBytes(out.subarray(0, Math.max(0, nul))));
381 const type = header === null ? null : getOrElse(readKey(TYPE_IDS, getOrElse(at(header, 1), '')), null);
382 const data = out.subarray(nul + 1);
383 if (header === null || type === null || Number(header[2]) !== data.length || hashObject(getOrElse(at(header, 1), ''), data) !== oid) return fail('pack_corrupt', `loose object ${oid}: bad header or hash`, { what: 'object', path: oid });
384 if (data.length > maxObject) return err(limitExceeded('object size', data.length, maxObject));
385 const o = { type, data };
386 const h = hold(oid, o);
387 if (!h.ok) return h;
388 stats.loose++;
389 return ok(o);
390 };
391 return ok({ get, stats });
392}
394// ---- refspecs → commands ----
395export type PushRepoConfig = {
396 // git refspecs: `src`, `src:dst`, `+src:dst`, `:dst`. null: the current branch (unless all or tags)
397 readonly refspecs: readonly string[] | null;
398 readonly all: boolean;
399 readonly tags: boolean;
400 readonly force: boolean;
401 readonly dryRun: boolean;
402 readonly thin: boolean;
403};
404export type PushRepoSpec = Input<PushRepoConfig>;
405export type PushRepoOptions = ReadOptions;
406export type RefUpdate = { readonly ref: string; readonly oldOid: string; readonly newOid: string; readonly kind: 'create' | 'update' | 'force' | 'delete' };
407export type PushRepoResult = {
408 // nothing to send: every ref named is already where the local repository has it (no receive-pack request)
409 readonly upToDate: boolean;
410 readonly dryRun: boolean;
411 readonly updates: readonly RefUpdate[];
412 // refs already at their target, left out of the push
413 readonly current: readonly string[];
414 // objects in the pack, of which deltas against an object in the pack (ofs) and against the remote's (thin)
415 readonly objects: number;
416 readonly deltas: number;
417 readonly thinDeltas: number;
418 // object bytes before deltas and zlib, and the pack sent (0 on a dry run or a delete-only push)
419 readonly rawBytes: number;
420 readonly packBytes: number;
421};
423// One wanted command: the ref, the local id (null: delete), forced or not, and the name it came from.
424type Wanted = { readonly dst: string; readonly src: string | null; readonly force: boolean; readonly from: string };
425// git's ref_rev_parse_rules, split as remote.c count_refspec_match splits a match: strong when the name was given in
426// full or from the top level (`refs/` + name), or is a branch or a tag; weak for the rest (refs/remotes/<name> and
427// refs/remotes/<name>/HEAD).
428const STRONG_RULES = ['', 'refs/', 'refs/tags/', 'refs/heads/'];
429const weakNames = (name: string): string[] => [`refs/remotes/${name}`, `refs/remotes/${name}/HEAD`];
430// Every full name the short one can mean that exists, as git counts them: the strong matches, and the weak ones only
431// when there is no strong one, so a branch `foo` beside a remote `foo` is the branch and not an ambiguity. A ref
432// directly under refs/ (refs/stash) is not counted at all (remote.c one_local_ref drops a one-level name), so a branch
433// `stash` beside it is the branch; it is the source only when nothing counted matches, which is where git reads the
434// name as an object name instead (try_explicit_object_name). At most one such ref exists for a name.
435const localMatches = (repo: Repo, name: string): string[] => {
436 const strong = STRONG_RULES.map(p => `${p}${name}`).filter(n => n.startsWith('refs/') && repo.refs.has(n));
437 const counted = strong.filter(n => n.includes('/', 5));
438 if (counted.length > 0) return counted;
439 const weak = weakNames(name).filter(n => repo.refs.has(n));
440 return weak.length > 0 ? weak : strong;
441};
443type RemoteRefs = ReadonlyMap<string, string>;
444// A destination on the remote: a full name it has, or the one branch or tag a short name means; null for none (or two).
445const dstOnRemote = (remote: RemoteRefs, name: string): string | null => {
446 if (name.startsWith('refs/')) return remote.has(name) ? name : null;
447 const found = ['refs/heads/', 'refs/tags/'].map(p => `${p}${name}`).filter(n => remote.has(n));
448 return found.length === 1 ? getOrElse(at(found, 0), null) : null;
449};
450// The local side of a refspec: HEAD, the one ref a name means, or a 40-hex id; a string says why it is none of those.
451function resolveSrc(repo: Repo, srcName: string): { readonly src: string; readonly srcRef: string | null } | string {
452 if (srcName === 'HEAD') return repo.head === null ? 'HEAD has no commit' : { src: repo.head, srcRef: repo.headRef };
453 const matches = localMatches(repo, srcName);
454 if (matches.length > 1) return `src matches more than one ref (${matches.join(', ')})`;
455 const one = at(matches, 0);
456 if (one.tag === 'some') return { src: getOrElse(mapGet(repo.refs, one.value), ''), srcRef: one.value };
457 return OID.test(srcName) ? { src: srcName, srcRef: null } : `src ${srcName} does not match any local ref`;
458}
460// `:dst`: the remote ref to delete, which must exist (git: "remote ref does not exist").
461function deletion(remote: RemoteRefs, spec: string, name: string, force: boolean): Result<Wanted, PlyError> {
462 const dst = dstOnRemote(remote, name);
463 if (dst === null) return fail('not_found', `refspec ${spec}: the remote has no ref ${name} to delete`, { miss: { kind: 'ref', ref: name, candidates: [] } });
464 return ok({ dst, src: null, force, from: spec });
465}
467// One refspec as git's match_explicit_refs reads it (the src side in the local repository, the dst side on the remote).
468function resolveRefspec(repo: Repo, remote: RemoteRefs, spec: string, forceAll: boolean): Result<Wanted, PlyError> {
469 const forced = spec.startsWith('+');
470 const body = forced ? spec.slice(1) : spec;
471 const colon = body.indexOf(':');
472 const srcName = colon < 0 ? body : body.slice(0, colon);
473 const dstName = colon < 0 ? null : body.slice(colon + 1);
474 const bad = (why: string): Result<never, PlyError> => fail('bad_request', `refspec ${spec}: ${why}`, { what: 'refspec', got: spec });
475 if (body === '' || body.includes(':', colon + 1) || dstName === '' || /\s/u.test(body)) return bad('not src, src:dst, +src:dst or :dst');
476 const force = forced || forceAll;
477 if (srcName === '') return deletion(remote, spec, getOrElse<string>(mapOrNone(dstName), ''), force);
478 const source = resolveSrc(repo, srcName);
479 if (typeof source === 'string') return bad(source);
480 const { src, srcRef } = source;
481 if (dstName === null) {
482 if (srcRef === null) return bad('a commit id or a detached HEAD needs a destination (src:refs/heads/…)');
483 return ok({ dst: srcRef, src, force, from: spec });
484 }
485 if (dstName.startsWith('refs/')) return ok({ dst: dstName, src, force, from: spec });
486 const onRemote = dstOnRemote(remote, dstName);
487 if (onRemote !== null) return ok({ dst: onRemote, src, force, from: spec });
488 // a new short name takes the kind of its source, as git's "the destination you provided is not a full refname" allows
489 const kind = srcRef !== null && srcRef.startsWith('refs/tags/') ? 'refs/tags/' : 'refs/heads/';
490 if (srcRef === null || !(srcRef.startsWith('refs/heads/') || srcRef.startsWith('refs/tags/'))) return bad(`destination ${dstName} is not a full refname and names no remote ref`);
491 return ok({ dst: `${kind}${dstName}`, src, force, from: spec });
492}
494// The commands the spec asks for, before any of them is compared with the remote.
495function wantedRefs(repo: Repo, remote: RemoteRefs, cfg: PushRepoConfig): Result<Wanted[], PlyError> {
496 const specs: string[] = [...(cfg.refspecs === null ? [] : cfg.refspecs)];
497 for (const [name] of repo.refs) if ((cfg.all && name.startsWith('refs/heads/')) || (cfg.tags && name.startsWith('refs/tags/'))) specs.push(name);
498 if (cfg.refspecs === null && !cfg.all && !cfg.tags) {
499 if (repo.headRef === null || repo.head === null) return fail('bad_request', `${repo.dir}: HEAD is not a branch with a commit; name what to push (refspecs, all or tags)`, { what: 'refspecs' });
500 specs.push(repo.headRef);
501 }
502 const out = new Map<string, Wanted>();
503 for (const s of specs) {
504 const w = resolveRefspec(repo, remote, s, cfg.force);
505 if (!w.ok) return w;
506 const prev = mapGet(out, w.value.dst);
507 if (prev.tag === 'some' && prev.value.src !== w.value.src) return fail('bad_request', `${w.value.dst} is the destination of two refspecs (${prev.value.from}, ${w.value.from})`, { what: 'refspec', got: w.value.from });
508 out.set(w.value.dst, { ...w.value, force: w.value.force || (prev.tag === 'some' && prev.value.force) });
509 }
510 return ok([...out.values()]);
511}
513// ---- the walks ----
514type Walk = PackWalk;
516// Is `old` an ancestor of (or equal to) `tip`? Both peeled to commits; false when either is not one the local
517// repository has.
518async function descends(w: Walk, tip: string, old: string): Promise<Result<boolean, PlyError>> {
519 const peel = async (oid: string): Promise<Result<string | null, PlyError>> => {
520 let at0 = oid;
521 for (let i = 0; i <= MAX_SYMREF_DEPTH; i++) {
522 const got = await w.store.get(at0);
523 if (!got.ok) return got;
524 if (got.value === null) return ok(null);
525 if (got.value.type === TYPE.COMMIT) return ok(at0);
526 if (got.value.type !== TYPE.TAG) return ok(null);
527 const t = parseTag(got.value.data);
528 if (!t.ok) return t;
529 at0 = t.value.object;
530 }
531 return ok(null);
532 };
533 const from = await peel(tip);
534 if (!from.ok) return from;
535 const target = await peel(old);
536 if (!target.ok) return target;
537 if (from.value === null || target.value === null) return ok(false);
538 const seen = new Set<string>();
539 const stack = [from.value];
540 for (let next = popped(stack); next.tag === 'some'; next = popped(stack)) {
541 const oid = next.value;
542 if (oid === target.value) return ok(true);
543 if (seen.has(oid)) continue;
544 seen.add(oid);
545 const got = await w.store.get(oid);
546 if (!got.ok) return got;
547 if (got.value === null) continue;
548 const c = parseCommit(got.value.data, w.limits);
549 if (!c.ok) return c;
550 stack.push(...c.value.parents);
551 }
552 return ok(false);
553}
555// The remote's object at each path of its tips' trees, for thin deltas: `${type} ${path}` → id. The first tip (in ref
556// name order) that has a path wins.
557async function remotePaths(w: Walk, tips: readonly string[]): Promise<Result<Map<string, string>, PlyError>> {
558 const out = new Map<string, string>();
559 const trees = new Set<string>();
560 const visit = async (oid: string, path: string): Promise<Result<null, PlyError>> => {
561 if (trees.has(oid)) return ok(null);
562 trees.add(oid);
563 const got = await w.store.get(oid);
564 if (!got.ok) return got;
565 if (got.value === null || got.value.type !== TYPE.TREE) return ok(null);
566 const kids = children(got.value, w.limits);
567 if (!kids.ok) return kids;
568 for (const k of kids.value) {
569 const p = path === '' ? k.name : `${path}/${k.name}`;
570 const key = `${k.type} ${p}`;
571 if (!out.has(key)) out.set(key, k.oid);
572 if (k.type === TYPE.TREE) { const r = await visit(k.oid, p); if (!r.ok) return r; }
573 }
574 return ok(null);
575 };
576 for (const tip of tips) {
577 const got = await w.store.get(tip);
578 if (!got.ok) return got;
579 if (got.value === null || got.value.type !== TYPE.COMMIT) continue;
580 const c = parseCommit(got.value.data, w.limits);
581 if (!c.ok) return c;
582 if (!out.has(`${TYPE.TREE} `)) out.set(`${TYPE.TREE} `, c.value.tree);
583 const r = await visit(c.value.tree, '');
584 if (!r.ok) return r;
585 }
586 return ok(out);
587}
589// ---- the entry ----
590// The store of a delete-only push: it has no object (and no change asks it for one).
591// oxlint-disable-next-line typescript/promise-function-async -- a settled answer, no work to await
592const NO_OBJECTS: Store = { get: () => Promise.resolve(ok(null)), stats: { packs: 0, packed: 0, loose: 0, resident: 0 } };
593// git's words for a refused update: a tag that exists, a tip this repository does not have, or a non-fast-forward.
594const refusal = (ref: string, haveOld: boolean): string => {
595 if (ref.startsWith('refs/tags/')) return 'already exists';
596 return haveOld ? 'non-fast-forward' : 'fetch first';
597};
598// Each change against the remote's tip: a create, a delete, a fast-forward, a forced update, or refused (every refused
599// ref is named in one not_fast_forward, and nothing is sent).
600async function decideUpdates(w: Walk, changes: readonly Wanted[], remote: RemoteRefs): Promise<Result<RefUpdate[], PlyError>> {
601 const updates: RefUpdate[] = [];
602 const refused: string[] = [];
603 for (const c of changes) {
604 const old = getOrElse<string | null>(mapGet(remote, c.dst), null);
605 if (c.src === null) { updates.push({ ref: c.dst, oldOid: getOrElse<string>(mapOrNone(old), ZERO_OID), newOid: ZERO_OID, kind: 'delete' }); continue; }
606 if (old === null) { updates.push({ ref: c.dst, oldOid: ZERO_OID, newOid: c.src, kind: 'create' }); continue; }
607 const ff = c.dst.startsWith('refs/tags/') ? ok(false) : await descends(w, c.src, old);
608 if (!ff.ok) return ff;
609 if (ff.value || c.force) { updates.push({ ref: c.dst, oldOid: old, newOid: c.src, kind: ff.value ? 'update' : 'force' }); continue; }
610 const had = await w.store.get(old);
611 if (!had.ok) return had;
612 refused.push(`${c.dst} (${refusal(c.dst, had.value !== null)})`);
613 }
614 if (refused.length > 0) return fail('not_fast_forward', `push refused before sending: ${refused.join(', ')}; pull or use + / force`, { what: 'ref', got: refused });
615 return ok(updates);
616}
618// The thin bases: for each path's first object in the pack, the remote's object at that path (its tips' trees).
619async function thinBases(w: Walk, remote: RemoteRefs, objects: readonly DeltaCandidate[]): Promise<Result<Map<string, ThinBase>, PlyError>> {
620 const thin = new Map<string, ThinBase>();
621 const paths = await remotePaths(w, [...remote.entries()].toSorted(([a], [b]) => (a < b ? -1 : 1)).map(([, v]) => v));
622 if (!paths.ok) return paths;
623 for (const o of objects) {
624 if (o.path === null) continue;
625 const key = `${o.type} ${o.path}`;
626 const base = mapGet(paths.value, key);
627 if (base.tag === 'none' || thin.has(key)) continue;
628 const got = await w.store.get(base.value);
629 if (!got.ok) return got;
630 if (got.value !== null) thin.set(key, { oid: base.value, data: got.value.data });
631 }
632 return ok(thin);
633}
635// What to send: the objects the remote lacks, delta-planned. Every one was read through the store, so maxPackObjects
636// and maxInflatedTotal already bound them.
637type PlanInput = { readonly thin: boolean; readonly remote: RemoteRefs; readonly updates: readonly RefUpdate[] };
638async function planPack(w: Walk, span: Span, { thin, remote, updates }: PlanInput): Promise<Result<DeltaPlan, PlyError>> {
639 const tips = updates.filter(u => u.kind !== 'delete').map(u => u.newOid);
640 // deletes only: no pack, and nothing to walk
641 const have = tips.length === 0 ? ok(new Set<string>()) : await reachable(w, [...new Set(remote.values())]);
642 if (!have.ok) return have;
643 const objects = await missing(w, tips, have.value);
644 if (!objects.ok) return objects;
645 const bases = thin ? await thinBases(w, remote, objects.value) : ok(new Map<string, ThinBase>());
646 if (!bases.ok) return bases;
647 const plan = planDeltas(objects.value, { thinBase: thin ? (type, path) => getOrElse(mapGet(bases.value, `${type} ${path}`), null) : null });
648 span.set({ 'git.push_repo.plan.have': have.value.size, 'git.push_repo.plan.objects': plan.objects.length, 'git.push_repo.plan.ofs': plan.ofs, 'git.push_repo.plan.ref': plan.ref, 'git.push_repo.plan.raw.bytes': plan.rawBytes, 'git.push_repo.plan.delta.bytes': plan.plannedBytes });
649 return ok(plan);
650}
652const pushRepoDefaults = (): PushRepoConfig => ({ refspecs: null, all: false, tags: false, force: false, dryRun: false, thin: false });
653const isBool = (v: unknown): boolean => typeof v === 'boolean';
655// A child span of the operation's root, ended with the body's Result.
656async function step<T>(root: Span, name: string, body: (span: Span) => Promise<Result<T, PlyError>>): Promise<Result<T, PlyError>> {
657 const span = root.tracer.start(name, { parent: root });
658 const r = await body(span);
659 if (!r.ok) span.error(r.error, r.error.code);
660 span.end();
661 return r;
662}
664export async function pushRepo(dir: string, url: string, spec: PushRepoSpec = {}, options: PushRepoOptions = {}): Promise<Result<PushRepoResult, PlyError>> {
665 if (!isArgObject(spec)) return fail('bad_request', 'pushRepo: spec must be an object', { what: 'spec' });
666 if (!isArgObject(options)) return fail('bad_request', 'pushRepo: options must be an object', { what: 'options' });
667 const cfg = withDefaults<PushRepoConfig>(spec, pushRepoDefaults());
668 const { refspecs } = cfg;
669 if ((refspecs !== null && !(Array.isArray(refspecs) && refspecs.every(s => typeof s === 'string'))) || ![cfg.all, cfg.tags, cfg.force, cfg.dryRun, cfg.thin].every(v => isBool(v)) || (cfg.all && refspecs !== null)) {
670 return fail('bad_request', 'pushRepo: refspecs is a list of strings, all/tags/force/dryRun/thin are booleans, and all takes no refspecs', { what: 'spec' });
671 }
672 const checked = limitsOf(options);
673 if (!checked.ok) return checked;
674 const limits = checked.value;
675 const repo = await openRepo(dir, limits);
676 if (!repo.ok) return repo;
677 const r = repo.value;
678 const opOpts: OperationOpts = { ...options, limits, attrs: { 'git.push_repo.dir': r.dir, 'git.push_repo.dry_run': cfg.dryRun, 'git.push_repo.thin': cfg.thin, 'git.push_repo.local_refs': r.refs.size } };
679 return operation('push_repo', url, opOpts, async ({ t, root, outcome }) => {
680 const listed = await lsRefs(t, []);
681 if (!listed.ok) return listed;
682 const remote = new Map<string, string>();
683 for (const [name, ref] of listed.value.refs) if (name.startsWith('refs/')) remote.set(name, ref.oid);
684 const wanted = wantedRefs(r, remote, cfg);
685 if (!wanted.ok) return wanted;
686 const current: string[] = [];
687 const changes: Wanted[] = [];
688 for (const want of wanted.value) {
689 const named = validatePushRef(want.dst, want.src === null);
690 if (!named.ok) return named;
691 if (want.src !== null && getOrElse<string | null>(mapGet(remote, want.dst), null) === want.src) current.push(want.dst);
692 else changes.push(want);
693 }
694 root.set({ 'git.push_repo.remote_refs': remote.size, 'git.push_repo.refs.current': current.length, 'git.push_repo.refs.changed': changes.length });
695 const done = (upToDate: boolean, updates: readonly RefUpdate[], counts: { readonly objects: number; readonly deltas: number; readonly thinDeltas: number; readonly rawBytes: number; readonly packBytes: number }, kind: string): Result<PushRepoResult, PlyError> =>
696 outcome(kind, { upToDate, dryRun: cfg.dryRun, updates, current, ...counts }, { 'git.push_repo.objects': counts.objects, 'git.push_repo.deltas': counts.deltas + counts.thinDeltas, 'git.push_repo.pack.bytes': counts.packBytes });
697 const none = { objects: 0, deltas: 0, thinDeltas: 0, rawBytes: 0, packBytes: 0 };
698 if (changes.length === 0) return done(true, [], none, 'up_to_date');
699 // a delete-only push reads no objects
700 const store = changes.every(c => c.src === null) ? ok(NO_OBJECTS) : await step(root, 'git.push_repo.read', async span => {
701 const s = await openStore(r, limits);
702 if (s.ok) span.set({ 'git.push_repo.read.packs': s.value.stats.packs, 'git.push_repo.read.objects': s.value.stats.packed, 'git.push_repo.read.bytes': s.value.stats.resident });
703 return s;
704 });
705 if (!store.ok) return store;
706 const w: Walk = { store: store.value, limits, source: 'the local repository' };
707 const updates = await decideUpdates(w, changes, remote);
708 if (!updates.ok) return updates;
709 const planned = await step(root, 'git.push_repo.plan', async span => { const p = await planPack(w, span, { thin: cfg.thin, remote, updates: updates.value }); return p; });
710 if (!planned.ok) return planned;
711 const plan = planned.value;
712 const counts = { objects: plan.objects.length, deltas: plan.ofs, thinDeltas: plan.ref, rawBytes: plan.rawBytes, packBytes: 0 };
713 if (cfg.dryRun) return done(false, updates.value, counts, 'dry_run');
714 const cmds = updates.value.map((u): Command => ({ ref: u.ref, oldOid: u.oldOid, newOid: u.newOid }));
715 const first = at(cmds, 0);
716 if (first.tag === 'none') return done(true, [], none, 'up_to_date');
717 const commands: Commands = [first.value, ...cmds.slice(1)];
718 const pushed = await push(t, { commands, objects: plan.objects });
719 if (!pushed.ok) return pushed;
720 return done(false, updates.value, { ...counts, packBytes: pushed.value.packBytes }, 'pushed');
721 });
722}
Diagnostics4 git calls · 333 ms
CallStatusSizeTime0333 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 · 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=38434 git.response.cache=HIT git.response.duration_ms=2 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
fetch20014 KiB328 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=328 git.response.bytes=14158 git.response.cache=MISS git.response.duration_ms=328 git.fetch.wants=98bf6b9a96fd68f0e472345ef0edf7b79b0bfb78 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=14158 git.pkt.payload.max=14137 git.sideband.band1.bytes=14136 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
- a5e28e755f9c24d3
- Request
- 5e349ab0…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format