setup: merge configuration of repository formats
[git/gitster.git] / t / t5305-include-tag.sh
blobdc8fe55c82d5ee146014f4b3d5f478d13fdc75f1
1 #!/bin/sh
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
8 . ./test-lib.sh
10 TRASH=$(pwd)
12 test_expect_success setup '
13 echo c >d &&
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 &&
21 echo >>sig &&
22 echo "our test tag" >>sig &&
23 tag=$(git mktag <sig) &&
24 rm d sig &&
25 git update-ref refs/tags/mytag $tag && {
26 echo $tree &&
27 echo $commit &&
28 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
29 } >obj-list
32 test_expect_success 'pack without --include-tag' '
33 packname=$(git pack-objects \
34 --window=0 \
35 test-no-include <obj-list)
38 test_expect_success 'unpack objects' '
39 rm -rf clone.git &&
40 git init clone.git &&
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 \
53 --window=0 \
54 --include-tag \
55 test-include <obj-list)
58 test_expect_success 'unpack objects' '
59 rm -rf clone.git &&
60 git init clone.git &&
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' '
73 test_commit commit &&
74 git tag -m inner inner HEAD &&
75 git tag -m outer outer inner &&
76 git tag -d inner
79 test_expect_success 'pack explicit outer tag' '
80 packname=$(
82 echo HEAD &&
83 echo outer
84 } |
85 git pack-objects --revs test-hidden-explicit
89 test_expect_success 'unpack objects' '
90 rm -rf clone.git &&
91 git init clone.git &&
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' '
100 packname=$(
101 echo HEAD |
102 git pack-objects --revs --include-tag test-hidden-implied
106 test_expect_success 'unpack objects' '
107 rm -rf clone.git &&
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' '
117 rm -rf clone.git &&
118 git clone --no-local --single-branch -b main . clone.git &&
119 git -C clone.git fsck
122 test_done