787fc831e3a8a41f3037252fe075afd5f3813b8f
1#!/bin/sh
2
3test_description='git pack-object --include-tag'
4. ./test-lib.sh
5
6TRASH=$(pwd)
7
8test_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
28test_expect_success 'pack without --include-tag' '
29 packname_1=$(git pack-objects \
30 --window=0 \
31 test-1 <obj-list)
32'
33
34test_expect_success 'unpack objects' '
35 rm -rf clone.git &&
36 (
37 GIT_DIR=clone.git &&
38 export GIT_DIR &&
39 git init &&
40 git unpack-objects <test-1-${packname_1}.pack
41 )
42'
43
44test_expect_success 'check unpacked result (have commit, no tag)' '
45 git rev-list --objects $commit >list.expect &&
46 (
47 test_must_fail env GIT_DIR=clone.git git cat-file -e $tag &&
48 git rev-list --objects $commit
49 ) >list.actual &&
50 test_cmp list.expect list.actual
51'
52
53test_expect_success 'pack with --include-tag' '
54 packname_1=$(git pack-objects \
55 --window=0 \
56 --include-tag \
57 test-2 <obj-list)
58'
59
60test_expect_success 'unpack objects' '
61 rm -rf clone.git &&
62 (
63 GIT_DIR=clone.git &&
64 export GIT_DIR &&
65 git init &&
66 git unpack-objects <test-2-${packname_1}.pack
67 )
68'
69
70test_expect_success 'check unpacked result (have commit, have tag)' '
71 git rev-list --objects mytag >list.expect &&
72 (
73 GIT_DIR=clone.git &&
74 export GIT_DIR &&
75 git rev-list --objects $tag
76 ) >list.actual &&
77 test_cmp list.expect list.actual
78'
79
80test_done