t5305: simplify packname handling
[git] / t / t5305-include-tag.sh
1 #!/bin/sh
2
3 test_description='git pack-object --include-tag'
4 . ./test-lib.sh
5
6 TRASH=$(pwd)
7
8 test_expect_success setup '
9         echo c >d &&
10         git update-index --add d &&
11         tree=$(git write-tree) &&
12         commit=$(git commit-tree $tree </dev/null) &&
13         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 &&
19         tag=$(git mktag <sig) &&
20         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
28 test_expect_success 'pack without --include-tag' '
29         packname=$(git pack-objects \
30                 --window=0 \
31                 test-no-include <obj-list)
32 '
33
34 test_expect_success 'unpack objects' '
35         rm -rf clone.git &&
36         git init clone.git &&
37         git -C clone.git unpack-objects <test-no-include-${packname}.pack
38 '
39
40 test_expect_success 'check unpacked result (have commit, no tag)' '
41         git rev-list --objects $commit >list.expect &&
42         test_must_fail git -C clone.git cat-file -e $tag &&
43         git -C clone.git rev-list --objects $commit >list.actual &&
44         test_cmp list.expect list.actual
45 '
46
47 test_expect_success 'pack with --include-tag' '
48         packname=$(git pack-objects \
49                 --window=0 \
50                 --include-tag \
51                 test-include <obj-list)
52 '
53
54 test_expect_success 'unpack objects' '
55         rm -rf clone.git &&
56         git init clone.git &&
57         git -C clone.git unpack-objects <test-include-${packname}.pack
58 '
59
60 test_expect_success 'check unpacked result (have commit, have tag)' '
61         git rev-list --objects mytag >list.expect &&
62         git -C clone.git rev-list --objects $tag >list.actual &&
63         test_cmp list.expect list.actual
64 '
65
66 test_done