]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5305-include-tag.sh
tests: use "env" to run commands with temporary env-var settings
[thirdparty/git.git] / t / t5305-include-tag.sh
CommitLineData
f0a24aa5
SP
1#!/bin/sh
2
3604e7c5 3test_description='git pack-object --include-tag'
f0a24aa5
SP
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
28rm -rf clone.git
29test_expect_success 'pack without --include-tag' '
30 packname_1=$(git pack-objects \
31 --window=0 \
32 test-1 <obj-list)
33'
34
35test_expect_success 'unpack objects' '
36 (
37 GIT_DIR=clone.git &&
38 export GIT_DIR &&
39 git init &&
40 git unpack-objects -n <test-1-${packname_1}.pack &&
41 git unpack-objects <test-1-${packname_1}.pack
42 )
43'
44
45test_expect_success 'check unpacked result (have commit, no tag)' '
46 git rev-list --objects $commit >list.expect &&
47 (
512477b1 48 test_must_fail env GIT_DIR=clone.git git cat-file -e $tag &&
f0a24aa5
SP
49 git rev-list --objects $commit
50 ) >list.actual &&
3af82863 51 test_cmp list.expect list.actual
f0a24aa5
SP
52'
53
54rm -rf clone.git
55test_expect_success 'pack with --include-tag' '
56 packname_1=$(git pack-objects \
57 --window=0 \
58 --include-tag \
59 test-2 <obj-list)
60'
61
62test_expect_success 'unpack objects' '
63 (
64 GIT_DIR=clone.git &&
65 export GIT_DIR &&
66 git init &&
67 git unpack-objects -n <test-2-${packname_1}.pack &&
68 git unpack-objects <test-2-${packname_1}.pack
69 )
70'
71
72test_expect_success 'check unpacked result (have commit, have tag)' '
73 git rev-list --objects mytag >list.expect &&
74 (
75 GIT_DIR=clone.git &&
76 export GIT_DIR &&
77 git rev-list --objects $tag
78 ) >list.actual &&
3af82863 79 test_cmp list.expect list.actual
f0a24aa5
SP
80'
81
82test_done