blob: a5eca210b8963c4881fd8be858d13b88401b9888 [file] [log] [blame]
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -05001#!/bin/sh
2
Nanako Shiraishi3604e7c2008-09-03 17:59:29 +09003test_description='git pack-object --include-tag'
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -05004. ./test-lib.sh
5
Elia Pinto0469cb92015-12-23 14:45:51 +01006TRASH=$(pwd)
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -05007
8test_expect_success setup '
9 echo c >d &&
10 git update-index --add d &&
Elia Pinto0469cb92015-12-23 14:45:51 +010011 tree=$(git write-tree) &&
12 commit=$(git commit-tree $tree </dev/null) &&
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050013 echo "object $commit" >sig &&
14 echo "type commit" >>sig &&
15 echo "tag mytag" >>sig &&
16 echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig &&
17 echo >>sig &&
18 echo "our test tag" >>sig &&
Elia Pinto0469cb92015-12-23 14:45:51 +010019 tag=$(git mktag <sig) &&
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050020 rm d sig &&
21 git update-ref refs/tags/mytag $tag && {
22 echo $tree &&
23 echo $commit &&
24 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
25 } >obj-list
26'
27
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050028test_expect_success 'pack without --include-tag' '
Jeff Kingab517832016-09-05 17:52:22 -040029 packname=$(git pack-objects \
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050030 --window=0 \
Jeff Kingab517832016-09-05 17:52:22 -040031 test-no-include <obj-list)
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050032'
33
34test_expect_success 'unpack objects' '
Jeff King1962d9f2016-09-05 17:52:10 -040035 rm -rf clone.git &&
Jeff King948a7fd2016-09-05 17:52:17 -040036 git init clone.git &&
Jeff Kingab517832016-09-05 17:52:22 -040037 git -C clone.git unpack-objects <test-no-include-${packname}.pack
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050038'
39
40test_expect_success 'check unpacked result (have commit, no tag)' '
41 git rev-list --objects $commit >list.expect &&
Jeff King948a7fd2016-09-05 17:52:17 -040042 test_must_fail git -C clone.git cat-file -e $tag &&
43 git -C clone.git rev-list --objects $commit >list.actual &&
Junio C Hamano3af82862008-05-23 22:28:56 -070044 test_cmp list.expect list.actual
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050045'
46
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050047test_expect_success 'pack with --include-tag' '
Jeff Kingab517832016-09-05 17:52:22 -040048 packname=$(git pack-objects \
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050049 --window=0 \
50 --include-tag \
Jeff Kingab517832016-09-05 17:52:22 -040051 test-include <obj-list)
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050052'
53
54test_expect_success 'unpack objects' '
Jeff King1962d9f2016-09-05 17:52:10 -040055 rm -rf clone.git &&
Jeff King948a7fd2016-09-05 17:52:17 -040056 git init clone.git &&
Jeff Kingab517832016-09-05 17:52:22 -040057 git -C clone.git unpack-objects <test-include-${packname}.pack
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050058'
59
60test_expect_success 'check unpacked result (have commit, have tag)' '
61 git rev-list --objects mytag >list.expect &&
Jeff King948a7fd2016-09-05 17:52:17 -040062 git -C clone.git rev-list --objects $tag >list.actual &&
Junio C Hamano3af82862008-05-23 22:28:56 -070063 test_cmp list.expect list.actual
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -050064'
65
Jeff Kingb773dde2016-09-05 17:52:26 -040066# A tag of a tag, where the "inner" tag is not otherwise
67# reachable, and a full peel points to a commit reachable from HEAD.
68test_expect_success 'create hidden inner tag' '
69 test_commit commit &&
70 git tag -m inner inner HEAD &&
71 git tag -m outer outer inner &&
72 git tag -d inner
73'
74
75test_expect_success 'pack explicit outer tag' '
76 packname=$(
77 {
78 echo HEAD &&
79 echo outer
80 } |
81 git pack-objects --revs test-hidden-explicit
82 )
83'
84
85test_expect_success 'unpack objects' '
86 rm -rf clone.git &&
87 git init clone.git &&
88 git -C clone.git unpack-objects <test-hidden-explicit-${packname}.pack
89'
90
91test_expect_success 'check unpacked result (have all objects)' '
92 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
93'
94
95test_expect_success 'pack implied outer tag' '
96 packname=$(
97 echo HEAD |
98 git pack-objects --revs --include-tag test-hidden-implied
99 )
100'
101
102test_expect_success 'unpack objects' '
103 rm -rf clone.git &&
104 git init clone.git &&
105 git -C clone.git unpack-objects <test-hidden-implied-${packname}.pack
106'
107
108test_expect_success 'check unpacked result (have all objects)' '
109 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
110'
111
112test_expect_success 'single-branch clone can transfer tag' '
113 rm -rf clone.git &&
114 git clone --no-local --single-branch -b master . clone.git &&
115 git -C clone.git fsck
116'
117
Shawn O. Pearcef0a24aa2008-03-03 22:27:20 -0500118test_done