]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5612-clone-refspec.sh
remote: add camel-cased *.tagOpt key, like clone
[thirdparty/git.git] / t / t5612-clone-refspec.sh
1 #!/bin/sh
2
3 test_description='test refspec written by clone-command'
4 . ./test-lib.sh
5
6 test_expect_success 'setup' '
7 # Make two branches, "master" and "side"
8 echo one >file &&
9 git add file &&
10 git commit -m one &&
11 echo two >file &&
12 git commit -a -m two &&
13 git tag two &&
14 echo three >file &&
15 git commit -a -m three &&
16 git checkout -b side &&
17 echo four >file &&
18 git commit -a -m four &&
19 git checkout master &&
20 git tag five &&
21
22 # default clone
23 git clone . dir_all &&
24
25 # default clone --no-tags
26 git clone --no-tags . dir_all_no_tags &&
27
28 # default --single that follows HEAD=master
29 git clone --single-branch . dir_master &&
30
31 # default --single that follows HEAD=master with no tags
32 git clone --single-branch --no-tags . dir_master_no_tags &&
33
34 # default --single that follows HEAD=side
35 git checkout side &&
36 git clone --single-branch . dir_side &&
37
38 # explicit --single that follows side
39 git checkout master &&
40 git clone --single-branch --branch side . dir_side2 &&
41
42 # default --single with --mirror
43 git clone --single-branch --mirror . dir_mirror &&
44
45 # default --single with --branch and --mirror
46 git clone --single-branch --mirror --branch side . dir_mirror_side &&
47
48 # --single that does not know what branch to follow
49 git checkout two^ &&
50 git clone --single-branch . dir_detached &&
51
52 # explicit --single with tag
53 git clone --single-branch --branch two . dir_tag &&
54
55 # explicit --single with tag and --no-tags
56 git clone --single-branch --no-tags --branch two . dir_tag_no_tags &&
57
58 # advance both "master" and "side" branches
59 git checkout side &&
60 echo five >file &&
61 git commit -a -m five &&
62 git checkout master &&
63 echo six >file &&
64 git commit -a -m six &&
65
66 # update tag
67 git tag -d two && git tag two
68 '
69
70 test_expect_success 'by default all branches will be kept updated' '
71 (
72 cd dir_all &&
73 git fetch &&
74 git for-each-ref refs/remotes/origin >refs &&
75 sed -e "/HEAD$/d" \
76 -e "s|/remotes/origin/|/heads/|" refs >../actual
77 ) &&
78 # follow both master and side
79 git for-each-ref refs/heads >expect &&
80 test_cmp expect actual
81 '
82
83 test_expect_success 'by default no tags will be kept updated' '
84 (
85 cd dir_all &&
86 git fetch &&
87 git for-each-ref refs/tags >../actual
88 ) &&
89 git for-each-ref refs/tags >expect &&
90 ! test_cmp expect actual &&
91 test_line_count = 2 actual
92 '
93
94 test_expect_success 'clone with --no-tags' '
95 (
96 cd dir_all_no_tags &&
97 grep tagOpt .git/config &&
98 git fetch &&
99 git for-each-ref refs/tags >../actual
100 ) &&
101 test_must_be_empty actual
102 '
103
104 test_expect_success '--single-branch while HEAD pointing at master' '
105 (
106 cd dir_master &&
107 git fetch --force &&
108 git for-each-ref refs/remotes/origin >refs &&
109 sed -e "/HEAD$/d" \
110 -e "s|/remotes/origin/|/heads/|" refs >../actual
111 ) &&
112 # only follow master
113 git for-each-ref refs/heads/master >expect &&
114 # get & check latest tags
115 test_cmp expect actual &&
116 (
117 cd dir_master &&
118 git fetch --tags --force &&
119 git for-each-ref refs/tags >../actual
120 ) &&
121 git for-each-ref refs/tags >expect &&
122 test_cmp expect actual &&
123 test_line_count = 2 actual
124 '
125
126 test_expect_success '--single-branch while HEAD pointing at master and --no-tags' '
127 (
128 cd dir_master_no_tags &&
129 git fetch &&
130 git for-each-ref refs/remotes/origin >refs &&
131 sed -e "/HEAD$/d" \
132 -e "s|/remotes/origin/|/heads/|" refs >../actual
133 ) &&
134 # only follow master
135 git for-each-ref refs/heads/master >expect &&
136 test_cmp expect actual &&
137 # get tags (noop)
138 (
139 cd dir_master_no_tags &&
140 git fetch &&
141 git for-each-ref refs/tags >../actual
142 ) &&
143 test_must_be_empty actual &&
144 test_line_count = 0 actual &&
145 # get tags with --tags overrides tagOpt
146 (
147 cd dir_master_no_tags &&
148 git fetch --tags &&
149 git for-each-ref refs/tags >../actual
150 ) &&
151 git for-each-ref refs/tags >expect &&
152 test_cmp expect actual &&
153 test_line_count = 2 actual
154 '
155
156 test_expect_success '--single-branch while HEAD pointing at side' '
157 (
158 cd dir_side &&
159 git fetch &&
160 git for-each-ref refs/remotes/origin >refs &&
161 sed -e "/HEAD$/d" \
162 -e "s|/remotes/origin/|/heads/|" refs >../actual
163 ) &&
164 # only follow side
165 git for-each-ref refs/heads/side >expect &&
166 test_cmp expect actual
167 '
168
169 test_expect_success '--single-branch with explicit --branch side' '
170 (
171 cd dir_side2 &&
172 git fetch &&
173 git for-each-ref refs/remotes/origin >refs &&
174 sed -e "/HEAD$/d" \
175 -e "s|/remotes/origin/|/heads/|" refs >../actual
176 ) &&
177 # only follow side
178 git for-each-ref refs/heads/side >expect &&
179 test_cmp expect actual
180 '
181
182 test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '
183 (
184 cd dir_tag &&
185 git fetch &&
186 git for-each-ref refs/tags >../actual
187 ) &&
188 git for-each-ref refs/tags >expect &&
189 test_cmp expect actual
190 '
191
192 test_expect_success '--single-branch with explicit --branch with tag fetches updated tag despite --no-tags' '
193 (
194 cd dir_tag_no_tags &&
195 git fetch &&
196 git for-each-ref refs/tags >../actual
197 ) &&
198 git for-each-ref refs/tags/two >expect &&
199 test_cmp expect actual &&
200 test_line_count = 1 actual
201 '
202
203 test_expect_success '--single-branch with --mirror' '
204 (
205 cd dir_mirror &&
206 git fetch &&
207 git for-each-ref refs > ../actual
208 ) &&
209 git for-each-ref refs >expect &&
210 test_cmp expect actual
211 '
212
213 test_expect_success '--single-branch with explicit --branch and --mirror' '
214 (
215 cd dir_mirror_side &&
216 git fetch &&
217 git for-each-ref refs > ../actual
218 ) &&
219 git for-each-ref refs >expect &&
220 test_cmp expect actual
221 '
222
223 test_expect_success '--single-branch with detached' '
224 (
225 cd dir_detached &&
226 git fetch &&
227 git for-each-ref refs/remotes/origin >refs &&
228 sed -e "/HEAD$/d" \
229 -e "s|/remotes/origin/|/heads/|" refs >../actual
230 ) &&
231 # nothing
232 test_must_be_empty actual
233 '
234
235 test_done