summaryrefslogtreecommitdiff
path: root/t/t5500-fetch-pack.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-05-01 20:40:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-01 20:40:00 (GMT)
commit0b07eecf6ed9334f09d6624732a4af2da03e38eb (patch)
treedc9a051dc91ba996bae50b24e6e0169a1d339375 /t/t5500-fetch-pack.sh
parent2c42fb76531f4565b5434e46102e6d85a0861738 (diff)
parent2f0a093dd640e0dad0b261dae2427f2541b5426c (diff)
downloadgit-0b07eecf6ed9334f09d6624732a4af2da03e38eb.zip
git-0b07eecf6ed9334f09d6624732a4af2da03e38eb.tar.gz
git-0b07eecf6ed9334f09d6624732a4af2da03e38eb.tar.bz2
Merge branch 'jt/v2-fetch-nego-fix'
The upload-pack protocol v2 gave up too early before finding a common ancestor, resulting in a wasteful fetch from a fork of a project. This has been corrected to match the behaviour of v0 protocol. * jt/v2-fetch-nego-fix: fetch-pack: in protocol v2, reset in_vain upon ACK fetch-pack: in protocol v2, in_vain only after ACK fetch-pack: return enum from process_acks()
Diffstat (limited to 't/t5500-fetch-pack.sh')
-rwxr-xr-xt/t5500-fetch-pack.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index baa1a99..52dd1a6 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -385,6 +385,54 @@ test_expect_success 'clone shallow with packed refs' '
test_cmp count8.expected count8.actual
'
+test_expect_success 'in_vain not triggered before first ACK' '
+ rm -rf myserver myclient trace &&
+ git init myserver &&
+ test_commit -C myserver foo &&
+ git clone "file://$(pwd)/myserver" myclient &&
+
+ # MAX_IN_VAIN is 256. Because of batching, the client will send 496
+ # (16+32+64+128+256) commits, not 256, before giving up. So create 496
+ # irrelevant commits.
+ test_commit_bulk -C myclient 496 &&
+
+ # The new commit that the client wants to fetch.
+ test_commit -C myserver bar &&
+
+ GIT_TRACE_PACKET="$(pwd)/trace" git -C myclient fetch --progress origin &&
+ test_i18ngrep "Total 3 " trace
+'
+
+test_expect_success 'in_vain resetted upon ACK' '
+ rm -rf myserver myclient trace &&
+ git init myserver &&
+
+ # Linked list of commits on master. The first is common; the rest are
+ # not.
+ test_commit -C myserver first_master_commit &&
+ git clone "file://$(pwd)/myserver" myclient &&
+ test_commit_bulk -C myclient 255 &&
+
+ # Another linked list of commits on anotherbranch with no connection to
+ # master. The first is common; the rest are not.
+ git -C myserver checkout --orphan anotherbranch &&
+ test_commit -C myserver first_anotherbranch_commit &&
+ git -C myclient fetch origin anotherbranch:refs/heads/anotherbranch &&
+ git -C myclient checkout anotherbranch &&
+ test_commit_bulk -C myclient 255 &&
+
+ # The new commit that the client wants to fetch.
+ git -C myserver checkout master &&
+ test_commit -C myserver to_fetch &&
+
+ # The client will send (as "have"s) all 256 commits in anotherbranch
+ # first. The 256th commit is common between the client and the server,
+ # and should reset in_vain. This allows negotiation to continue until
+ # the client reports that first_anotherbranch_commit is common.
+ GIT_TRACE_PACKET="$(pwd)/trace" git -C myclient fetch --progress origin master &&
+ test_i18ngrep "Total 3 " trace
+'
+
test_expect_success 'fetch in shallow repo unreachable shallow objects' '
(
git clone --bare --branch B --single-branch "file://$(pwd)/." no-reflog &&