1#!/bin/sh
23
test_description='git pack-object --include-tag'
4. ./test-lib.sh
56
TRASH=$(pwd)
78
test_expect_success setup '
9echo c >d &&
10git update-index --add d &&
11tree=$(git write-tree) &&
12commit=$(git commit-tree $tree </dev/null) &&
13echo "object $commit" >sig &&
14echo "type commit" >>sig &&
15echo "tag mytag" >>sig &&
16echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig &&
17echo >>sig &&
18echo "our test tag" >>sig &&
19tag=$(git mktag <sig) &&
20rm d sig &&
21git update-ref refs/tags/mytag $tag && {
22echo $tree &&
23echo $commit &&
24git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
25} >obj-list
26'
2728
rm -rf clone.git
29test_expect_success 'pack without --include-tag' '
30packname_1=$(git pack-objects \
31--window=0 \
32test-1 <obj-list)
33'
3435
test_expect_success 'unpack objects' '
36(
37GIT_DIR=clone.git &&
38export GIT_DIR &&
39git init &&
40git unpack-objects -n <test-1-${packname_1}.pack &&
41git unpack-objects <test-1-${packname_1}.pack
42)
43'
4445
test_expect_success 'check unpacked result (have commit, no tag)' '
46git rev-list --objects $commit >list.expect &&
47(
48test_must_fail env GIT_DIR=clone.git git cat-file -e $tag &&
49git rev-list --objects $commit
50) >list.actual &&
51test_cmp list.expect list.actual
52'
5354
rm -rf clone.git
55test_expect_success 'pack with --include-tag' '
56packname_1=$(git pack-objects \
57--window=0 \
58--include-tag \
59test-2 <obj-list)
60'
6162
test_expect_success 'unpack objects' '
63(
64GIT_DIR=clone.git &&
65export GIT_DIR &&
66git init &&
67git unpack-objects -n <test-2-${packname_1}.pack &&
68git unpack-objects <test-2-${packname_1}.pack
69)
70'
7172
test_expect_success 'check unpacked result (have commit, have tag)' '
73git rev-list --objects mytag >list.expect &&
74(
75GIT_DIR=clone.git &&
76export GIT_DIR &&
77git rev-list --objects $tag
78) >list.actual &&
79test_cmp list.expect list.actual
80'
8182
test_done