wrap git's main usage string.
[alt-git.git] / t / t5503-tagfollow.sh
blobd5db75d826c8584e1d7f0f5ef298021fecd6f055
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"
10 test_done
11 esac
13 # End state of the repository:
15 # T - tag1 S - tag2
16 # / /
17 # L - A ------ O ------ B
18 # \ \ \
19 # \ C - origin/cat \
20 # origin/master master
22 test_expect_success setup '
23 test_tick &&
24 echo ichi >file &&
25 git add file &&
26 git commit -m L &&
27 L=$(git rev-parse --verify HEAD) &&
30 mkdir cloned &&
31 cd cloned &&
32 git init-db &&
33 git remote add -f origin ..
34 ) &&
36 test_tick &&
37 echo A >file &&
38 git add file &&
39 git commit -m A &&
40 A=$(git rev-parse --verify HEAD)
43 U=UPLOAD_LOG
45 cat - <<EOF >expect
47 want $A
49 EOF
50 test_expect_success 'fetch A (new commit : 1 connection)' '
51 rm -f $U
53 cd cloned &&
54 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
55 test $A = $(git rev-parse --verify origin/master)
56 ) &&
57 test -s $U &&
58 cut -d" " -f1,2 $U >actual &&
59 test_cmp expect actual
62 test_expect_success "create tag T on A, create C on branch cat" '
63 git tag -a -m tag1 tag1 $A &&
64 T=$(git rev-parse --verify tag1) &&
66 git checkout -b cat &&
67 echo C >file &&
68 git add file &&
69 git commit -m C &&
70 C=$(git rev-parse --verify HEAD) &&
71 git checkout master
74 cat - <<EOF >expect
76 want $C
77 want $T
79 EOF
80 test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
81 rm -f $U
83 cd cloned &&
84 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
85 test $C = $(git rev-parse --verify origin/cat) &&
86 test $T = $(git rev-parse --verify tag1) &&
87 test $A = $(git rev-parse --verify tag1^0)
88 ) &&
89 test -s $U &&
90 cut -d" " -f1,2 $U >actual &&
91 test_cmp expect actual
94 test_expect_success "create commits O, B, tag S on B" '
95 test_tick &&
96 echo O >file &&
97 git add file &&
98 git commit -m O &&
100 test_tick &&
101 echo B >file &&
102 git add file &&
103 git commit -m B &&
104 B=$(git rev-parse --verify HEAD) &&
106 git tag -a -m tag2 tag2 $B &&
107 S=$(git rev-parse --verify tag2)
110 cat - <<EOF >expect
112 want $B
113 want $S
116 test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
117 rm -f $U
119 cd cloned &&
120 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
121 test $B = $(git rev-parse --verify origin/master) &&
122 test $B = $(git rev-parse --verify tag2^0) &&
123 test $S = $(git rev-parse --verify tag2)
124 ) &&
125 test -s $U &&
126 cut -d" " -f1,2 $U >actual &&
127 test_cmp expect actual
130 cat - <<EOF >expect
132 want $B
133 want $S
136 test_expect_success 'new clone fetch master and tags' '
137 git branch -D cat
138 rm -f $U
140 mkdir clone2 &&
141 cd clone2 &&
142 git init &&
143 git remote add origin .. &&
144 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
145 test $B = $(git rev-parse --verify origin/master) &&
146 test $S = $(git rev-parse --verify tag2) &&
147 test $B = $(git rev-parse --verify tag2^0) &&
148 test $T = $(git rev-parse --verify tag1) &&
149 test $A = $(git rev-parse --verify tag1^0)
150 ) &&
151 test -s $U &&
152 cut -d" " -f1,2 $U >actual &&
153 test_cmp expect actual
156 test_done