]> rtime.felk.cvut.cz Git - git.git/blob - t/t5503-tagfollow.sh
t5503: GIT_DEBUG_SEND_PACK is not supported on MinGW
[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         test_done
11         exit
12 esac
13
14 # End state of the repository:
15 #
16 #         T - tag1          S - tag2
17 #        /                 /
18 #   L - A ------ O ------ B
19 #    \   \                 \
20 #     \   C - origin/cat    \
21 #      origin/master         master
22
23 test_expect_success setup '
24         test_tick &&
25         echo ichi >file &&
26         git add file &&
27         git commit -m L &&
28         L=$(git rev-parse --verify HEAD) &&
29
30         (
31                 mkdir cloned &&
32                 cd cloned &&
33                 git init-db &&
34                 git remote add -f origin ..
35         ) &&
36
37         test_tick &&
38         echo A >file &&
39         git add file &&
40         git commit -m A &&
41         A=$(git rev-parse --verify HEAD)
42 '
43
44 U=UPLOAD_LOG
45
46 cat - <<EOF >expect
47 #S
48 want $A
49 #E
50 EOF
51 test_expect_success 'fetch A (new commit : 1 connection)' '
52         rm -f $U
53         (
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
61 '
62
63 test_expect_success "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) &&
66
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
73 '
74
75 cat - <<EOF >expect
76 #S
77 want $C
78 want $T
79 #E
80 EOF
81 test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
82         rm -f $U
83         (
84                 cd cloned &&
85                 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
86                 test $C = $(git rev-parse --verify origin/cat) &&
87                 test $T = $(git rev-parse --verify tag1) &&
88                 test $A = $(git rev-parse --verify tag1^0)
89         ) &&
90         test -s $U &&
91         cut -d" " -f1,2 $U >actual &&
92         test_cmp expect actual
93 '
94
95 test_expect_success "create commits O, B, tag S on B" '
96         test_tick &&
97         echo O >file &&
98         git add file &&
99         git commit -m O &&
100
101         test_tick &&
102         echo B >file &&
103         git add file &&
104         git commit -m B &&
105         B=$(git rev-parse --verify HEAD) &&
106
107         git tag -a -m tag2 tag2 $B &&
108         S=$(git rev-parse --verify tag2)
109 '
110
111 cat - <<EOF >expect
112 #S
113 want $B
114 want $S
115 #E
116 EOF
117 test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
118         rm -f $U
119         (
120                 cd cloned &&
121                 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
122                 test $B = $(git rev-parse --verify origin/master) &&
123                 test $B = $(git rev-parse --verify tag2^0) &&
124                 test $S = $(git rev-parse --verify tag2)
125         ) &&
126         test -s $U &&
127         cut -d" " -f1,2 $U >actual &&
128         test_cmp expect actual
129 '
130
131 cat - <<EOF >expect
132 #S
133 want $B
134 want $S
135 #E
136 EOF
137 test_expect_success 'new clone fetch master and tags' '
138         git branch -D cat
139         rm -f $U
140         (
141                 mkdir clone2 &&
142                 cd clone2 &&
143                 git init &&
144                 git remote add origin .. &&
145                 GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
146                 test $B = $(git rev-parse --verify origin/master) &&
147                 test $S = $(git rev-parse --verify tag2) &&
148                 test $B = $(git rev-parse --verify tag2^0) &&
149                 test $T = $(git rev-parse --verify tag1) &&
150                 test $A = $(git rev-parse --verify tag1^0)
151         ) &&
152         test -s $U &&
153         cut -d" " -f1,2 $U >actual &&
154         test_cmp expect actual
155 '
156
157 test_done