Repository navigation
fix(gix-protocol): send all V1 want lines before shallow and deepen lines. (#3247) - #3248
sagi-qryptonite wants to merge 1 commit into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b3170decb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".
359b3f2 to
2e07615
Compare
…pen` lines. (GitoxideLabs#3247) `fetch()` adds `shallow` and `deepen*` arguments before the wants, and `Arguments::send()` then only swapped the *first* `want` to the front for protocol V0/V1. With more than one want, which a clone always has (`HEAD` and the branch it points to), the request became ``` want <id> <capabilities> deepen 1 want <id> 0000 done ``` The V1 grammar is `want-list *shallow-line *1depth-request [filter-request] flush-pkt` (see `gitprotocol-pack`), which is also the order `git` uses. `git upload-pack` accepts lines in any order, so this went unnoticed with GitHub and `git http-backend`, but Azure DevOps Services rejects such a request with HTTP 400, which made every shallow clone from it fail. Now the arguments are sorted stably before sending, in grammar order: all wants (the first one still carrying the capabilities), `shallow` lines, the `deepen*` lines in the order they were added, and `filter` last. As stateless transports resend the retained arguments in each round, every round uses this order. `haves_and_wants_for_clone` and `haves_and_wants_for_fetch_stateless` now add `deepen` (and `filter`) before multiple wants, like `fetch()` does. The expectation of `response::v1::arguments::all` changes as it encoded the previous behaviour, where the swap moved the `shallow` line behind the `deepen*` lines.
2e07615 to
a0300cb
Compare
Fixes #3247.
Motivation
The fix is for a repository scanner built on
gixthat fetches repositories withShallow::DepthAtRemote(1). Shallow fetches from Azure DevOps Services fail, so it currently has to fall back to full fetches for those hosts.Root cause
fetch()adds theshallow/deepen*arguments before the wants. For protocol V0/V1,Arguments::send()then swapped only the firstwantto the front. With more than one want, thedeepenline ended up betweenwantlines. A clone always has at least two wants (HEADand the branch it points to, even if they are the same id).git upload-packaccepts lines in any order, so GitHub andgit http-backenddidn't notice. Azure DevOps follows the grammar ingitprotocol-pack,want-list *shallow-line *1depth-request [filter-request] flush-pkt, and answers with HTTP 400.It isn't the unadvertised
deepen-*capabilities suspected in the issue.gix0.91 sends only what the server advertised.Packet traces
Shallow clone (depth 1) of an Azure DevOps Services repository, captured with
gitoxide.tracePacket=true:Before (HTTP 400):
After:
The order of the lines is the only difference between the two requests.
Change
prepare_v1()now sorts the arguments stably in grammar order: all wants (the first one still carries the capabilities), thenshallowlines, then thedeepen*lines in the order they were added, thenfilter. Stateless transports resend the retained arguments in each round, so every round uses this order.The expectation in
response::v1::arguments::allchanges because it encoded the old behaviour, where the swap moved theshallowline behind thedeepen*lines. The new order (shallowbeforedeepen) is the ordergituses.Tests
The existing
fetch::arguments::v1::haves_and_wants_for_cloneandhaves_and_wants_for_fetch_statelessnow adddeepen(andfilter) before two wants, asfetch()does, and check the exact request bytes of both stateless rounds. Both fail without the fix, and the stateless one also fails iffilterisn't ranked after thedeepen*lines.cargo test -p gix-protocolpasses withblocking-clientand withasync-client.cargo fmt --checkpasses.cargo clippyreports nothing new; the existingdrop_non_dropwarning atfetch/function.rs:154is also onmain.cargo test -p gix --features blocking-network-client --test gix -- remote:: clonepasses, including all shallow clone and fetch tests. On macOS,fetch_and_checkout_honors_shared_repository_permissionsalso fails onmain, so that failure is unrelated.Against live servers with a small
gix::clone::PrepareFetchprogram:github.com/octocat/Hello-World