]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5503-tagfollow.sh
perl: bump the required Perl version to 5.8 from 5.6.[21]
[thirdparty/git.git] / t / t5503-tagfollow.sh
1 #!/bin/sh
2
3 test_description='test automatic tag following'
4
5 . ./test-lib.sh
6
7 case $(uname -s) in
8 *MINGW*)
9 say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
10 ;;
11 *)
12 test_set_prereq NOT_MINGW
13 ;;
14 esac
15
16 # End state of the repository:
17 #
18 # T - tag1 S - tag2
19 # / /
20 # L - A ------ O ------ B
21 # \ \ \
22 # \ C - origin/cat \
23 # origin/master master
24
25 test_expect_success NOT_MINGW setup '
26 test_tick &&
27 echo ichi >file &&
28 git add file &&
29 git commit -m L &&
30 L=$(git rev-parse --verify HEAD) &&
31
32 (
33 mkdir cloned &&
34 cd cloned &&
35 git init-db &&
36 git remote add -f origin ..
37 ) &&
38
39 test_tick &&
40 echo A >file &&
41 git add file &&
42 git commit -m A &&
43 A=$(git rev-parse --verify HEAD)
44 '
45
46 U=UPLOAD_LOG
47
48 test_expect_success NOT_MINGW 'setup expect' '
49 cat - <<EOF >expect
50 #S
51 want $A
52 #E
53 EOF
54 '
55
56 test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
57 rm -f $U
58 (
59 cd cloned &&
60 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
61 test $A = $(git rev-parse --verify origin/master)
62 ) &&
63 test -s $U &&
64 cut -d" " -f1,2 $U >actual &&
65 test_cmp expect actual
66 '
67
68 test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
69 git tag -a -m tag1 tag1 $A &&
70 T=$(git rev-parse --verify tag1) &&
71
72 git checkout -b cat &&
73 echo C >file &&
74 git add file &&
75 git commit -m C &&
76 C=$(git rev-parse --verify HEAD) &&
77 git checkout master
78 '
79
80 test_expect_success NOT_MINGW 'setup expect' '
81 cat - <<EOF >expect
82 #S
83 want $C
84 want $T
85 #E
86 EOF
87 '
88
89 test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
90 rm -f $U
91 (
92 cd cloned &&
93 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
94 test $C = $(git rev-parse --verify origin/cat) &&
95 test $T = $(git rev-parse --verify tag1) &&
96 test $A = $(git rev-parse --verify tag1^0)
97 ) &&
98 test -s $U &&
99 cut -d" " -f1,2 $U >actual &&
100 test_cmp expect actual
101 '
102
103 test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
104 test_tick &&
105 echo O >file &&
106 git add file &&
107 git commit -m O &&
108
109 test_tick &&
110 echo B >file &&
111 git add file &&
112 git commit -m B &&
113 B=$(git rev-parse --verify HEAD) &&
114
115 git tag -a -m tag2 tag2 $B &&
116 S=$(git rev-parse --verify tag2)
117 '
118
119 test_expect_success NOT_MINGW 'setup expect' '
120 cat - <<EOF >expect
121 #S
122 want $B
123 want $S
124 #E
125 EOF
126 '
127
128 test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
129 rm -f $U
130 (
131 cd cloned &&
132 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
133 test $B = $(git rev-parse --verify origin/master) &&
134 test $B = $(git rev-parse --verify tag2^0) &&
135 test $S = $(git rev-parse --verify tag2)
136 ) &&
137 test -s $U &&
138 cut -d" " -f1,2 $U >actual &&
139 test_cmp expect actual
140 '
141
142 test_expect_success NOT_MINGW 'setup expect' '
143 cat - <<EOF >expect
144 #S
145 want $B
146 want $S
147 #E
148 EOF
149 '
150
151 test_expect_success NOT_MINGW 'new clone fetch master and tags' '
152 git branch -D cat
153 rm -f $U
154 (
155 mkdir clone2 &&
156 cd clone2 &&
157 git init &&
158 git remote add origin .. &&
159 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
160 test $B = $(git rev-parse --verify origin/master) &&
161 test $S = $(git rev-parse --verify tag2) &&
162 test $B = $(git rev-parse --verify tag2^0) &&
163 test $T = $(git rev-parse --verify tag1) &&
164 test $A = $(git rev-parse --verify tag1^0)
165 ) &&
166 test -s $U &&
167 cut -d" " -f1,2 $U >actual &&
168 test_cmp expect actual
169 '
170
171 test_done