]>
Commit | Line | Data |
---|---|---|
a3b427b9 AW |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Amos Waterland | |
4 | # | |
5 | ||
c2d17ba3 | 6 | test_description='git branch assorted tests' |
a3b427b9 | 7 | |
a3b427b9 AW |
8 | . ./test-lib.sh |
9 | ||
0d158ebb RR |
10 | test_expect_success 'prepare a trivial repository' ' |
11 | echo Hello >A && | |
12 | git update-index --add A && | |
13 | git commit -m "Initial commit." && | |
14 | echo World >>A && | |
15 | git update-index --add A && | |
16 | git commit -m "Second commit." && | |
140cd845 FC |
17 | HEAD=$(git rev-parse --verify HEAD) |
18 | ' | |
0d158ebb RR |
19 | |
20 | test_expect_success 'git branch --help should not have created a bogus branch' ' | |
01e8d327 | 21 | test_might_fail git branch --man --help </dev/null >/dev/null 2>&1 && |
0d158ebb | 22 | test_path_is_missing .git/refs/heads/--help |
41ac414e | 23 | ' |
a3b427b9 | 24 | |
1dacfbcf NTND |
25 | test_expect_success 'branch -h in broken repository' ' |
26 | mkdir broken && | |
27 | ( | |
28 | cd broken && | |
29 | git init && | |
30 | >.git/refs/heads/master && | |
31 | test_expect_code 129 git branch -h >usage 2>&1 | |
32 | ) && | |
9a001381 | 33 | test_i18ngrep "[Uu]sage" broken/usage |
1dacfbcf NTND |
34 | ' |
35 | ||
0d158ebb RR |
36 | test_expect_success 'git branch abc should create a branch' ' |
37 | git branch abc && test_path_is_file .git/refs/heads/abc | |
38 | ' | |
08db81a9 | 39 | |
0d158ebb RR |
40 | test_expect_success 'git branch a/b/c should create a branch' ' |
41 | git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c | |
42 | ' | |
08db81a9 | 43 | |
0cb24fe8 JH |
44 | test_expect_success 'git branch HEAD should fail' ' |
45 | test_must_fail git branch HEAD | |
46 | ' | |
8efb8899 | 47 | |
d7fb7a37 | 48 | cat >expect <<EOF |
3749fde5 | 49 | $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master |
d7fb7a37 | 50 | EOF |
0d158ebb RR |
51 | test_expect_success 'git branch -l d/e/f should create a branch and a log' ' |
52 | GIT_COMMITTER_DATE="2005-05-26 23:30" \ | |
53 | git branch -l d/e/f && | |
54 | test_path_is_file .git/refs/heads/d/e/f && | |
55 | test_path_is_file .git/logs/refs/heads/d/e/f && | |
56 | test_cmp expect .git/logs/refs/heads/d/e/f | |
57 | ' | |
58 | ||
59 | test_expect_success 'git branch -d d/e/f should delete a branch and a log' ' | |
60 | git branch -d d/e/f && | |
61 | test_path_is_missing .git/refs/heads/d/e/f && | |
d0ab0584 | 62 | test_must_fail git reflog exists refs/heads/d/e/f |
0d158ebb RR |
63 | ' |
64 | ||
65 | test_expect_success 'git branch j/k should work after branch j has been deleted' ' | |
66 | git branch j && | |
67 | git branch -d j && | |
68 | git branch j/k | |
69 | ' | |
70 | ||
71 | test_expect_success 'git branch l should work after branch l/m has been deleted' ' | |
72 | git branch l/m && | |
73 | git branch -d l/m && | |
74 | git branch l | |
75 | ' | |
76 | ||
77 | test_expect_success 'git branch -m dumps usage' ' | |
78 | test_expect_code 128 git branch -m 2>err && | |
8054b9a6 | 79 | test_i18ngrep "branch name required" err |
0d158ebb RR |
80 | ' |
81 | ||
12fd3496 DT |
82 | test_expect_success 'git branch -m m broken_symref should work' ' |
83 | test_when_finished "git branch -D broken_symref" && | |
84 | git branch -l m && | |
85 | git symbolic-ref refs/heads/broken_symref refs/heads/i_am_broken && | |
86 | git branch -m m broken_symref && | |
87 | git reflog exists refs/heads/broken_symref && | |
88 | test_must_fail git reflog exists refs/heads/i_am_broken | |
89 | ' | |
90 | ||
0d158ebb RR |
91 | test_expect_success 'git branch -m m m/m should work' ' |
92 | git branch -l m && | |
93 | git branch -m m m/m && | |
d0ab0584 | 94 | git reflog exists refs/heads/m/m |
0d158ebb RR |
95 | ' |
96 | ||
97 | test_expect_success 'git branch -m n/n n should work' ' | |
98 | git branch -l n/n && | |
2f139044 | 99 | git branch -m n/n n && |
d0ab0584 | 100 | git reflog exists refs/heads/n |
0d158ebb | 101 | ' |
c976d415 | 102 | |
bb8efa17 SD |
103 | # The topmost entry in reflog for branch bbb is about branch creation. |
104 | # Hence, we compare bbb@{1} (instead of bbb@{0}) with aaa@{0}. | |
105 | ||
106 | test_expect_success 'git branch -m bbb should rename checked out branch' ' | |
107 | test_when_finished git branch -D bbb && | |
108 | test_when_finished git checkout master && | |
109 | git checkout -b aaa && | |
110 | git commit --allow-empty -m "a new commit" && | |
111 | git rev-parse aaa@{0} >expect && | |
112 | git branch -m bbb && | |
113 | git rev-parse bbb@{1} >actual && | |
114 | test_cmp expect actual && | |
115 | git symbolic-ref HEAD >actual && | |
116 | echo refs/heads/bbb >expect && | |
117 | test_cmp expect actual | |
118 | ' | |
119 | ||
41ac414e JH |
120 | test_expect_success 'git branch -m o/o o should fail when o/p exists' ' |
121 | git branch o/o && | |
0d158ebb | 122 | git branch o/p && |
d492b31c | 123 | test_must_fail git branch -m o/o o |
41ac414e | 124 | ' |
c976d415 | 125 | |
ff7aa81f MG |
126 | test_expect_success 'git branch -m o/q o/p should fail when o/p exists' ' |
127 | git branch o/q && | |
128 | test_must_fail git branch -m o/q o/p | |
129 | ' | |
130 | ||
131 | test_expect_success 'git branch -M o/q o/p should work when o/p exists' ' | |
132 | git branch -M o/q o/p | |
133 | ' | |
134 | ||
356e91f2 MG |
135 | test_expect_success 'git branch -m -f o/q o/p should work when o/p exists' ' |
136 | git branch o/q && | |
137 | git branch -m -f o/q o/p | |
138 | ' | |
139 | ||
41ac414e JH |
140 | test_expect_success 'git branch -m q r/q should fail when r exists' ' |
141 | git branch q && | |
142 | git branch r && | |
d492b31c | 143 | test_must_fail git branch -m q r/q |
41ac414e | 144 | ' |
c976d415 | 145 | |
55c4a673 CI |
146 | test_expect_success 'git branch -M foo bar should fail when bar is checked out' ' |
147 | git branch bar && | |
148 | git checkout -b foo && | |
149 | test_must_fail git branch -M bar foo | |
150 | ' | |
151 | ||
152 | test_expect_success 'git branch -M baz bam should succeed when baz is checked out' ' | |
153 | git checkout -b baz && | |
154 | git branch bam && | |
70999e9c KY |
155 | git branch -M baz bam && |
156 | test $(git rev-parse --abbrev-ref HEAD) = bam | |
157 | ' | |
158 | ||
39ee4c6c | 159 | test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' ' |
893dbf5b | 160 | msg="Branch: renamed refs/heads/baz to refs/heads/bam" && |
39ee4c6c KM |
161 | grep " 0\{40\}.*$msg$" .git/logs/HEAD && |
162 | grep "^0\{40\}.*$msg$" .git/logs/HEAD | |
893dbf5b KM |
163 | ' |
164 | ||
2272d3e5 JK |
165 | test_expect_success 'resulting reflog can be shown by log -g' ' |
166 | oid=$(git rev-parse HEAD) && | |
167 | cat >expect <<-EOF && | |
168 | HEAD@{0} $oid $msg | |
2272d3e5 JK |
169 | HEAD@{2} $oid checkout: moving from foo to baz |
170 | EOF | |
d08565bf | 171 | git log -g --format="%gd %H %gs" -2 HEAD >actual && |
2272d3e5 JK |
172 | test_cmp expect actual |
173 | ' | |
174 | ||
70999e9c KY |
175 | test_expect_success 'git branch -M baz bam should succeed when baz is checked out as linked working tree' ' |
176 | git checkout master && | |
177 | git worktree add -b baz bazdir && | |
178 | git worktree add -f bazdir2 baz && | |
179 | git branch -M baz bam && | |
180 | test $(git -C bazdir rev-parse --abbrev-ref HEAD) = bam && | |
181 | test $(git -C bazdir2 rev-parse --abbrev-ref HEAD) = bam | |
182 | ' | |
183 | ||
184 | test_expect_success 'git branch -M baz bam should succeed within a worktree in which baz is checked out' ' | |
185 | git checkout -b baz && | |
186 | git worktree add -f bazdir3 baz && | |
187 | ( | |
188 | cd bazdir3 && | |
189 | git branch -M baz bam && | |
190 | test $(git rev-parse --abbrev-ref HEAD) = bam | |
191 | ) && | |
192 | test $(git rev-parse --abbrev-ref HEAD) = bam | |
55c4a673 CI |
193 | ' |
194 | ||
3f59481e JN |
195 | test_expect_success 'git branch -M master should work when master is checked out' ' |
196 | git checkout master && | |
197 | git branch -M master | |
198 | ' | |
199 | ||
200 | test_expect_success 'git branch -M master master should work when master is checked out' ' | |
201 | git checkout master && | |
202 | git branch -M master master | |
203 | ' | |
204 | ||
205 | test_expect_success 'git branch -M master2 master2 should work when master is checked out' ' | |
206 | git checkout master && | |
207 | git branch master2 && | |
208 | git branch -M master2 master2 | |
209 | ' | |
210 | ||
cddd127b MG |
211 | test_expect_success 'git branch -v -d t should work' ' |
212 | git branch t && | |
376eb14a | 213 | test_path_is_file .git/refs/heads/t && |
cddd127b | 214 | git branch -v -d t && |
376eb14a | 215 | test_path_is_missing .git/refs/heads/t |
cddd127b MG |
216 | ' |
217 | ||
218 | test_expect_success 'git branch -v -m t s should work' ' | |
219 | git branch t && | |
376eb14a | 220 | test_path_is_file .git/refs/heads/t && |
cddd127b | 221 | git branch -v -m t s && |
376eb14a JK |
222 | test_path_is_missing .git/refs/heads/t && |
223 | test_path_is_file .git/refs/heads/s && | |
cddd127b MG |
224 | git branch -d s |
225 | ' | |
226 | ||
227 | test_expect_success 'git branch -m -d t s should fail' ' | |
228 | git branch t && | |
376eb14a | 229 | test_path_is_file .git/refs/heads/t && |
cddd127b MG |
230 | test_must_fail git branch -m -d t s && |
231 | git branch -d t && | |
376eb14a | 232 | test_path_is_missing .git/refs/heads/t |
cddd127b MG |
233 | ' |
234 | ||
235 | test_expect_success 'git branch --list -d t should fail' ' | |
236 | git branch t && | |
376eb14a | 237 | test_path_is_file .git/refs/heads/t && |
cddd127b MG |
238 | test_must_fail git branch --list -d t && |
239 | git branch -d t && | |
376eb14a | 240 | test_path_is_missing .git/refs/heads/t |
cddd127b MG |
241 | ' |
242 | ||
ac5bbc02 JH |
243 | test_expect_success 'git branch --list -v with --abbrev' ' |
244 | test_when_finished "git branch -D t" && | |
245 | git branch t && | |
246 | git branch -v --list t >actual.default && | |
247 | git branch -v --list --abbrev t >actual.abbrev && | |
248 | test_cmp actual.default actual.abbrev && | |
249 | ||
250 | git branch -v --list --no-abbrev t >actual.noabbrev && | |
251 | git branch -v --list --abbrev=0 t >actual.0abbrev && | |
252 | test_cmp actual.noabbrev actual.0abbrev && | |
253 | ||
254 | git branch -v --list --abbrev=36 t >actual.36abbrev && | |
255 | # how many hexdigits are used? | |
256 | read name objdefault rest <actual.abbrev && | |
257 | read name obj36 rest <actual.36abbrev && | |
258 | objfull=$(git rev-parse --verify t) && | |
259 | ||
260 | # are we really getting abbreviations? | |
261 | test "$obj36" != "$objdefault" && | |
262 | expr "$obj36" : "$objdefault" >/dev/null && | |
263 | test "$objfull" != "$obj36" && | |
264 | expr "$objfull" : "$obj36" >/dev/null | |
265 | ||
266 | ' | |
267 | ||
ebe31ef2 NTND |
268 | test_expect_success 'git branch --column' ' |
269 | COLUMNS=81 git branch --column=column >actual && | |
270 | cat >expected <<\EOF && | |
271 | a/b/c bam foo l * master n o/p r | |
272 | abc bar j/k m/m master2 o/o q | |
273 | EOF | |
274 | test_cmp expected actual | |
275 | ' | |
276 | ||
277 | test_expect_success 'git branch --column with an extremely long branch name' ' | |
278 | long=this/is/a/part/of/long/branch/name && | |
279 | long=z$long/$long/$long/$long && | |
280 | test_when_finished "git branch -d $long" && | |
281 | git branch $long && | |
282 | COLUMNS=80 git branch --column=column >actual && | |
283 | cat >expected <<EOF && | |
284 | a/b/c | |
285 | abc | |
286 | bam | |
287 | bar | |
288 | foo | |
289 | j/k | |
290 | l | |
291 | m/m | |
292 | * master | |
293 | master2 | |
294 | n | |
295 | o/o | |
296 | o/p | |
297 | q | |
298 | r | |
299 | $long | |
300 | EOF | |
301 | test_cmp expected actual | |
302 | ' | |
303 | ||
304 | test_expect_success 'git branch with column.*' ' | |
305 | git config column.ui column && | |
306 | git config column.branch "dense" && | |
307 | COLUMNS=80 git branch >actual && | |
308 | git config --unset column.branch && | |
309 | git config --unset column.ui && | |
310 | cat >expected <<\EOF && | |
311 | a/b/c bam foo l * master n o/p r | |
312 | abc bar j/k m/m master2 o/o q | |
313 | EOF | |
314 | test_cmp expected actual | |
315 | ' | |
316 | ||
317 | test_expect_success 'git branch --column -v should fail' ' | |
318 | test_must_fail git branch --column -v | |
319 | ' | |
320 | ||
321 | test_expect_success 'git branch -v with column.ui ignored' ' | |
322 | git config column.ui column && | |
323 | COLUMNS=80 git branch -v | cut -c -10 | sed "s/ *$//" >actual && | |
324 | git config --unset column.ui && | |
325 | cat >expected <<\EOF && | |
326 | a/b/c | |
327 | abc | |
328 | bam | |
329 | bar | |
330 | foo | |
331 | j/k | |
332 | l | |
333 | m/m | |
334 | * master | |
335 | master2 | |
336 | n | |
337 | o/o | |
338 | o/p | |
339 | q | |
340 | r | |
341 | EOF | |
342 | test_cmp expected actual | |
343 | ' | |
344 | ||
01ebb9dc GB |
345 | mv .git/config .git/config-saved |
346 | ||
08b984fb | 347 | test_expect_success 'git branch -m q q2 without config should succeed' ' |
5be60078 JH |
348 | git branch -m q q2 && |
349 | git branch -m q2 q | |
01ebb9dc GB |
350 | ' |
351 | ||
352 | mv .git/config-saved .git/config | |
353 | ||
5be60078 | 354 | git config branch.s/s.dummy Hello |
dc81c58c | 355 | |
0d158ebb RR |
356 | test_expect_success 'git branch -m s/s s should work when s/t is deleted' ' |
357 | git branch -l s/s && | |
d0ab0584 | 358 | git reflog exists refs/heads/s/s && |
0d158ebb | 359 | git branch -l s/t && |
d0ab0584 | 360 | git reflog exists refs/heads/s/t && |
0d158ebb RR |
361 | git branch -d s/t && |
362 | git branch -m s/s s && | |
d0ab0584 | 363 | git reflog exists refs/heads/s |
0d158ebb | 364 | ' |
c976d415 | 365 | |
0d158ebb RR |
366 | test_expect_success 'config information was renamed, too' ' |
367 | test $(git config branch.s.dummy) = Hello && | |
b8f354f2 | 368 | test_must_fail git config branch.s/s.dummy |
0d158ebb | 369 | ' |
dc81c58c | 370 | |
566c7707 RS |
371 | test_expect_success 'deleting a symref' ' |
372 | git branch target && | |
373 | git symbolic-ref refs/heads/symref refs/heads/target && | |
13baa9fe | 374 | echo "Deleted branch symref (was refs/heads/target)." >expect && |
566c7707 RS |
375 | git branch -d symref >actual && |
376 | test_path_is_file .git/refs/heads/target && | |
377 | test_path_is_missing .git/refs/heads/symref && | |
378 | test_i18ncmp expect actual | |
379 | ' | |
380 | ||
0fe700e3 RS |
381 | test_expect_success 'deleting a dangling symref' ' |
382 | git symbolic-ref refs/heads/dangling-symref nowhere && | |
383 | test_path_is_file .git/refs/heads/dangling-symref && | |
13baa9fe | 384 | echo "Deleted branch dangling-symref (was nowhere)." >expect && |
0fe700e3 RS |
385 | git branch -d dangling-symref >actual && |
386 | test_path_is_missing .git/refs/heads/dangling-symref && | |
387 | test_i18ncmp expect actual | |
388 | ' | |
389 | ||
62a2d525 JN |
390 | test_expect_success 'deleting a self-referential symref' ' |
391 | git symbolic-ref refs/heads/self-reference refs/heads/self-reference && | |
392 | test_path_is_file .git/refs/heads/self-reference && | |
393 | echo "Deleted branch self-reference (was refs/heads/self-reference)." >expect && | |
394 | git branch -d self-reference >actual && | |
395 | test_path_is_missing .git/refs/heads/self-reference && | |
396 | test_i18ncmp expect actual | |
397 | ' | |
398 | ||
0d158ebb | 399 | test_expect_success 'renaming a symref is not allowed' ' |
eca35a25 | 400 | git symbolic-ref refs/heads/master2 refs/heads/master && |
fa58186c MV |
401 | test_must_fail git branch -m master2 master3 && |
402 | git symbolic-ref refs/heads/master2 && | |
376eb14a JK |
403 | test_path_is_file .git/refs/heads/master && |
404 | test_path_is_missing .git/refs/heads/master3 | |
eca35a25 MV |
405 | ' |
406 | ||
0d158ebb RR |
407 | test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' ' |
408 | git branch -l u && | |
409 | mv .git/logs/refs/heads/u real-u && | |
410 | ln -s real-u .git/logs/refs/heads/u && | |
411 | test_must_fail git branch -m u v | |
412 | ' | |
413 | ||
414 | test_expect_success 'test tracking setup via --track' ' | |
415 | git config remote.local.url . && | |
416 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
417 | (git show-ref -q refs/remotes/local/master || git fetch local) && | |
418 | git branch --track my1 local/master && | |
419 | test $(git config branch.my1.remote) = local && | |
420 | test $(git config branch.my1.merge) = refs/heads/master | |
421 | ' | |
422 | ||
423 | test_expect_success 'test tracking setup (non-wildcard, matching)' ' | |
424 | git config remote.local.url . && | |
425 | git config remote.local.fetch refs/heads/master:refs/remotes/local/master && | |
426 | (git show-ref -q refs/remotes/local/master || git fetch local) && | |
427 | git branch --track my4 local/master && | |
428 | test $(git config branch.my4.remote) = local && | |
429 | test $(git config branch.my4.merge) = refs/heads/master | |
430 | ' | |
431 | ||
41c21f22 | 432 | test_expect_success 'tracking setup fails on non-matching refspec' ' |
0d158ebb | 433 | git config remote.local.url . && |
81f339dc | 434 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && |
0d158ebb | 435 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
81f339dc | 436 | git config remote.local.fetch refs/heads/s:refs/remotes/local/s && |
9c9cd39a JH |
437 | test_must_fail git branch --track my5 local/master && |
438 | test_must_fail git config branch.my5.remote && | |
439 | test_must_fail git config branch.my5.merge | |
0d158ebb RR |
440 | ' |
441 | ||
442 | test_expect_success 'test tracking setup via config' ' | |
443 | git config branch.autosetupmerge true && | |
444 | git config remote.local.url . && | |
445 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
446 | (git show-ref -q refs/remotes/local/master || git fetch local) && | |
447 | git branch my3 local/master && | |
448 | test $(git config branch.my3.remote) = local && | |
449 | test $(git config branch.my3.merge) = refs/heads/master | |
450 | ' | |
451 | ||
452 | test_expect_success 'test overriding tracking setup via --no-track' ' | |
453 | git config branch.autosetupmerge true && | |
454 | git config remote.local.url . && | |
455 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
456 | (git show-ref -q refs/remotes/local/master || git fetch local) && | |
457 | git branch --no-track my2 local/master && | |
458 | git config branch.autosetupmerge false && | |
459 | ! test "$(git config branch.my2.remote)" = local && | |
460 | ! test "$(git config branch.my2.merge)" = refs/heads/master | |
461 | ' | |
462 | ||
463 | test_expect_success 'no tracking without .fetch entries' ' | |
464 | git config branch.autosetupmerge true && | |
465 | git branch my6 s && | |
002ba037 | 466 | git config branch.autosetupmerge false && |
0d158ebb RR |
467 | test -z "$(git config branch.my6.remote)" && |
468 | test -z "$(git config branch.my6.merge)" | |
469 | ' | |
470 | ||
471 | test_expect_success 'test tracking setup via --track but deeper' ' | |
472 | git config remote.local.url . && | |
473 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
474 | (git show-ref -q refs/remotes/local/o/o || git fetch local) && | |
475 | git branch --track my7 local/o/o && | |
476 | test "$(git config branch.my7.remote)" = local && | |
477 | test "$(git config branch.my7.merge)" = refs/heads/o/o | |
478 | ' | |
479 | ||
480 | test_expect_success 'test deleting branch deletes branch config' ' | |
481 | git branch -d my7 && | |
482 | test -z "$(git config branch.my7.remote)" && | |
483 | test -z "$(git config branch.my7.merge)" | |
484 | ' | |
485 | ||
486 | test_expect_success 'test deleting branch without config' ' | |
487 | git branch my7 s && | |
488 | sha1=$(git rev-parse my7 | cut -c 1-7) && | |
489 | echo "Deleted branch my7 (was $sha1)." >expect && | |
490 | git branch -d my7 >actual 2>&1 && | |
491 | test_i18ncmp expect actual | |
492 | ' | |
493 | ||
f292244c KY |
494 | test_expect_success 'deleting currently checked out branch fails' ' |
495 | git worktree add -b my7 my7 && | |
496 | test_must_fail git -C my7 branch -d my7 && | |
497 | test_must_fail git branch -d my7 | |
498 | ' | |
499 | ||
0d158ebb RR |
500 | test_expect_success 'test --track without .fetch entries' ' |
501 | git branch --track my8 && | |
502 | test "$(git config branch.my8.remote)" && | |
503 | test "$(git config branch.my8.merge)" | |
504 | ' | |
505 | ||
506 | test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' ' | |
507 | git config branch.autosetupmerge always && | |
508 | git branch my9 HEAD^ && | |
509 | git config branch.autosetupmerge false | |
510 | ' | |
511 | ||
512 | test_expect_success 'branch from non-branch HEAD w/--track causes failure' ' | |
513 | test_must_fail git branch --track my10 HEAD^ | |
514 | ' | |
515 | ||
516 | test_expect_success 'branch from tag w/--track causes failure' ' | |
517 | git tag foobar && | |
518 | test_must_fail git branch --track my11 foobar | |
519 | ' | |
520 | ||
0cb24fe8 JH |
521 | test_expect_success '--set-upstream-to fails on multiple branches' ' |
522 | test_must_fail git branch --set-upstream-to master a b c | |
523 | ' | |
524 | ||
525 | test_expect_success '--set-upstream-to fails on detached HEAD' ' | |
526 | git checkout HEAD^{} && | |
527 | test_must_fail git branch --set-upstream-to master && | |
528 | git checkout - | |
529 | ' | |
530 | ||
8a3e5ecd JK |
531 | test_expect_success '--set-upstream-to fails on a missing dst branch' ' |
532 | test_must_fail git branch --set-upstream-to master does-not-exist | |
533 | ' | |
534 | ||
535 | test_expect_success '--set-upstream-to fails on a missing src branch' ' | |
536 | test_must_fail git branch --set-upstream-to does-not-exist master | |
537 | ' | |
538 | ||
539 | test_expect_success '--set-upstream-to fails on a non-ref' ' | |
540 | test_must_fail git branch --set-upstream-to HEAD^{} | |
541 | ' | |
542 | ||
27852b2c PS |
543 | test_expect_success '--set-upstream-to fails on locked config' ' |
544 | test_when_finished "rm -f .git/config.lock" && | |
545 | >.git/config.lock && | |
546 | git branch locked && | |
547 | test_must_fail git branch --set-upstream-to locked | |
548 | ' | |
549 | ||
0d158ebb RR |
550 | test_expect_success 'use --set-upstream-to modify HEAD' ' |
551 | test_config branch.master.remote foo && | |
552 | test_config branch.master.merge foo && | |
d0423ddd | 553 | git branch my12 && |
0d158ebb RR |
554 | git branch --set-upstream-to my12 && |
555 | test "$(git config branch.master.remote)" = "." && | |
556 | test "$(git config branch.master.merge)" = "refs/heads/my12" | |
557 | ' | |
558 | ||
559 | test_expect_success 'use --set-upstream-to modify a particular branch' ' | |
d0423ddd | 560 | git branch my13 && |
0d158ebb | 561 | git branch --set-upstream-to master my13 && |
93a6b3f2 | 562 | test_when_finished "git branch --unset-upstream my13" && |
0d158ebb RR |
563 | test "$(git config branch.my13.remote)" = "." && |
564 | test "$(git config branch.my13.merge)" = "refs/heads/master" | |
565 | ' | |
566 | ||
567 | test_expect_success '--unset-upstream should fail if given a non-existent branch' ' | |
568 | test_must_fail git branch --unset-upstream i-dont-exist | |
569 | ' | |
570 | ||
b81842cb PS |
571 | test_expect_success '--unset-upstream should fail if config is locked' ' |
572 | test_when_finished "rm -f .git/config.lock" && | |
573 | git branch --set-upstream-to locked && | |
574 | >.git/config.lock && | |
575 | test_must_fail git branch --unset-upstream | |
576 | ' | |
577 | ||
0d158ebb | 578 | test_expect_success 'test --unset-upstream on HEAD' ' |
d0423ddd | 579 | git branch my14 && |
0d158ebb RR |
580 | test_config branch.master.remote foo && |
581 | test_config branch.master.merge foo && | |
582 | git branch --set-upstream-to my14 && | |
583 | git branch --unset-upstream && | |
584 | test_must_fail git config branch.master.remote && | |
585 | test_must_fail git config branch.master.merge && | |
586 | # fail for a branch without upstream set | |
587 | test_must_fail git branch --unset-upstream | |
588 | ' | |
589 | ||
0cb24fe8 JH |
590 | test_expect_success '--unset-upstream should fail on multiple branches' ' |
591 | test_must_fail git branch --unset-upstream a b c | |
592 | ' | |
593 | ||
594 | test_expect_success '--unset-upstream should fail on detached HEAD' ' | |
595 | git checkout HEAD^{} && | |
596 | test_must_fail git branch --unset-upstream && | |
597 | git checkout - | |
598 | ' | |
599 | ||
0d158ebb | 600 | test_expect_success 'test --unset-upstream on a particular branch' ' |
d0423ddd | 601 | git branch my15 && |
0d158ebb RR |
602 | git branch --set-upstream-to master my14 && |
603 | git branch --unset-upstream my14 && | |
604 | test_must_fail git config branch.my14.remote && | |
605 | test_must_fail git config branch.my14.merge | |
606 | ' | |
607 | ||
52668846 KS |
608 | test_expect_success '--set-upstream fails' ' |
609 | test_must_fail git branch --set-upstream origin/master | |
b347d06b CMN |
610 | ' |
611 | ||
95052d1f BG |
612 | test_expect_success '--set-upstream-to notices an error to set branch as own upstream' ' |
613 | git branch --set-upstream-to refs/heads/my13 my13 2>actual && | |
614 | cat >expected <<-\EOF && | |
615 | warning: Not setting branch my13 as its own upstream. | |
616 | EOF | |
617 | test_expect_code 1 git config branch.my13.remote && | |
618 | test_expect_code 1 git config branch.my13.merge && | |
619 | test_i18ncmp expected actual | |
620 | ' | |
621 | ||
0746d19a PB |
622 | # Keep this test last, as it changes the current branch |
623 | cat >expect <<EOF | |
3749fde5 | 624 | $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master |
0746d19a | 625 | EOF |
0d158ebb RR |
626 | test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' ' |
627 | GIT_COMMITTER_DATE="2005-05-26 23:30" \ | |
628 | git checkout -b g/h/i -l master && | |
629 | test_path_is_file .git/refs/heads/g/h/i && | |
630 | test_path_is_file .git/logs/refs/heads/g/h/i && | |
631 | test_cmp expect .git/logs/refs/heads/g/h/i | |
632 | ' | |
0746d19a | 633 | |
b2099957 EM |
634 | test_expect_success 'checkout -b makes reflog by default' ' |
635 | git checkout master && | |
636 | git config --unset core.logAllRefUpdates && | |
637 | git checkout -b alpha && | |
6e6842e3 | 638 | git rev-parse --verify alpha@{0} |
b2099957 EM |
639 | ' |
640 | ||
641 | test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' ' | |
642 | git checkout master && | |
643 | git config core.logAllRefUpdates false && | |
644 | git checkout -b beta && | |
6e6842e3 | 645 | test_must_fail git rev-parse --verify beta@{0} |
b2099957 EM |
646 | ' |
647 | ||
648 | test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' ' | |
649 | git checkout master && | |
650 | git checkout -lb gamma && | |
651 | git config --unset core.logAllRefUpdates && | |
6e6842e3 | 652 | git rev-parse --verify gamma@{0} |
b2099957 EM |
653 | ' |
654 | ||
1d0a694b DB |
655 | test_expect_success 'avoid ambiguous track' ' |
656 | git config branch.autosetupmerge true && | |
657 | git config remote.ambi1.url lalala && | |
658 | git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master && | |
659 | git config remote.ambi2.url lilili && | |
660 | git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master && | |
27852b2c | 661 | test_must_fail git branch all1 master && |
1d0a694b DB |
662 | test -z "$(git config branch.all1.merge)" |
663 | ' | |
664 | ||
c998ae9b DS |
665 | test_expect_success 'autosetuprebase local on a tracked local branch' ' |
666 | git config remote.local.url . && | |
667 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
668 | git config branch.autosetuprebase local && | |
0cb0e143 | 669 | (git show-ref -q refs/remotes/local/o || git fetch local) && |
c998ae9b DS |
670 | git branch mybase && |
671 | git branch --track myr1 mybase && | |
672 | test "$(git config branch.myr1.remote)" = . && | |
673 | test "$(git config branch.myr1.merge)" = refs/heads/mybase && | |
674 | test "$(git config branch.myr1.rebase)" = true | |
675 | ' | |
676 | ||
677 | test_expect_success 'autosetuprebase always on a tracked local branch' ' | |
678 | git config remote.local.url . && | |
679 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
680 | git config branch.autosetuprebase always && | |
0cb0e143 | 681 | (git show-ref -q refs/remotes/local/o || git fetch local) && |
c998ae9b DS |
682 | git branch mybase2 && |
683 | git branch --track myr2 mybase && | |
684 | test "$(git config branch.myr2.remote)" = . && | |
685 | test "$(git config branch.myr2.merge)" = refs/heads/mybase && | |
686 | test "$(git config branch.myr2.rebase)" = true | |
687 | ' | |
688 | ||
689 | test_expect_success 'autosetuprebase remote on a tracked local branch' ' | |
690 | git config remote.local.url . && | |
691 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
692 | git config branch.autosetuprebase remote && | |
0cb0e143 | 693 | (git show-ref -q refs/remotes/local/o || git fetch local) && |
c998ae9b DS |
694 | git branch mybase3 && |
695 | git branch --track myr3 mybase2 && | |
696 | test "$(git config branch.myr3.remote)" = . && | |
697 | test "$(git config branch.myr3.merge)" = refs/heads/mybase2 && | |
698 | ! test "$(git config branch.myr3.rebase)" = true | |
699 | ' | |
700 | ||
701 | test_expect_success 'autosetuprebase never on a tracked local branch' ' | |
702 | git config remote.local.url . && | |
703 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
704 | git config branch.autosetuprebase never && | |
0cb0e143 | 705 | (git show-ref -q refs/remotes/local/o || git fetch local) && |
c998ae9b DS |
706 | git branch mybase4 && |
707 | git branch --track myr4 mybase2 && | |
708 | test "$(git config branch.myr4.remote)" = . && | |
709 | test "$(git config branch.myr4.merge)" = refs/heads/mybase2 && | |
710 | ! test "$(git config branch.myr4.rebase)" = true | |
711 | ' | |
712 | ||
713 | test_expect_success 'autosetuprebase local on a tracked remote branch' ' | |
714 | git config remote.local.url . && | |
715 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
716 | git config branch.autosetuprebase local && | |
0cb0e143 | 717 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
718 | git branch --track myr5 local/master && |
719 | test "$(git config branch.myr5.remote)" = local && | |
720 | test "$(git config branch.myr5.merge)" = refs/heads/master && | |
721 | ! test "$(git config branch.myr5.rebase)" = true | |
722 | ' | |
723 | ||
724 | test_expect_success 'autosetuprebase never on a tracked remote branch' ' | |
725 | git config remote.local.url . && | |
726 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
727 | git config branch.autosetuprebase never && | |
0cb0e143 | 728 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
729 | git branch --track myr6 local/master && |
730 | test "$(git config branch.myr6.remote)" = local && | |
731 | test "$(git config branch.myr6.merge)" = refs/heads/master && | |
732 | ! test "$(git config branch.myr6.rebase)" = true | |
733 | ' | |
734 | ||
735 | test_expect_success 'autosetuprebase remote on a tracked remote branch' ' | |
736 | git config remote.local.url . && | |
737 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
738 | git config branch.autosetuprebase remote && | |
0cb0e143 | 739 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
740 | git branch --track myr7 local/master && |
741 | test "$(git config branch.myr7.remote)" = local && | |
742 | test "$(git config branch.myr7.merge)" = refs/heads/master && | |
743 | test "$(git config branch.myr7.rebase)" = true | |
744 | ' | |
745 | ||
746 | test_expect_success 'autosetuprebase always on a tracked remote branch' ' | |
747 | git config remote.local.url . && | |
748 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
749 | git config branch.autosetuprebase remote && | |
0cb0e143 | 750 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
751 | git branch --track myr8 local/master && |
752 | test "$(git config branch.myr8.remote)" = local && | |
753 | test "$(git config branch.myr8.merge)" = refs/heads/master && | |
754 | test "$(git config branch.myr8.rebase)" = true | |
755 | ' | |
756 | ||
757 | test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' ' | |
758 | git config --unset branch.autosetuprebase && | |
759 | git config remote.local.url . && | |
760 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 761 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
762 | git branch --track myr9 local/master && |
763 | test "$(git config branch.myr9.remote)" = local && | |
764 | test "$(git config branch.myr9.merge)" = refs/heads/master && | |
765 | test "z$(git config branch.myr9.rebase)" = z | |
766 | ' | |
767 | ||
768 | test_expect_success 'autosetuprebase unconfigured on a tracked local branch' ' | |
769 | git config remote.local.url . && | |
770 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 771 | (git show-ref -q refs/remotes/local/o || git fetch local) && |
c998ae9b DS |
772 | git branch mybase10 && |
773 | git branch --track myr10 mybase2 && | |
774 | test "$(git config branch.myr10.remote)" = . && | |
775 | test "$(git config branch.myr10.merge)" = refs/heads/mybase2 && | |
776 | test "z$(git config branch.myr10.rebase)" = z | |
777 | ' | |
778 | ||
779 | test_expect_success 'autosetuprebase unconfigured on untracked local branch' ' | |
780 | git config remote.local.url . && | |
781 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 782 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
783 | git branch --no-track myr11 mybase2 && |
784 | test "z$(git config branch.myr11.remote)" = z && | |
785 | test "z$(git config branch.myr11.merge)" = z && | |
786 | test "z$(git config branch.myr11.rebase)" = z | |
787 | ' | |
788 | ||
789 | test_expect_success 'autosetuprebase unconfigured on untracked remote branch' ' | |
790 | git config remote.local.url . && | |
791 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 792 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
793 | git branch --no-track myr12 local/master && |
794 | test "z$(git config branch.myr12.remote)" = z && | |
795 | test "z$(git config branch.myr12.merge)" = z && | |
796 | test "z$(git config branch.myr12.rebase)" = z | |
797 | ' | |
798 | ||
799 | test_expect_success 'autosetuprebase never on an untracked local branch' ' | |
800 | git config branch.autosetuprebase never && | |
801 | git config remote.local.url . && | |
802 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 803 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
804 | git branch --no-track myr13 mybase2 && |
805 | test "z$(git config branch.myr13.remote)" = z && | |
806 | test "z$(git config branch.myr13.merge)" = z && | |
807 | test "z$(git config branch.myr13.rebase)" = z | |
808 | ' | |
809 | ||
810 | test_expect_success 'autosetuprebase local on an untracked local branch' ' | |
811 | git config branch.autosetuprebase local && | |
812 | git config remote.local.url . && | |
813 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 814 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
815 | git branch --no-track myr14 mybase2 && |
816 | test "z$(git config branch.myr14.remote)" = z && | |
817 | test "z$(git config branch.myr14.merge)" = z && | |
818 | test "z$(git config branch.myr14.rebase)" = z | |
819 | ' | |
820 | ||
821 | test_expect_success 'autosetuprebase remote on an untracked local branch' ' | |
822 | git config branch.autosetuprebase remote && | |
823 | git config remote.local.url . && | |
824 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 825 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
826 | git branch --no-track myr15 mybase2 && |
827 | test "z$(git config branch.myr15.remote)" = z && | |
828 | test "z$(git config branch.myr15.merge)" = z && | |
829 | test "z$(git config branch.myr15.rebase)" = z | |
830 | ' | |
831 | ||
832 | test_expect_success 'autosetuprebase always on an untracked local branch' ' | |
833 | git config branch.autosetuprebase always && | |
834 | git config remote.local.url . && | |
835 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 836 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
837 | git branch --no-track myr16 mybase2 && |
838 | test "z$(git config branch.myr16.remote)" = z && | |
839 | test "z$(git config branch.myr16.merge)" = z && | |
840 | test "z$(git config branch.myr16.rebase)" = z | |
841 | ' | |
842 | ||
843 | test_expect_success 'autosetuprebase never on an untracked remote branch' ' | |
844 | git config branch.autosetuprebase never && | |
845 | git config remote.local.url . && | |
846 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 847 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
848 | git branch --no-track myr17 local/master && |
849 | test "z$(git config branch.myr17.remote)" = z && | |
850 | test "z$(git config branch.myr17.merge)" = z && | |
851 | test "z$(git config branch.myr17.rebase)" = z | |
852 | ' | |
853 | ||
854 | test_expect_success 'autosetuprebase local on an untracked remote branch' ' | |
855 | git config branch.autosetuprebase local && | |
856 | git config remote.local.url . && | |
857 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 858 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
859 | git branch --no-track myr18 local/master && |
860 | test "z$(git config branch.myr18.remote)" = z && | |
861 | test "z$(git config branch.myr18.merge)" = z && | |
862 | test "z$(git config branch.myr18.rebase)" = z | |
863 | ' | |
864 | ||
865 | test_expect_success 'autosetuprebase remote on an untracked remote branch' ' | |
866 | git config branch.autosetuprebase remote && | |
867 | git config remote.local.url . && | |
868 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 869 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
870 | git branch --no-track myr19 local/master && |
871 | test "z$(git config branch.myr19.remote)" = z && | |
872 | test "z$(git config branch.myr19.merge)" = z && | |
873 | test "z$(git config branch.myr19.rebase)" = z | |
874 | ' | |
875 | ||
876 | test_expect_success 'autosetuprebase always on an untracked remote branch' ' | |
877 | git config branch.autosetuprebase always && | |
878 | git config remote.local.url . && | |
879 | git config remote.local.fetch refs/heads/*:refs/remotes/local/* && | |
0cb0e143 | 880 | (git show-ref -q refs/remotes/local/master || git fetch local) && |
c998ae9b DS |
881 | git branch --no-track myr20 local/master && |
882 | test "z$(git config branch.myr20.remote)" = z && | |
883 | test "z$(git config branch.myr20.merge)" = z && | |
884 | test "z$(git config branch.myr20.rebase)" = z | |
885 | ' | |
886 | ||
21b5b1e8 JH |
887 | test_expect_success 'autosetuprebase always on detached HEAD' ' |
888 | git config branch.autosetupmerge always && | |
889 | test_when_finished git checkout master && | |
890 | git checkout HEAD^0 && | |
891 | git branch my11 && | |
892 | test -z "$(git config branch.my11.remote)" && | |
893 | test -z "$(git config branch.my11.merge)" | |
894 | ' | |
895 | ||
c998ae9b DS |
896 | test_expect_success 'detect misconfigured autosetuprebase (bad value)' ' |
897 | git config branch.autosetuprebase garbage && | |
898 | test_must_fail git branch | |
899 | ' | |
900 | ||
901 | test_expect_success 'detect misconfigured autosetuprebase (no value)' ' | |
902 | git config --unset branch.autosetuprebase && | |
0d158ebb | 903 | echo "[branch] autosetuprebase" >>.git/config && |
c998ae9b DS |
904 | test_must_fail git branch && |
905 | git config --unset branch.autosetuprebase | |
906 | ' | |
907 | ||
99c419c9 JH |
908 | test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' ' |
909 | git checkout my9 && | |
910 | git config --unset branch.my8.merge && | |
911 | test_must_fail git branch -d my8 | |
912 | ' | |
913 | ||
914 | test_expect_success 'attempt to delete a branch merged to its base' ' | |
915 | # we are on my9 which is the initial commit; traditionally | |
916 | # we would not have allowed deleting my8 that is not merged | |
917 | # to my9, but it is set to track master that already has my8 | |
918 | git config branch.my8.merge refs/heads/master && | |
919 | git branch -d my8 | |
920 | ' | |
921 | ||
922 | test_expect_success 'attempt to delete a branch merged to its base' ' | |
923 | git checkout master && | |
924 | echo Third >>A && | |
925 | git commit -m "Third commit" A && | |
926 | git branch -t my10 my9 && | |
927 | git branch -f my10 HEAD^ && | |
928 | # we are on master which is at the third commit, and my10 | |
929 | # is behind us, so traditionally we would have allowed deleting | |
930 | # it; but my10 is set to track my9 that is further behind. | |
931 | test_must_fail git branch -d my10 | |
932 | ' | |
933 | ||
c2d17ba3 JH |
934 | test_expect_success 'use --edit-description' ' |
935 | write_script editor <<-\EOF && | |
936 | echo "New contents" >"$1" | |
937 | EOF | |
938 | EDITOR=./editor git branch --edit-description && | |
939 | write_script editor <<-\EOF && | |
940 | git stripspace -s <"$1" >"EDITOR_OUTPUT" | |
941 | EOF | |
942 | EDITOR=./editor git branch --edit-description && | |
943 | echo "New contents" >expect && | |
944 | test_cmp EDITOR_OUTPUT expect | |
945 | ' | |
946 | ||
947 | test_expect_success 'detect typo in branch name when using --edit-description' ' | |
948 | write_script editor <<-\EOF && | |
949 | echo "New contents" >"$1" | |
950 | EOF | |
512477b1 | 951 | test_must_fail env EDITOR=./editor git branch --edit-description no-such-branch |
c2d17ba3 JH |
952 | ' |
953 | ||
954 | test_expect_success 'refuse --edit-description on unborn branch for now' ' | |
955 | write_script editor <<-\EOF && | |
956 | echo "New contents" >"$1" | |
957 | EOF | |
958 | git checkout --orphan unborn && | |
512477b1 | 959 | test_must_fail env EDITOR=./editor git branch --edit-description |
c2d17ba3 JH |
960 | ' |
961 | ||
6c41e975 CMN |
962 | test_expect_success '--merged catches invalid object names' ' |
963 | test_must_fail git branch --merged 0000000000000000000000000000000000000000 | |
964 | ' | |
965 | ||
17d6c744 ÆAB |
966 | test_expect_success '--merged is incompatible with --no-merged' ' |
967 | test_must_fail git branch --merged HEAD --no-merged HEAD | |
968 | ' | |
969 | ||
1d7358c5 | 970 | test_expect_success 'tracking with unexpected .fetch refspec' ' |
b0f49ff1 | 971 | rm -rf a b c d && |
62d94a3a JH |
972 | git init a && |
973 | ( | |
974 | cd a && | |
975 | test_commit a | |
976 | ) && | |
977 | git init b && | |
978 | ( | |
979 | cd b && | |
980 | test_commit b | |
981 | ) && | |
982 | git init c && | |
983 | ( | |
984 | cd c && | |
985 | test_commit c && | |
986 | git remote add a ../a && | |
987 | git remote add b ../b && | |
988 | git fetch --all | |
989 | ) && | |
990 | git init d && | |
991 | ( | |
992 | cd d && | |
993 | git remote add c ../c && | |
994 | git config remote.c.fetch "+refs/remotes/*:refs/remotes/*" && | |
995 | git fetch c && | |
996 | git branch --track local/a/master remotes/a/master && | |
997 | test "$(git config branch.local/a/master.remote)" = "c" && | |
998 | test "$(git config branch.local/a/master.merge)" = "refs/remotes/a/master" && | |
999 | git rev-parse --verify a >expect && | |
1000 | git rev-parse --verify local/a/master >actual && | |
1001 | test_cmp expect actual | |
1002 | ) | |
1003 | ' | |
1004 | ||
a3b427b9 | 1005 | test_done |