summaryrefslogtreecommitdiff
path: root/t/t5500-fetch-pack.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5500-fetch-pack.sh')
-rwxr-xr-xt/t5500-fetch-pack.sh94
1 files changed, 93 insertions, 1 deletions
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index d4f4351..fa03f56 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -259,7 +259,7 @@ test_expect_success 'clone shallow object count' '
test_expect_success 'pull in shallow repo with missing merge base' '
(
cd shallow &&
- git fetch --depth 4 .. A
+ git fetch --depth 4 .. A &&
test_must_fail git merge --allow-unrelated-histories FETCH_HEAD
)
'
@@ -518,6 +518,54 @@ test_expect_success 'test --all, --depth, and explicit tag' '
) >out-adt 2>error-adt
'
+test_expect_success 'test --all with tag to non-tip' '
+ git commit --allow-empty -m non-tip &&
+ git commit --allow-empty -m tip &&
+ git tag -m "annotated" non-tip HEAD^ &&
+ (
+ cd client &&
+ git fetch-pack --all ..
+ )
+'
+
+test_expect_success 'test --all wrt tag to non-commits' '
+ # create tag-to-{blob,tree,commit,tag}, making sure all tagged objects
+ # are reachable only via created tag references.
+ blob=$(echo "hello blob" | git hash-object -t blob -w --stdin) &&
+ git tag -a -m "tag -> blob" tag-to-blob $blob &&
+
+ tree=$(printf "100644 blob $blob\tfile" | git mktree) &&
+ git tag -a -m "tag -> tree" tag-to-tree $tree &&
+
+ tree2=$(printf "100644 blob $blob\tfile2" | git mktree) &&
+ commit=$(git commit-tree -m "hello commit" $tree) &&
+ git tag -a -m "tag -> commit" tag-to-commit $commit &&
+
+ blob2=$(echo "hello blob2" | git hash-object -t blob -w --stdin) &&
+ tag=$(git mktag <<-EOF
+ object $blob2
+ type blob
+ tag tag-to-blob2
+ tagger author A U Thor <author@example.com> 0 +0000
+
+ hello tag
+ EOF
+ ) &&
+ git tag -a -m "tag -> tag" tag-to-tag $tag &&
+
+ # `fetch-pack --all` should succeed fetching all those objects.
+ mkdir fetchall &&
+ (
+ cd fetchall &&
+ git init &&
+ git fetch-pack --all .. &&
+ git cat-file blob $blob >/dev/null &&
+ git cat-file tree $tree >/dev/null &&
+ git cat-file commit $commit >/dev/null &&
+ git cat-file tag $tag >/dev/null
+ )
+'
+
test_expect_success 'shallow fetch with tags does not break the repository' '
mkdir repo1 &&
(
@@ -711,6 +759,17 @@ test_expect_success 'fetch shallow since ...' '
test_cmp expected actual
'
+test_expect_success 'clone shallow since selects no commits' '
+ test_create_repo shallow-since-the-future &&
+ (
+ cd shallow-since-the-future &&
+ GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
+ GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
+ GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
+ test_must_fail git clone --shallow-since "900000000 +0700" "file://$(pwd)/." ../shallow111
+ )
+'
+
test_expect_success 'shallow clone exclude tag two' '
test_create_repo shallow-exclude &&
(
@@ -755,6 +814,39 @@ test_expect_success 'fetching deepen' '
)
'
+test_expect_success 'use ref advertisement to prune "have" lines sent' '
+ rm -rf server client &&
+ git init server &&
+ test_commit -C server both_have_1 &&
+ git -C server tag -d both_have_1 &&
+ test_commit -C server both_have_2 &&
+
+ git clone server client &&
+ test_commit -C server server_has &&
+ test_commit -C client client_has &&
+
+ # In both protocol v0 and v2, ensure that the parent of both_have_2 is
+ # not sent as a "have" line. The client should know that the server has
+ # both_have_2, so it only needs to inform the server that it has
+ # both_have_2, and the server can infer the rest.
+
+ rm -f trace &&
+ cp -r client clientv0 &&
+ GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv0 \
+ fetch origin server_has both_have_2 &&
+ grep "have $(git -C client rev-parse client_has)" trace &&
+ grep "have $(git -C client rev-parse both_have_2)" trace &&
+ ! grep "have $(git -C client rev-parse both_have_2^)" trace &&
+
+ rm -f trace &&
+ cp -r client clientv2 &&
+ GIT_TRACE_PACKET="$(pwd)/trace" git -C clientv2 -c protocol.version=2 \
+ fetch origin server_has both_have_2 &&
+ grep "have $(git -C client rev-parse client_has)" trace &&
+ grep "have $(git -C client rev-parse both_have_2)" trace &&
+ ! grep "have $(git -C client rev-parse both_have_2^)" trace
+'
+
test_expect_success 'filtering by size' '
rm -rf server client &&
test_create_repo server &&