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(
48GIT_DIR=clone.git &&
49export GIT_DIR &&
50test_must_fail git cat-file -e $tag &&
51git rev-list --objects $commit
52) >list.actual &&
53git diff list.expect list.actual
54'
5556
rm -rf clone.git
57test_expect_success 'pack with --include-tag' '
58packname_1=$(git pack-objects \
59--window=0 \
60--include-tag \
61test-2 <obj-list)
62'
6364
test_expect_success 'unpack objects' '
65(
66GIT_DIR=clone.git &&
67export GIT_DIR &&
68git init &&
69git unpack-objects -n <test-2-${packname_1}.pack &&
70git unpack-objects <test-2-${packname_1}.pack
71)
72'
7374
test_expect_success 'check unpacked result (have commit, have tag)' '
75git rev-list --objects mytag >list.expect &&
76(
77GIT_DIR=clone.git &&
78export GIT_DIR &&
79git rev-list --objects $tag
80) >list.actual &&
81git diff list.expect list.actual
82'
8384
test_done