t/Makefile: introduce TEST_SHELL_PATH
[alt-git.git] / t / t5503-tagfollow.sh
blob4ca48f02761d4379bf5e01cb862e47830ec0c5ac
1 #!/bin/sh
3 test_description='test automatic tag following'
5 . ./test-lib.sh
7 # End state of the repository:
9 # T - tag1 S - tag2
10 # / /
11 # L - A ------ O ------ B
12 # \ \ \
13 # \ C - origin/cat \
14 # origin/master master
16 test_expect_success setup '
17 test_tick &&
18 echo ichi >file &&
19 git add file &&
20 git commit -m L &&
21 L=$(git rev-parse --verify HEAD) &&
24 mkdir cloned &&
25 cd cloned &&
26 git init-db &&
27 git remote add -f origin ..
28 ) &&
30 test_tick &&
31 echo A >file &&
32 git add file &&
33 git commit -m A &&
34 A=$(git rev-parse --verify HEAD)
37 U=UPLOAD_LOG
38 UPATH="$(pwd)/$U"
40 test_expect_success 'setup expect' '
41 cat - <<EOF >expect
42 want $A
43 EOF
46 get_needs () {
47 test -s "$1" &&
48 perl -alne '
49 next unless $F[1] eq "upload-pack<";
50 last if $F[2] eq "0000";
51 print $F[2], " ", $F[3];
52 ' "$1"
55 test_expect_success 'fetch A (new commit : 1 connection)' '
56 rm -f $U &&
58 cd cloned &&
59 GIT_TRACE_PACKET=$UPATH git fetch &&
60 test $A = $(git rev-parse --verify origin/master)
61 ) &&
62 get_needs $U >actual &&
63 test_cmp expect actual
66 test_expect_success "create tag T on A, create C on branch cat" '
67 git tag -a -m tag1 tag1 $A &&
68 T=$(git rev-parse --verify tag1) &&
70 git checkout -b cat &&
71 echo C >file &&
72 git add file &&
73 git commit -m C &&
74 C=$(git rev-parse --verify HEAD) &&
75 git checkout master
78 test_expect_success 'setup expect' '
79 cat - <<EOF >expect
80 want $C
81 want $T
82 EOF
85 test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
86 rm -f $U &&
88 cd cloned &&
89 GIT_TRACE_PACKET=$UPATH git fetch &&
90 test $C = $(git rev-parse --verify origin/cat) &&
91 test $T = $(git rev-parse --verify tag1) &&
92 test $A = $(git rev-parse --verify tag1^0)
93 ) &&
94 get_needs $U >actual &&
95 test_cmp expect actual
98 test_expect_success "create commits O, B, tag S on B" '
99 test_tick &&
100 echo O >file &&
101 git add file &&
102 git commit -m O &&
104 test_tick &&
105 echo B >file &&
106 git add file &&
107 git commit -m B &&
108 B=$(git rev-parse --verify HEAD) &&
110 git tag -a -m tag2 tag2 $B &&
111 S=$(git rev-parse --verify tag2)
114 test_expect_success 'setup expect' '
115 cat - <<EOF >expect
116 want $B
117 want $S
121 test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
122 rm -f $U &&
124 cd cloned &&
125 GIT_TRACE_PACKET=$UPATH git fetch &&
126 test $B = $(git rev-parse --verify origin/master) &&
127 test $B = $(git rev-parse --verify tag2^0) &&
128 test $S = $(git rev-parse --verify tag2)
129 ) &&
130 get_needs $U >actual &&
131 test_cmp expect actual
134 test_expect_success 'setup expect' '
135 cat - <<EOF >expect
136 want $B
137 want $S
141 test_expect_success 'new clone fetch master and tags' '
142 test_might_fail git branch -D cat &&
143 rm -f $U &&
145 mkdir clone2 &&
146 cd clone2 &&
147 git init &&
148 git remote add origin .. &&
149 GIT_TRACE_PACKET=$UPATH git fetch &&
150 test $B = $(git rev-parse --verify origin/master) &&
151 test $S = $(git rev-parse --verify tag2) &&
152 test $B = $(git rev-parse --verify tag2^0) &&
153 test $T = $(git rev-parse --verify tag1) &&
154 test $A = $(git rev-parse --verify tag1^0)
155 ) &&
156 get_needs $U >actual &&
157 test_cmp expect actual
160 test_done