3 test_description
='git pack-object --include-tag'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 test_expect_success setup
'
13 git update-index --add d &&
14 tree=$(git write-tree) &&
15 commit=$(git commit-tree $tree </dev/null) &&
16 echo "object $commit" >sig &&
17 echo "type commit" >>sig &&
18 echo "tag mytag" >>sig &&
19 echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig &&
21 echo "our test tag" >>sig &&
22 tag=$(git mktag <sig) &&
24 git update-ref refs/tags/mytag $tag && {
27 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
31 test_expect_success
'pack without --include-tag' '
32 packname=$(git pack-objects \
34 test-no-include <obj-list)
37 test_expect_success
'unpack objects' '
40 git -C clone.git unpack-objects <test-no-include-${packname}.pack
43 test_expect_success
'check unpacked result (have commit, no tag)' '
44 git rev-list --objects $commit >list.expect &&
45 test_must_fail git -C clone.git cat-file -e $tag &&
46 git -C clone.git rev-list --objects $commit >list.actual &&
47 test_cmp list.expect list.actual
50 test_expect_success
'pack with --include-tag' '
51 packname=$(git pack-objects \
54 test-include <obj-list)
57 test_expect_success
'unpack objects' '
60 git -C clone.git unpack-objects <test-include-${packname}.pack
63 test_expect_success
'check unpacked result (have commit, have tag)' '
64 git rev-list --objects mytag >list.expect &&
65 git -C clone.git rev-list --objects $tag >list.actual &&
66 test_cmp list.expect list.actual
69 # A tag of a tag, where the "inner" tag is not otherwise
70 # reachable, and a full peel points to a commit reachable from HEAD.
71 test_expect_success
'create hidden inner tag' '
73 git tag -m inner inner HEAD &&
74 git tag -m outer outer inner &&
78 test_expect_success
'pack explicit outer tag' '
84 git pack-objects --revs test-hidden-explicit
88 test_expect_success
'unpack objects' '
91 git -C clone.git unpack-objects <test-hidden-explicit-${packname}.pack
94 test_expect_success
'check unpacked result (have all objects)' '
95 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
98 test_expect_success
'pack implied outer tag' '
101 git pack-objects --revs --include-tag test-hidden-implied
105 test_expect_success
'unpack objects' '
107 git init clone.git &&
108 git -C clone.git unpack-objects <test-hidden-implied-${packname}.pack
111 test_expect_success
'check unpacked result (have all objects)' '
112 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
115 test_expect_success
'single-branch clone can transfer tag' '
117 git clone --no-local --single-branch -b main . clone.git &&
118 git -C clone.git fsck