git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/2] negotiator/default.c: mark commits seen only after parsing

From
Taylor Blau <ttaylorr@openai.com>
Date
Oct 26, 2026, 23:49 UTC
Message-ID
<5a6af9166354f0c0d0c229f0ed57b495af24090c.1793058562.git.ttaylorr@openai.com>
In-Reply-To
<cover.1793058562.git.ttaylorr@openai.com>

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 <ttaylorr@openai.com>
---
 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
Previous: Taylor BlauNext: Taylor Blau
Message 14 of 15 in “negotiator/skipping.c: parse parents before queueing”
  1. negotiator/skipping.c: parse parents before queueingTaylor Blau, Oct 19, 2026
  2. Patrick SteinhardtOct 21, 2026
  3. Junio C HamanoOct 21, 2026
  4. Taylor BlauOct 22, 2026
  5. Junio C HamanoOct 22, 2026
  6. Taylor BlauOct 22, 2026
  7. negotiator/skipping.c: parse parents before queueingTaylor Blau, Oct 22, 2026
  8. Junio C HamanoOct 22, 2026
  9. Taylor BlauOct 22, 2026
  10. Junio C HamanoOct 23, 2026
  11. Taylor BlauOct 24, 2026
  12. Junio C HamanoOct 24, 2026
  13. 0/2 negotiator: parse commits before queueingTaylor Blau, Oct 26, 2026
  14. 1/2 negotiator/default.c: mark commits seen only after parsingTaylor Blau, Oct 26, 2026
  15. 2/2 negotiator/skipping.c: parse parents before queueingTaylor Blau, Oct 26, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.