archive: move parameter parsing code to archive.c
[git/jnareb-git/bp-gitweb.git] / t / t5503-tagfollow.sh
blob4074e23ffa2c7a93fdbd4a367e273118224b9038
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
39 cat - <<EOF >expect
41 want $A
43 EOF
44 test_expect_success 'fetch A (new commit : 1 connection)' '
45 rm -f $U
47 cd cloned &&
48 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
49 test $A = $(git rev-parse --verify origin/master)
50 ) &&
51 test -s $U &&
52 cut -d" " -f1,2 $U >actual &&
53 test_cmp expect actual
56 test_expect_success "create tag T on A, create C on branch cat" '
57 git tag -a -m tag1 tag1 $A &&
58 T=$(git rev-parse --verify tag1) &&
60 git checkout -b cat &&
61 echo C >file &&
62 git add file &&
63 git commit -m C &&
64 C=$(git rev-parse --verify HEAD) &&
65 git checkout master
68 cat - <<EOF >expect
70 want $C
71 want $T
73 EOF
74 test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
75 rm -f $U
77 cd cloned &&
78 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
79 test $C = $(git rev-parse --verify origin/cat) &&
80 test $T = $(git rev-parse --verify tag1) &&
81 test $A = $(git rev-parse --verify tag1^0)
82 ) &&
83 test -s $U &&
84 cut -d" " -f1,2 $U >actual &&
85 test_cmp expect actual
88 test_expect_success "create commits O, B, tag S on B" '
89 test_tick &&
90 echo O >file &&
91 git add file &&
92 git commit -m O &&
94 test_tick &&
95 echo B >file &&
96 git add file &&
97 git commit -m B &&
98 B=$(git rev-parse --verify HEAD) &&
100 git tag -a -m tag2 tag2 $B &&
101 S=$(git rev-parse --verify tag2)
104 cat - <<EOF >expect
106 want $B
107 want $S
110 test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
111 rm -f $U
113 cd cloned &&
114 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
115 test $B = $(git rev-parse --verify origin/master) &&
116 test $B = $(git rev-parse --verify tag2^0) &&
117 test $S = $(git rev-parse --verify tag2)
118 ) &&
119 test -s $U &&
120 cut -d" " -f1,2 $U >actual &&
121 test_cmp expect actual
124 cat - <<EOF >expect
126 want $B
127 want $S
130 test_expect_success 'new clone fetch master and tags' '
131 git branch -D cat
132 rm -f $U
134 mkdir clone2 &&
135 cd clone2 &&
136 git init &&
137 git remote add origin .. &&
138 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
139 test $B = $(git rev-parse --verify origin/master) &&
140 test $S = $(git rev-parse --verify tag2) &&
141 test $B = $(git rev-parse --verify tag2^0) &&
142 test $T = $(git rev-parse --verify tag1) &&
143 test $A = $(git rev-parse --verify tag1^0)
144 ) &&
145 test -s $U &&
146 cut -d" " -f1,2 $U >actual &&
147 test_cmp expect actual
150 test_done