backend: shallow clone (--depth 1) fails over stateless HTTP — missing shallow line in phase 2 response
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- git, go
- Ambito
- api, backend, networking
Direzione di ricerca
Parti dalla gestione di Smart HTTP di backend.Backend per git-upload-pack con StatelessRPC abilitato e traccia il modo in cui vengono analizzate e serializzate le due fasi POST di un clone shallow. Riproduci con git clone --depth 1 verso il server protocol-v1, quindi verifica che la risposta della fase 2 ripeta shallow prima di NAK e che il clone riesca.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
When serving a git repository via `backend.Backend` (Smart HTTP, `StatelessRPC: true`), a `git clone --depth 1` fails with:
```
fatal: git fetch-pack: expected shallow list
```
This was discovered while running a self-hosted git marketplace server for Claude Code plugin marketplaces. Claude Code always clones marketplaces with `--depth 1 --recurse-submodules --shallow-submodules`, so this failure blocks every marketplace add/refresh.
Root Cause
The shallow clone protocol over stateless HTTP requires two POST requests:
Phase 1 — client sends `want + deepen 1`:
Server → shallow <hash> ✅ go-git sends this correctly
Server → flush
Phase 2 — client sends `want + done`:
Server → shallow <hash> ❌ go-git omits this
Server → NAK
Server → <pack data>
The client expects `shallow ` to appear again before `NAK` in the phase 2 response. go-git sends `NAK` without it, causing the client to error with `expected shallow list`.
Evidence (captured packet trace)
Without workaround — go-git phase 2 response:
fetch-pack< shallow 7aabc998... ← phase 1 OK
fetch-pack> done
fetch-pack< NAK ← phase 2 missing shallow line!
fatal: git fetch-pack: expected shallow list
With workaround — intercepting the two phases manually:
fetch-pack< shallow 7aabc998... ← phase 1 (intercepted)
fetch-pack> done
fetch-pack< shallow 7aabc998... ← phase 2 (injected)
fetch-pack< NAK
✓ clone succeeds
Workaround
We implemented a middleware that intercepts `git-upload-pack` POST requests:
- Phase 1 (`want + deepen`): handle entirely ourselves, return `shallow + flush` without involving go-git
- Phase 2 (`want + done`): pass to go-git, then inject the `shallow ` pkt-line into the response before the NAK
This works but is fragile and shouldn't be necessary.
Environment
- go-git: `v6.0.0-alpha.2`
- Client: `git/2.53.0-Linux` (system git called by Claude Code)
- Client clone flags: `git clone --depth 1 --recurse-submodules --shallow-submodules`
- Protocol: v1
Note: I'm not deeply familiar with the git wire protocol internals — this issue was written with help from Claude Code, which also helped diagnose the problem by capturing and analysing the git packet traces.
- Lingua principale
- Go
- Stelle
- 7.9k
- Fork
- 1.1k
- Merge medio
- 4g 19h
- PR unite (30g)
- 34
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di go-git/go-git
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 3 giorni
-
plumbing: ReferenceName.Short() is slow (5× fmt.Sscanf per call, panic/recover on mismatch)Forse già presa @blakepettersson l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 3 giorni
-
storage/filesystem: EncodedObjectSize leaks the loose object file handleForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 3 giorni
-
`GO_GIT_USER_AGENT_EXTRA` puts a space in the `agent` capabilityForse già presa @BoxBoxJason l’ha presa 54 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 3 giorni
-
Worktree checkout rejects Windows reserved device names (e.g. prn.sh) on Linux/macOS — regression since v5.19.1Forse già presa @SomSamantray l’ha presa 102 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
go-git/go-git#2322 · 5 commenti ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di go-git/go-git
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
alibaba/MongoShake#1077 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mattermost/mattermost-plugin-jira#1397 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Add Free CS Systems Workshops, Starter Scaffolds & Zero-Dependency Verification CLI to CS SeriesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
documentation linkinator-failure
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100