Skip to content

Commit 2f0a093

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: in protocol v2, reset in_vain upon ACK
In the function process_acks() in fetch-pack.c, the variable received_ack is meant to track that an ACK was received, but it was never set. This results in negotiation terminating prematurely through the in_vain counter, when the counter should have been reset upon every ACK. Therefore, reset the in_vain counter upon every ACK. Helped-by: Jonathan Nieder <[email protected]> Signed-off-by: Jonathan Tan <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4fa3f00 commit 2f0a093

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

fetch-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,7 @@ static enum common_found process_acks(struct fetch_negotiator *negotiator,
13071307

13081308
if (skip_prefix(reader->line, "ACK ", &arg)) {
13091309
struct object_id oid;
1310+
received_ack = 1;
13101311
if (!get_oid_hex(arg, &oid)) {
13111312
struct commit *commit;
13121313
oidset_insert(common, &oid);

t/t5500-fetch-pack.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,36 @@ test_expect_success 'in_vain not triggered before first ACK' '
403403
test_i18ngrep "Total 3 " trace
404404
'
405405

406+
test_expect_success 'in_vain resetted upon ACK' '
407+
rm -rf myserver myclient trace &&
408+
git init myserver &&
409+
410+
# Linked list of commits on master. The first is common; the rest are
411+
# not.
412+
test_commit -C myserver first_master_commit &&
413+
git clone "file://$(pwd)/myserver" myclient &&
414+
test_commit_bulk -C myclient 255 &&
415+
416+
# Another linked list of commits on anotherbranch with no connection to
417+
# master. The first is common; the rest are not.
418+
git -C myserver checkout --orphan anotherbranch &&
419+
test_commit -C myserver first_anotherbranch_commit &&
420+
git -C myclient fetch origin anotherbranch:refs/heads/anotherbranch &&
421+
git -C myclient checkout anotherbranch &&
422+
test_commit_bulk -C myclient 255 &&
423+
424+
# The new commit that the client wants to fetch.
425+
git -C myserver checkout master &&
426+
test_commit -C myserver to_fetch &&
427+
428+
# The client will send (as "have"s) all 256 commits in anotherbranch
429+
# first. The 256th commit is common between the client and the server,
430+
# and should reset in_vain. This allows negotiation to continue until
431+
# the client reports that first_anotherbranch_commit is common.
432+
GIT_TRACE_PACKET="$(pwd)/trace" git -C myclient fetch --progress origin master &&
433+
test_i18ngrep "Total 3 " trace
434+
'
435+
406436
test_expect_success 'fetch in shallow repo unreachable shallow objects' '
407437
(
408438
git clone --bare --branch B --single-branch "file://$(pwd)/." no-reflog &&

0 commit comments

Comments
 (0)