Skip to content

Git smart-HTTP overview

git-fs-s3/http implements the git smart-HTTP protocol (info/refs, upload-pack, receive-pack) as plain functions over a Repo — no framework assumptions, Fetch-API-shaped inputs and outputs. Extracted from the same production git-hosting service’s HTTP layer, so it’s what actually serves git clone/git push over HTTPS today: pkt-line framing, side-band-64k packfile chunking, compare-and-swap ref updates, and pack consolidation.

Node.jsCloudflare WorkersDenoBrowser

This module is pure Web APIs (Uint8Array, Web Crypto, CompressionStream) — no node:crypto, no node:zlib, no Buffer. It runs anywhere git-fs-s3 itself does.

info/refs

GET .../info/refs?service=git-upload-pack (or git-receive-pack) — the ref advertisement a client fetches before deciding what to want or push. Handled by handleInfoRefs.

upload-pack

POST .../git-upload-pack — serves a clone or fetch. Handled by handleUploadPack.

See Serving clones and pushes for a full worked example wiring all three into a route handler.

Every handler in this module accepts an optional hooks argument — the same instrumentation seam used throughout /ops:

interface HttpHooks {
/** Wrap a timed sub-step. Default: run directly. */
step?<T>(label: string, fn: () => Promise<T>): Promise<T>;
/** Non-fatal problem sink (missing objects, failed repacks). */
onWarn?(message: string, error?: unknown): void;
}

step is shaped exactly like a typical app-level timing wrapper (e.g. perfStep(label, fn)) — drop yours in directly:

const hooks = { step: perfStep, onWarn: (m, e) => logWarn('git-http', m, e) };
await handleInfoRefs(repo, { service: 'git-upload-pack' }, hooks);