From: Taylor Blau Date: Mon, 26 Oct 2026 23:49:37 GMT Subject: [PATCH v3 1/2] negotiator/default.c: mark commits seen only after parsing Message-ID: <5a6af9166354f0c0d0c229f0ed57b495af24090c.1793058562.git.ttaylorr@openai.com> In-Reply-To: rev_list_push() sets SEEN before parsing a commit, but leaves the commit out of the queue if parsing fails. This makes SEEN describe an attempted insertion rather than a commit that was actually queued. mark_common() relies on SEEN and POPPED to decide whether a newly common commit contributes to non_common_revs. If a missing parent is marked SEEN and later reached while acknowledging one of its children, mark_common() subtracts it even though rev_list_push() never incremented the counter. This can stop negotiation while other non-common commits remain queued. Set the requested flags only after parsing succeeds. Successful insertions are unchanged, and a failed parse no longer marks the commit as queued. This also lets the skipping negotiator follow the same order when it starts parsing commits in rev_list_push(). Add a negotiation-only fetch test that fills the first batch with commits above a missing parent, leaving an older, unrelated tip queued. The ACK for the first branch must not stop negotiation before the second tip is sent and acknowledged. Before this fix, the second tip is omitted and the negotiation-only fetch fails. Signed-off-by: Taylor Blau --- negotiator/default.c | 3 +-- t/t5702-protocol-v2.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/negotiator/default.c b/negotiator/default.c index 19cdf3808cf..32cba7ed8d9 100644 --- a/negotiator/default.c +++ b/negotiator/default.c @@ -26,11 +26,10 @@ static void rev_list_push(struct negotiation_state *ns, struct commit *commit, int mark) { if (!(commit->object.flags & mark)) { - commit->object.flags |= mark; - if (repo_parse_commit(the_repository, commit)) return; + commit->object.flags |= mark; prio_queue_put(&ns->rev_list, commit); if (!(commit->object.flags & COMMON)) diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 7e69ba7f843..b1768cbdbc5 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -912,6 +912,37 @@ test_expect_success 'file:// --negotiate-only' ' test_grep "$COMMON" out ' +test_expect_success 'negotiate-only continues after ACK with a missing ancestor' ' + rm -rf server client && + git init server && + test_commit -C server --no-tag b && + git -C server branch b && + git -C server checkout --orphan a && + test_commit -C server --no-tag missing && + missing=$(git -C server rev-parse HEAD) && + + # Fill the first batch with this branch, leaving b for the next one. + for i in $(test_seq 16) + do + test_commit -C server --no-tag a$i || return 1 + done && + git clone --no-hardlinks server client && + # Force a parse failure in the client. Keep the parent on the + # server so it can acknowledge the branch normally. + rm "client/.git/objects/$(test_oid_to_path "$missing")" && + + # ACKing a must not count the missing ancestor as a queued commit + # and stop negotiation before sending b. + git -c protocol.version=2 -c core.commitGraph=false \ + -c fetch.negotiationAlgorithm=consecutive -C client fetch \ + --negotiate-only --negotiation-tip=a --negotiation-tip=origin/b \ + origin >out && + git -C client rev-parse a origin/b >tips && + sort tips >expect && + sort out >actual && + test_cmp expect actual +' + test_expect_success 'file:// --negotiate-only with protocol v0' ' SERVER="server" && URI="file://$(pwd)/server" && -- 2.56.0.187.g9e9ae442333