main
1// One public page: discover, then either a pack map or a ref → commit → tree walk → optional blob.
2// Quirks are the isolate's per-origin map (src/quirks.ts), shared with /v1: a server that refuses tree:0 costs that 400
3// once per isolate, not once per page. The trace still names the fallback on every fetch that uses it.
4import { chainGet, fromNullable, mapGet } from '../absent.ts';
5import { unwrapOr } from '../option.ts';
6import { commitView, concat, createTransport, discover, entryType, fetchObject, fetchPack, fetchPackFiltered, hashObject, inflate, isFilterRejection, limitError, lsMode, lsRefs, packStream, parseTree, plyError, refCandidates, spFinish, spInit, spStep, TYPE, walkCommit, walkPath } from 'ply';
7import type { Walked } from 'ply/read';
8import { pathTreesOf, tree0Taken } from 'ply/transport';
9import type { SpState, Tracer, Transport } from 'ply';
10import type { SpStepped } from 'ply/fetch';
11import { unwrap, type OkOf } from '../ply-result.ts';
12import type { Budget } from './budget.ts';
13import { clampText, safeFilename } from './escape.ts';
14import { viewerAllowUrl, type FetchLike } from './fetchguard.ts';
15import { VIEWER_CAPS, VIEWER_GIT_LIMITS, VIEWER_UA } from './limits.ts';
16import { mapParsed } from './packmap.ts';
17import type { CommitInfo, FilterName, Loaded, RepoHeader, ServerInfo, TreeEntry } from './model.ts';
18import type { ViewerRoute } from './route.ts';
19import type { AllowedHost, RepoLocation, ValidatedPublicRepoUrl } from './url.ts';
20import { viewerHref } from './url.ts';
22import { quirksFor, type Quirks } from '../quirks.ts';
23import { isAbbreviatedOid, matchAbbreviatedOid } from '../abbrev.ts';
24import { nearbyRefs, type ViewerHint } from './hint.ts';
25import { tagsFromRefs } from './tags.ts';
27export type SessionDeps = {
28 tracer: Tracer;
29 fetchImpl: FetchLike;
30 signal: AbortSignal;
31 budget: Budget;
32};
34type RefRec = { oid: string };
35type DiscoverInfo = OkOf<ReturnType<typeof discover>>;
37function openTransport(url: ValidatedPublicRepoUrl, allowed: readonly AllowedHost[], opts: {
38 tracer: Tracer;
39 fetchImpl: FetchLike;
40 signal: AbortSignal;
41 quirks: Quirks;
42}): Transport {
43 const parsed = new URL(url);
44 if (parsed.username || parsed.password) throw plyError('bad_request', 'remote must not carry credentials');
45 // git's http.followRedirects=initial: a moved repo (name → name.git) answers its first GET info/refs with a 3xx that ply
46 // follows, after viewerAllowUrl has checked it is still this repo; a 3xx on a POST is an error naming the target.
47 return unwrap(createTransport(url, { ...opts, userAgent: VIEWER_UA, limits: VIEWER_GIT_LIMITS, followRedirects: 'initial', allowUrl: viewerAllowUrl(url, allowed), maxRedirects: VIEWER_CAPS.maxRedirects }));
48}
50function serverOf(info: DiscoverInfo): ServerInfo {
51 return {
52 agent: info.agent,
53 protocol: info.version,
54 objectFormat: info.objectFormat,
55 caps: [...info.caps.keys()],
56 fetchFeatures: [...info.fetch],
57 filterAdvertised: info.filter,
58 };
59}
61function textOrEmpty(value: unknown): string {
62 const present = fromNullable(value);
63 if (present.tag === 'none') return '';
64 return typeof present.value === 'string' ? present.value : String(present.value);
65}
67function toCommit(oid: string, data: Uint8Array): CommitInfo {
68 const view = unwrap(commitView(data, VIEWER_GIT_LIMITS));
69 const author = fromNullable(view.author);
70 const who = author.tag === 'some' ? author.value : { name: '', email: '', time: '', tz: '' };
71 const parents = fromNullable(view.parents);
72 return {
73 oid,
74 tree: textOrEmpty(view.tree),
75 parents: parents.tag === 'none' ? [] : [...parents.value],
76 authorName: textOrEmpty(who.name),
77 authorEmail: textOrEmpty(who.email),
78 authorTime: textOrEmpty(who.time),
79 authorTz: textOrEmpty(who.tz),
80 message: textOrEmpty(view.message),
81 signed: !!view.signed,
82 };
83}
85function headerFor(loc: RepoLocation, ref: string, commit: string, server: ServerInfo): RepoHeader {
86 return { host: loc.host, repoPath: loc.repoPath, ref, commit, treeHref: viewerHref(loc.host, loc.repoPath, { ref }), server };
87}
89/** A viewer failure carrying the error page's hint (src/viewer/hint.ts reads it back); ply's Extra has no such field. */
90function withHint<E extends object>(err: E, viewerHint: ViewerHint): E & { viewerHint: ViewerHint } {
91 return Object.assign(err, { viewerHint });
92}
94function refPrefixes(ref: string | null, allTags = true): string[] {
95 const prefixes = new Set<string>(allTags ? ['HEAD', 'refs/heads/', 'refs/tags/'] : ['HEAD', 'refs/heads/']);
96 for (const cand of unwrap(refCandidates(ref))) {
97 if (cand === 'HEAD') continue;
98 prefixes.add(cand);
99 }
100 return [...prefixes];
101}
103function refMiss(listedRefs: { refs: Map<string, RefRec>; head: string | null }, wanted: string, code: 'not_found' | 'bad_request', message: string): never {
104 const catalog = refCatalog(listedRefs);
105 throw withHint(plyError(code, message), { nearby: nearbyRefs(wanted, catalog.branches, catalog.tags), path: null });
106}
108function textRef(ref: string | null): string {
109 return ref === null ? '' : ref;
110}
112function peeledOid(rec: RefRec): string {
113 const peeled = chainGet(rec, 'peeled');
114 if (peeled.tag === 'none') return rec.oid;
115 return typeof peeled.value === 'string' ? peeled.value : rec.oid;
116}
118function resolveRef(listedRefs: { refs: Map<string, RefRec>; head: string | null }, ref: string | null): { name: string; commit: string } {
119 const refs = listedRefs.refs;
120 const cands = unwrap(refCandidates(ref));
121 if (!cands.length) return { name: textRef(ref), commit: textRef(ref) };
122 for (const cand of cands) {
123 const rec = refs.get(cand);
124 if (!rec) continue;
125 const head = listedRefs.head === null ? 'HEAD' : listedRefs.head;
126 return { name: cand === 'HEAD' ? head : cand, commit: peeledOid(rec) };
127 }
128 if (ref && isAbbreviatedOid(ref)) {
129 const match = matchAbbreviatedOid(ref, refs);
130 if (match.kind === 'unique') return { name: match.oid, commit: match.oid };
131 refMiss(listedRefs, ref, 'bad_request', match.message);
132 }
133 const message = cands[0] === 'HEAD' ? 'remote HEAD is unborn or absent; pass ref explicitly' : `ref ${ref} not found`;
134 refMiss(listedRefs, textRef(ref), 'not_found', message);
135}
137function refCatalog(listedRefs: { refs: Map<string, RefRec>; head: string | null }) {
138 const heads = [];
139 for (const [name, rec] of listedRefs.refs) {
140 if (!name.startsWith('refs/heads/')) continue;
141 heads.push({ name, oid: rec.oid, head: name === listedRefs.head });
142 }
143 heads.sort((a, b) => Number(b.head) - Number(a.head) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
144 const branches = heads.slice(0, VIEWER_CAPS.maxBranchesShown);
145 const tagView = tagsFromRefs(listedRefs.refs, VIEWER_CAPS.maxTagsShown);
146 return { branches, branchesTruncated: heads.length - branches.length, tags: tagView.tags, tagsTruncated: tagView.truncated };
147}
149async function loadTreeBytes(transport: Transport, oid: string, cache: Map<string, Uint8Array>): Promise<Uint8Array> {
150 const hit = cache.get(oid);
151 if (hit) return hit;
152 const obj = unwrap(await fetchObject(transport, { oid, filter: 'tree:0', expectType: TYPE.TREE }));
153 cache.set(oid, obj.data);
154 return obj.data;
155}
157// ply's walk answer, or its not_found carrying the viewer's path hint (the page names the missing component and the
158// directory it was looked for in).
159function walkResult<T>(r: { readonly ok: true; readonly value: T } | { readonly ok: false; readonly error: unknown }): T {
160 if (r.ok) return r.value;
161 const e = r.error;
162 const miss = chainGet(e, 'miss');
163 const kind = textOrEmpty(unwrapOr(chainGet(miss.tag === 'some' ? miss.value : null, 'kind'), ''));
164 const field = (key: string) => textOrEmpty(unwrapOr(chainGet(miss.tag === 'some' ? miss.value : null, key), ''));
165 if (kind === 'path') throw withHint(e as object, { nearby: [], path: { missing: field('missing'), existingPath: field('existingPath'), notDirectory: false } });
166 if (kind === 'not_directory') {
167 const parts = field('path').split('/');
168 const missing = unwrapOr(fromNullable(parts.pop()), '');
169 throw withHint(e as object, { nearby: [], path: { missing, existingPath: parts.join('/'), notDirectory: true } });
170 }
171 throw e;
172}
174function listed(entries: { name: string; mode: string; oid: string }[]): { shown: TreeEntry[]; truncated: number } {
175 if (entries.length > VIEWER_GIT_LIMITS.maxTreeEntries) throw limitError('tree entries', entries.length, VIEWER_GIT_LIMITS.maxTreeEntries);
176 const mapped: TreeEntry[] = entries.map(entry => ({ name: entry.name, mode: lsMode(entry.mode), oid: entry.oid, type: entryType(entry.mode) }));
177 mapped.sort((a, b) => (a.type === 'tree' ? 0 : 1) - (b.type === 'tree' ? 0 : 1) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
178 return { shown: mapped.slice(0, VIEWER_CAPS.maxTreeShown), truncated: Math.max(0, mapped.length - VIEWER_CAPS.maxTreeShown) };
179}
181// zlib can be a little larger than the inflated file cap. Same slack ply uses before inflate.
182const COMPRESSED_SLACK_BYTES = 64 * 1024;
184async function closeIterator(it: AsyncIterator<Uint8Array>): Promise<void> {
185 await (it.return as (this: AsyncIterator<Uint8Array>) => Promise<unknown>).call(it).catch(() => {});
186}
188function refuseOversizedChunk(cursor: SpState, chunk: Uint8Array): void {
189 const next = cursor.bytes + chunk.byteLength;
190 if (next > VIEWER_CAPS.maxPackBytes) throw limitError('pack bytes', next, VIEWER_CAPS.maxPackBytes);
191}
193async function readBlob(transport: Transport, tracer: Tracer, oid: string): Promise<{ size: number; bytes: Uint8Array | null; tooBig: boolean }> {
194 const span = tracer.start('git.viewer.blob', { attrs: { 'git.read.blob.oid': oid } });
195 const fetchSpan = tracer.start('git.upload-pack fetch', { parent: span, kind: 3 });
196 const it = packStream(transport, { wants: [oid], ofsDelta: true, thinPack: false }, fetchSpan)[Symbol.asyncIterator]();
197 let sp: SpState = spInit();
198 const early: Uint8Array[] = [];
199 try {
200 while (sp.phase !== 'body') {
201 const step = await it.next();
202 if (step.done) throw plyError('pack_corrupt', 'pack ended before the object header');
203 refuseOversizedChunk(sp, step.value);
204 const r: SpStepped = unwrap(spStep(sp, step.value));
205 sp = r.state;
206 early.push(...r.zlib);
207 }
208 if (sp.type !== TYPE.BLOB) throw plyError('pack_corrupt', `expected blob, got type ${sp.type}`);
209 if (sp.size > VIEWER_CAPS.maxFileDisplayBytes) {
210 span.set({ 'git.viewer.blob.too_big': true, 'git.viewer.blob.size': sp.size });
211 await closeIterator(it);
212 fetchSpan.set({ 'git.viewer.blob.too_big': true, 'git.viewer.blob.size': sp.size });
213 fetchSpan.end();
214 span.end();
215 return { size: sp.size, bytes: null, tooBig: true };
216 }
217 const zlibParts = early;
218 let zlibLen = early.reduce((n, c) => n + c.byteLength, 0);
219 for (;;) {
220 const step = await it.next();
221 if (step.done) break;
222 refuseOversizedChunk(sp, step.value);
223 const r: SpStepped = unwrap(spStep(sp, step.value));
224 sp = r.state;
225 for (const z of r.zlib) { zlibParts.push(z); zlibLen += z.byteLength; }
226 if (zlibLen > VIEWER_CAPS.maxFileDisplayBytes + COMPRESSED_SLACK_BYTES) throw limitError('compressed object bytes', zlibLen, VIEWER_CAPS.maxFileDisplayBytes);
227 }
228 sp = unwrap(spFinish(sp));
229 const { out } = unwrap(inflate(concat(zlibParts), 0, { expectedSize: sp.size, maxOutput: VIEWER_CAPS.maxFileDisplayBytes }));
230 const got = hashObject('blob', out);
231 if (got !== oid) throw plyError('pack_corrupt', `blob content hashes to ${got}, not ${oid}`);
232 fetchSpan.end();
233 span.set({ 'git.viewer.blob.size': sp.size });
234 span.end();
235 return { size: sp.size, bytes: out, tooBig: false };
236 } catch (err) {
237 await closeIterator(it);
238 fetchSpan.error(err).end();
239 span.error(err).end();
240 throw err;
241 }
242}
244function asText(bytes: Uint8Array): string | null {
245 for (let i = 0; i < bytes.length; i++) if (bytes[i] === 0) return null;
246 try { return new TextDecoder('utf-8', { fatal: true }).decode(bytes); }
247 catch { return null; }
248}
250type Held = { type: number; data: Uint8Array };
252/**
253 * The page's commit, its first-parent history and (on a blob:none server) every tree, in ONE fetch:
254 * `want <head> deepen N` with `filter tree:0`, or `blob:none` where the server refuses tree:0 (Cloudflare Artifacts).
255 * Measured 2026-10-30 against the same graphs on GitHub: curl tree:0 deepen 10 is 6.1 KB (10 commits);
256 * blob:none deepen 1 is 121.6 KB (1 commit + 48 trees) and deepen 10 is 129.0 KB (+6%, 10 commits + 77 trees).
257 * So the history costs one round trip and a few KB instead of one blob:none fetch per commit. The old walk stopped
258 * after the first commit on any server that refuses tree:0, which is every Artifacts page.
259 * Returns null when the window does not fit the caps; the caller then reads the commit alone.
260 */
261async function loadWindow(transport: Transport, head: string): Promise<Map<string, Held> | null> {
262 // ply picks the filter from what it learned about the server (fetchPackFiltered): tree:0, blob:none after a refusal
263 // (Artifacts), or none where the advertisement lists no `filter` (git.sr.ht, stock git; ply-web#121).
264 const result = await fetchPackFiltered(transport, { wants: [head], filter: 'tree:0', deepen: VIEWER_CAPS.maxLogCommits });
265 if (!result.ok) {
266 const error = result.error;
267 // Too big for the window (a huge tree under blob:none): fall back to the single-commit read. Timeouts and aborts end the page.
268 if (error.code === 'limit_exceeded' && !/upstream/.test(error.message)) return null;
269 throw error;
270 }
271 return result.value.objects;
272}
274function historyOf(first: CommitInfo, held: Map<string, Held> | null): { log: CommitInfo[]; logStopped: boolean } {
275 const log = [first];
276 if (!held) return { log, logStopped: first.parents.length > 0 };
277 let parent = first.parents[0];
278 while (parent && log.length < VIEWER_CAPS.maxLogCommits) {
279 const obj = held.get(parent);
280 if (!obj || obj.type !== TYPE.COMMIT) return { log, logStopped: true };
281 const commit = toCommit(parent, obj.data);
282 log.push(commit);
283 parent = commit.parents[0];
284 }
285 return { log, logStopped: false };
286}
288/**
289 * Branches and every tag (for the picker). A repository whose tags alone pass maxRefs (or the ls-refs byte cap) still
290 * opens: one more ls-refs lists branches and the asked-for name only, and the picker shows no tags.
291 */
292export async function listPageRefs(transport: Transport, ref: string | null): Promise<{ refs: Map<string, RefRec>; head: string | null }> {
293 const listed = await lsRefs(transport, refPrefixes(ref));
294 if (listed.ok) return listed.value;
295 const error = listed.error;
296 if (error.code !== 'limit_exceeded' || !/^ls-refs /.test(error.what)) throw error;
297 return unwrap(await lsRefs(transport, refPrefixes(ref, false)));
298}
300async function loadTree(transport: Transport, route: Extract<ViewerRoute, { kind: 'repo' }>, advertised: Promise<ServerInfo>, quirks: Quirks, budget: Budget, tracer: Tracer): Promise<Loaded> {
301 // A full object id names the commit without the ref listing (resolveRef never reads it then), so the listing, which
302 // only fills the branch and tag picker, runs beside the window fetch instead of before it, and a raw read skips it.
303 // An ls-refs miss is 140-490 ms on /r pages (59f39490).
304 const direct = unwrap(refCandidates(route.ref)).length === 0 && route.ref !== null;
305 let listing: Promise<{ refs: Map<string, RefRec>; head: string | null }> | null = null;
306 const refsNow = () => {
307 if (listing === null) listing = listPageRefs(transport, route.ref);
308 return listing;
309 };
310 // ls-refs does not wait for discover (ply-web#120; ply#220 makes the two share one advertisement GET): nothing before
311 // the header needs the advertisement. The window and the walk still wait for it, because discover is what tells ply's
312 // transport a server takes no `filter` at all.
313 if (!(direct && route.raw)) refsNow().catch(() => {});
314 const server = await advertised;
315 const resolved: { name: string; commit: string } = direct
316 ? { name: route.ref as string, commit: route.ref as string }
317 : resolveRef(await refsNow(), route.ref);
318 const comps = route.path ? route.path.split('/') : [];
319 const cache = new Map<string, Uint8Array>();
320 // Raw bytes need no history: no window, and the walk is ply's walkCommit. Every other page reads the window (history,
321 // and on a blob:none or unfiltered host every tree too). On a host ply knows takes tree:0 and has not seen refuse
322 // `combine:blob:none+tree:K` (GitLab, Codeberg), walkCommit runs beside the window: the commit and the path's first two
323 // tree levels in one fetch (ply#219/#222). Anywhere else (GitHub refuses the combined filter; a first contact knows
324 // nothing yet) walkCommit's commit fetch would only repeat the window's, so the walk starts from the window's commit.
325 const windowed = route.raw ? Promise.resolve(null) : loadWindow(transport, resolved.commit);
326 const beside = route.raw || (tree0Taken(quirks) && pathTreesOf(quirks) !== 'refused');
327 const walking = beside ? walkCommit(transport, resolved.commit, comps, { cache }) : null;
328 const held = await windowed;
329 const catalog = route.raw && direct ? { branches: [], branchesTruncated: 0, tags: [], tagsTruncated: 0 } : refCatalog(await refsNow());
330 let commitData: Uint8Array;
331 let walked: Walked;
332 if (walking) {
333 const got = walkResult(await walking);
334 commitData = got.data;
335 walked = got;
336 } else {
337 for (const [oid, obj] of held === null ? [] : held) if (obj.type === TYPE.TREE) cache.set(oid, obj.data);
338 const headObj = held === null ? null : unwrapOr(mapGet(held, resolved.commit), null);
339 commitData = headObj && headObj.type === TYPE.COMMIT
340 ? headObj.data
341 : unwrap(await fetchObject(transport, { oid: resolved.commit, filter: 'tree:0', deepen: 1, expectType: TYPE.COMMIT })).data;
342 walked = walkResult(await walkPath(transport, toCommit(resolved.commit, commitData).tree, comps, { cache }));
343 }
344 const commit = toCommit(resolved.commit, commitData);
345 const header = headerFor(route.loc, resolved.name, resolved.commit, server);
346 let treeOid = commit.tree;
347 let file: { mode: string; oid: string } | null = null;
348 if (walked.entry) {
349 if (walked.entry.mode === '40000') treeOid = walked.entry.oid;
350 else file = { mode: walked.entry.mode, oid: walked.entry.oid };
351 }
352 if (file) {
353 const mode = lsMode(file.mode);
354 if (file.mode === '160000') {
355 if (route.raw) throw plyError('not_found', 'submodule has no blob in this repository', { miss: { kind: 'submodule', path: route.path, commit: file.oid } });
356 return { kind: 'file', header, path: route.path, ...catalog, mode, blob: file.oid, size: 0, note: 'submodule', text: null };
357 }
358 const blob = await readBlob(transport, tracer, file.oid);
359 if (blob.tooBig || !blob.bytes) {
360 if (route.raw) throw limitError('file bytes', blob.size, VIEWER_CAPS.maxFileDisplayBytes);
361 return { kind: 'file', header, path: route.path, ...catalog, mode, blob: file.oid, size: blob.size, note: 'too-big', text: null };
362 }
363 if (route.raw) return { kind: 'raw', filename: safeFilename(route.path), bytes: blob.bytes, size: blob.size };
364 const text = asText(blob.bytes);
365 return { kind: 'file', header, path: route.path, ...catalog, mode, blob: file.oid, size: blob.size, note: text === null ? 'binary' : 'text', text };
366 }
367 if (route.raw) throw plyError('bad_request', 'raw is a file view');
368 const data = await loadTreeBytes(transport, treeOid, cache);
369 const parsed = unwrap(parseTree(data, VIEWER_GIT_LIMITS));
370 const entries = listed(parsed);
371 let readme: { name: string; text: string } | { name: string; tooBig: true } | null = null;
372 if (!route.path && budget.canSpend(1)) {
373 const hit = parsed.find((entry: { name: string; mode: string; oid: string }) => (entry.name === 'README.md' || entry.name === 'README') && entry.mode !== '40000' && entry.mode !== '160000');
374 if (hit) {
375 try {
376 const blob = await readBlob(transport, tracer, hit.oid);
377 if (blob.tooBig || !blob.bytes) readme = { name: hit.name, tooBig: true };
378 else {
379 const text = asText(blob.bytes);
380 readme = text === null ? { name: hit.name, tooBig: true } : { name: hit.name, text: clampText(text, 20_000) };
381 }
382 } catch (err) {
383 const code = (err as { code: unknown }).code;
384 if (code === 'limit_exceeded' || code === 'timeout' || code === 'aborted') throw err;
385 readme = null;
386 }
387 }
388 }
389 const { log, logStopped } = historyOf(commit, held);
390 return {
391 kind: 'tree', header, path: route.path, commit, log, logStopped, ...catalog,
392 entries: entries.shown,
393 entriesTruncated: entries.truncated,
394 readme,
395 };
396}
398async function loadPack(transport: Transport, route: Extract<ViewerRoute, { kind: 'repo' }>, server: ServerInfo, quirks: Quirks): Promise<Loaded> {
399 const pack = route.pack;
400 if (!pack) throw plyError('internal', 'pack view without a want');
401 const want = pack.want;
402 const requested: FilterName = pack.filter;
403 const common = { wants: [want], deepen: 1, ofsDelta: true as const, thinPack: false as const };
404 let honoured: FilterName = requested;
405 let result = await fetchPack(transport, { ...common, filter: requested }, { resolve: false });
406 if (requested === 'tree:0' && !result.ok && isFilterRejection(result.error)) {
407 quirks.treeFilter = 'blob:none';
408 honoured = 'blob:none';
409 result = await fetchPack(transport, { ...common, filter: 'blob:none' }, {
410 resolve: false,
411 attrs: { 'git.fetch.filter.fallback': 'blob:none', 'git.fetch.filter.requested': 'tree:0', 'git.fetch.filter.learned': true },
412 });
413 }
414 const parsed = unwrap(result).parsed;
415 if (parsed === null) throw plyError('pack_corrupt', 'server sent no pack');
416 return {
417 kind: 'pack',
418 header: headerFor(route.loc, route.ref === null ? 'HEAD' : route.ref, want, server),
419 want,
420 filterRequested: requested,
421 filterHonoured: honoured,
422 map: mapParsed(parsed, VIEWER_GIT_LIMITS),
423 offset: pack.offset,
424 askedOfsDelta: true,
425 askedThinPack: false,
426 };
427}
429export async function loadRepo(route: Extract<ViewerRoute, { kind: 'repo' }>, deps: SessionDeps): Promise<Loaded> {
430 const quirks = quirksFor(route.loc.origin);
431 const transport = openTransport(route.loc.url, route.loc.allowedHosts, { tracer: deps.tracer, fetchImpl: deps.fetchImpl, signal: deps.signal, quirks });
432 const advertised = discover(transport).then(info => serverOf(unwrap(info)));
433 if (route.pack) return loadPack(transport, route, await advertised, quirks);
434 return loadTree(transport, route, advertised, quirks, deps.budget, deps.tracer);
435}
Diagnostics4 git calls · 198 ms
CallStatusSizeTime0198 ms
discover200152 B4 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch 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 · hit4 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=4 git.response.bytes=145 git.response.cache=HIT git.response.duration_ms=4 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 · hit7 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=187 git.response.bytes=41349 git.response.cache=HIT git.response.duration_ms=7 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=61Open pack map
fetch2007.4 KiB187 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=7607 git.response.cache=MISS git.response.duration_ms=187 git.fetch.wants=3bcd19cf6259f1ee8eee2eb1df3403f43d4595a0 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=7607 git.pkt.payload.max=7586 git.sideband.band1.bytes=7585 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
- a5e2ed03dac277be
- Request
- 21695f69…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format