fetch-pack: test explicitly that --all can fetch tag references pointing to non-commits
[gitweb.git] / t / t5500-fetch-pack.sh
index 9b9bec468a849cec0344a4b735f7fcdb4f6f888d..5879ee44d759dc4ab6b58b9c5b1f334ecb1f115e 100755 (executable)
@@ -259,7 +259,8 @@ test_expect_success 'clone shallow object count' '
 test_expect_success 'pull in shallow repo with missing merge base' '
        (
                cd shallow &&
-               test_must_fail git pull --depth 4 .. A
+               git fetch --depth 4 .. A
+               test_must_fail git merge --allow-unrelated-histories FETCH_HEAD
        )
 '
 
@@ -279,9 +280,10 @@ test_expect_success 'clone shallow depth count' '
 test_expect_success 'clone shallow object count' '
        (
                cd shallow &&
+               git prune &&
                git count-objects -v
        ) > count.shallow &&
-       grep "^count: 55" count.shallow
+       grep "^count: 54" count.shallow
 '
 
 test_expect_success 'fetch --no-shallow on full repo' '
@@ -516,6 +518,47 @@ 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=$(printf "object $blob2\ntype blob\ntag tag-to-blob2\n\
+tagger author A U Thor <author@example.com> 0 +0000\n\nhello tag" | git mktag) &&
+       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 &&
        (
@@ -556,7 +599,6 @@ check_prot_path () {
 }
 
 check_prot_host_port_path () {
-       local diagport
        case "$2" in
                *ssh*)
                pp=ssh
@@ -651,4 +693,72 @@ test_expect_success MINGW 'fetch-pack --diag-url c:repo' '
        check_prot_path c:repo file c:repo
 '
 
+test_expect_success 'clone shallow since ...' '
+       test_create_repo shallow-since &&
+       (
+       cd shallow-since &&
+       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 &&
+       git clone --shallow-since "300000000 +0700" "file://$(pwd)/." ../shallow11 &&
+       git -C ../shallow11 log --pretty=tformat:%s HEAD >actual &&
+       echo three >expected &&
+       test_cmp expected actual
+       )
+'
+
+test_expect_success 'fetch shallow since ...' '
+       git -C shallow11 fetch --shallow-since "200000000 +0700" origin &&
+       git -C shallow11 log --pretty=tformat:%s origin/master >actual &&
+       cat >expected <<-\EOF &&
+       three
+       two
+       EOF
+       test_cmp expected actual
+'
+
+test_expect_success 'shallow clone exclude tag two' '
+       test_create_repo shallow-exclude &&
+       (
+       cd shallow-exclude &&
+       test_commit one &&
+       test_commit two &&
+       test_commit three &&
+       git clone --shallow-exclude two "file://$(pwd)/." ../shallow12 &&
+       git -C ../shallow12 log --pretty=tformat:%s HEAD >actual &&
+       echo three >expected &&
+       test_cmp expected actual
+       )
+'
+
+test_expect_success 'fetch exclude tag one' '
+       git -C shallow12 fetch --shallow-exclude one origin &&
+       git -C shallow12 log --pretty=tformat:%s origin/master >actual &&
+       test_write_lines three two >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'fetching deepen' '
+       test_create_repo shallow-deepen &&
+       (
+       cd shallow-deepen &&
+       test_commit one &&
+       test_commit two &&
+       test_commit three &&
+       git clone --depth 1 "file://$(pwd)/." deepen &&
+       test_commit four &&
+       git -C deepen log --pretty=tformat:%s master >actual &&
+       echo three >expected &&
+       test_cmp expected actual &&
+       git -C deepen fetch --deepen=1 &&
+       git -C deepen log --pretty=tformat:%s origin/master >actual &&
+       cat >expected <<-\EOF &&
+       four
+       three
+       two
+       EOF
+       test_cmp expected actual
+       )
+'
+
 test_done