3 test_description
='git pack-object --include-tag'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
12 test_expect_success setup
'
14 git update-index --add d &&
15 tree=$(git write-tree) &&
16 commit=$(git commit-tree $tree </dev/null) &&
17 echo "object $commit" >sig &&
18 echo "type commit" >>sig &&
19 echo "tag mytag" >>sig &&
20 echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig &&
22 echo "our test tag" >>sig &&
23 tag=$(git mktag <sig) &&
25 git update-ref refs/tags/mytag $tag && {
28 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
32 test_expect_success
'pack without --include-tag' '
33 packname=$(git pack-objects \
35 test-no-include <obj-list)
38 test_expect_success
'unpack objects' '
41 git -C clone.git unpack-objects <test-no-include-${packname}.pack
44 test_expect_success
'check unpacked result (have commit, no tag)' '
45 git rev-list --objects $commit >list.expect &&
46 test_must_fail git -C clone.git cat-file -e $tag &&
47 git -C clone.git rev-list --objects $commit >list.actual &&
48 test_cmp list.expect list.actual
51 test_expect_success
'pack with --include-tag' '
52 packname=$(git pack-objects \
55 test-include <obj-list)
58 test_expect_success
'unpack objects' '
61 git -C clone.git unpack-objects <test-include-${packname}.pack
64 test_expect_success
'check unpacked result (have commit, have tag)' '
65 git rev-list --objects mytag >list.expect &&
66 git -C clone.git rev-list --objects $tag >list.actual &&
67 test_cmp list.expect list.actual
70 # A tag of a tag, where the "inner" tag is not otherwise
71 # reachable, and a full peel points to a commit reachable from HEAD.
72 test_expect_success
'create hidden inner tag' '
74 git tag -m inner inner HEAD &&
75 git tag -m outer outer inner &&
79 test_expect_success
'pack explicit outer tag' '
85 git pack-objects --revs test-hidden-explicit
89 test_expect_success
'unpack objects' '
92 git -C clone.git unpack-objects <test-hidden-explicit-${packname}.pack
95 test_expect_success
'check unpacked result (have all objects)' '
96 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
99 test_expect_success
'pack implied outer tag' '
102 git pack-objects --revs --include-tag test-hidden-implied
106 test_expect_success
'unpack objects' '
108 git init clone.git &&
109 git -C clone.git unpack-objects <test-hidden-implied-${packname}.pack
112 test_expect_success
'check unpacked result (have all objects)' '
113 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
116 test_expect_success
'single-branch clone can transfer tag' '
118 git clone --no-local --single-branch -b main . clone.git &&
119 git -C clone.git fsck