]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5305-include-tag.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t5305-include-tag.sh
CommitLineData
f0a24aa5
SP
1#!/bin/sh
2
3604e7c5 3test_description='git pack-object --include-tag'
966b4be2 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
f0a24aa5
SP
7. ./test-lib.sh
8
0469cb96 9TRASH=$(pwd)
f0a24aa5
SP
10
11test_expect_success setup '
12 echo c >d &&
13 git update-index --add d &&
0469cb96
EP
14 tree=$(git write-tree) &&
15 commit=$(git commit-tree $tree </dev/null) &&
f0a24aa5
SP
16 echo "object $commit" >sig &&
17 echo "type commit" >>sig &&
18 echo "tag mytag" >>sig &&
19 echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig &&
20 echo >>sig &&
21 echo "our test tag" >>sig &&
0469cb96 22 tag=$(git mktag <sig) &&
f0a24aa5
SP
23 rm d sig &&
24 git update-ref refs/tags/mytag $tag && {
25 echo $tree &&
26 echo $commit &&
27 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
28 } >obj-list
29'
30
f0a24aa5 31test_expect_success 'pack without --include-tag' '
ab517835 32 packname=$(git pack-objects \
f0a24aa5 33 --window=0 \
ab517835 34 test-no-include <obj-list)
f0a24aa5
SP
35'
36
37test_expect_success 'unpack objects' '
1962d9fb 38 rm -rf clone.git &&
948a7fd2 39 git init clone.git &&
ab517835 40 git -C clone.git unpack-objects <test-no-include-${packname}.pack
f0a24aa5
SP
41'
42
43test_expect_success 'check unpacked result (have commit, no tag)' '
44 git rev-list --objects $commit >list.expect &&
948a7fd2
JK
45 test_must_fail git -C clone.git cat-file -e $tag &&
46 git -C clone.git rev-list --objects $commit >list.actual &&
3af82863 47 test_cmp list.expect list.actual
f0a24aa5
SP
48'
49
f0a24aa5 50test_expect_success 'pack with --include-tag' '
ab517835 51 packname=$(git pack-objects \
f0a24aa5
SP
52 --window=0 \
53 --include-tag \
ab517835 54 test-include <obj-list)
f0a24aa5
SP
55'
56
57test_expect_success 'unpack objects' '
1962d9fb 58 rm -rf clone.git &&
948a7fd2 59 git init clone.git &&
ab517835 60 git -C clone.git unpack-objects <test-include-${packname}.pack
f0a24aa5
SP
61'
62
63test_expect_success 'check unpacked result (have commit, have tag)' '
64 git rev-list --objects mytag >list.expect &&
948a7fd2 65 git -C clone.git rev-list --objects $tag >list.actual &&
3af82863 66 test_cmp list.expect list.actual
f0a24aa5
SP
67'
68
b773ddea
JK
69# A tag of a tag, where the "inner" tag is not otherwise
70# reachable, and a full peel points to a commit reachable from HEAD.
71test_expect_success 'create hidden inner tag' '
72 test_commit commit &&
73 git tag -m inner inner HEAD &&
74 git tag -m outer outer inner &&
75 git tag -d inner
76'
77
78test_expect_success 'pack explicit outer tag' '
79 packname=$(
80 {
81 echo HEAD &&
82 echo outer
83 } |
84 git pack-objects --revs test-hidden-explicit
85 )
86'
87
88test_expect_success 'unpack objects' '
89 rm -rf clone.git &&
90 git init clone.git &&
91 git -C clone.git unpack-objects <test-hidden-explicit-${packname}.pack
92'
93
94test_expect_success 'check unpacked result (have all objects)' '
95 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
96'
97
98test_expect_success 'pack implied outer tag' '
99 packname=$(
100 echo HEAD |
101 git pack-objects --revs --include-tag test-hidden-implied
102 )
103'
104
105test_expect_success 'unpack objects' '
106 rm -rf clone.git &&
107 git init clone.git &&
108 git -C clone.git unpack-objects <test-hidden-implied-${packname}.pack
109'
110
111test_expect_success 'check unpacked result (have all objects)' '
112 git -C clone.git rev-list --objects $(git rev-parse outer HEAD)
113'
114
115test_expect_success 'single-branch clone can transfer tag' '
116 rm -rf clone.git &&
966b4be2 117 git clone --no-local --single-branch -b main . clone.git &&
b773ddea
JK
118 git -C clone.git fsck
119'
120
f0a24aa5 121test_done