Merge branch 'rs/opt-help-text'
[git/kirr.git] / t / t5503-tagfollow.sh
blob60de2d6ede958e713aebe85d73ee65ddbc10201d
1 #!/bin/sh
3 test_description='test automatic tag following'
5 . ./test-lib.sh
7 if ! test_have_prereq NOT_MINGW; then
8 say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
9 fi
11 # End state of the repository:
13 # T - tag1 S - tag2
14 # / /
15 # L - A ------ O ------ B
16 # \ \ \
17 # \ C - origin/cat \
18 # origin/master master
20 test_expect_success NOT_MINGW setup '
21 test_tick &&
22 echo ichi >file &&
23 git add file &&
24 git commit -m L &&
25 L=$(git rev-parse --verify HEAD) &&
28 mkdir cloned &&
29 cd cloned &&
30 git init-db &&
31 git remote add -f origin ..
32 ) &&
34 test_tick &&
35 echo A >file &&
36 git add file &&
37 git commit -m A &&
38 A=$(git rev-parse --verify HEAD)
41 U=UPLOAD_LOG
43 test_expect_success NOT_MINGW 'setup expect' '
44 cat - <<EOF >expect
46 want $A
48 EOF
51 test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
52 rm -f $U &&
54 cd cloned &&
55 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
56 test $A = $(git rev-parse --verify origin/master)
57 ) &&
58 test -s $U &&
59 cut -d" " -f1,2 $U >actual &&
60 test_cmp expect actual
63 test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
64 git tag -a -m tag1 tag1 $A &&
65 T=$(git rev-parse --verify tag1) &&
67 git checkout -b cat &&
68 echo C >file &&
69 git add file &&
70 git commit -m C &&
71 C=$(git rev-parse --verify HEAD) &&
72 git checkout master
75 test_expect_success NOT_MINGW 'setup expect' '
76 cat - <<EOF >expect
78 want $C
79 want $T
81 EOF
84 test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
85 rm -f $U &&
87 cd cloned &&
88 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
89 test $C = $(git rev-parse --verify origin/cat) &&
90 test $T = $(git rev-parse --verify tag1) &&
91 test $A = $(git rev-parse --verify tag1^0)
92 ) &&
93 test -s $U &&
94 cut -d" " -f1,2 $U >actual &&
95 test_cmp expect actual
98 test_expect_success NOT_MINGW "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 NOT_MINGW 'setup expect' '
115 cat - <<EOF >expect
117 want $B
118 want $S
123 test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
124 rm -f $U &&
126 cd cloned &&
127 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
128 test $B = $(git rev-parse --verify origin/master) &&
129 test $B = $(git rev-parse --verify tag2^0) &&
130 test $S = $(git rev-parse --verify tag2)
131 ) &&
132 test -s $U &&
133 cut -d" " -f1,2 $U >actual &&
134 test_cmp expect actual
137 test_expect_success NOT_MINGW 'setup expect' '
138 cat - <<EOF >expect
140 want $B
141 want $S
146 test_expect_success NOT_MINGW 'new clone fetch master and tags' '
147 git branch -D cat
148 rm -f $U
150 mkdir clone2 &&
151 cd clone2 &&
152 git init &&
153 git remote add origin .. &&
154 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
155 test $B = $(git rev-parse --verify origin/master) &&
156 test $S = $(git rev-parse --verify tag2) &&
157 test $B = $(git rev-parse --verify tag2^0) &&
158 test $T = $(git rev-parse --verify tag1) &&
159 test $A = $(git rev-parse --verify tag1^0)
160 ) &&
161 test -s $U &&
162 cut -d" " -f1,2 $U >actual &&
163 test_cmp expect actual
166 test_done