t7003: Use test_commit instead of custom function
[git/mjg.git] / t / t5503-tagfollow.sh
blob8a298a655fa007fbd9a43d6212b53f749c980eb6
1 #!/bin/sh
3 test_description='test automatic tag following'
5 . ./test-lib.sh
7 case $(uname -s) in
8 *MINGW*)
9 say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
12 test_set_prereq NOT_MINGW
14 esac
16 # End state of the repository:
18 # T - tag1 S - tag2
19 # / /
20 # L - A ------ O ------ B
21 # \ \ \
22 # \ C - origin/cat \
23 # origin/master master
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) &&
33 mkdir cloned &&
34 cd cloned &&
35 git init-db &&
36 git remote add -f origin ..
37 ) &&
39 test_tick &&
40 echo A >file &&
41 git add file &&
42 git commit -m A &&
43 A=$(git rev-parse --verify HEAD)
46 U=UPLOAD_LOG
48 test_expect_success NOT_MINGW 'setup expect' '
49 cat - <<EOF >expect
51 want $A
53 EOF
56 test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
57 rm -f $U
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
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) &&
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
80 test_expect_success NOT_MINGW 'setup expect' '
81 cat - <<EOF >expect
83 want $C
84 want $T
86 EOF
89 test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
90 rm -f $U
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
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 &&
109 test_tick &&
110 echo B >file &&
111 git add file &&
112 git commit -m B &&
113 B=$(git rev-parse --verify HEAD) &&
115 git tag -a -m tag2 tag2 $B &&
116 S=$(git rev-parse --verify tag2)
119 test_expect_success NOT_MINGW 'setup expect' '
120 cat - <<EOF >expect
122 want $B
123 want $S
128 test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
129 rm -f $U
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
142 test_expect_success NOT_MINGW 'setup expect' '
143 cat - <<EOF >expect
145 want $B
146 want $S
151 test_expect_success NOT_MINGW 'new clone fetch master and tags' '
152 git branch -D cat
153 rm -f $U
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
171 test_done