1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Amos Waterland
4 #
6 test_description='git branch --foo should not create bogus branch
8 This test runs git branch --help and checks that the argument is properly
9 handled. Specifically, that a bogus branch is not created.
10 '
11 . ./test-lib.sh
13 test_expect_success \
14 'prepare a trivial repository' \
15 'echo Hello > A &&
16 git update-index --add A &&
17 git commit -m "Initial commit." &&
18 echo World >> A &&
19 git update-index --add A &&
20 git commit -m "Second commit." &&
21 HEAD=$(git rev-parse --verify HEAD)'
23 test_expect_success \
24 'git branch --help should not have created a bogus branch' '
25 git branch --help </dev/null >/dev/null 2>/dev/null;
26 test_path_is_missing .git/refs/heads/--help
27 '
29 test_expect_success 'branch -h in broken repository' '
30 mkdir broken &&
31 (
32 cd broken &&
33 git init &&
34 >.git/refs/heads/master &&
35 test_expect_code 129 git branch -h >usage 2>&1
36 ) &&
37 grep "[Uu]sage" broken/usage
38 '
40 test_expect_success \
41 'git branch abc should create a branch' \
42 'git branch abc && test_path_is_file .git/refs/heads/abc'
44 test_expect_success \
45 'git branch a/b/c should create a branch' \
46 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
48 cat >expect <<EOF
49 $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
50 EOF
51 test_expect_success \
52 'git branch -l d/e/f should create a branch and a log' \
53 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
54 git branch -l d/e/f &&
55 test_path_is_file .git/refs/heads/d/e/f &&
56 test_path_is_file .git/logs/refs/heads/d/e/f &&
57 test_cmp expect .git/logs/refs/heads/d/e/f'
59 test_expect_success \
60 'git branch -d d/e/f should delete a branch and a log' \
61 'git branch -d d/e/f &&
62 test_path_is_missing .git/refs/heads/d/e/f &&
63 test_path_is_missing .git/logs/refs/heads/d/e/f'
65 test_expect_success \
66 'git branch j/k should work after branch j has been deleted' \
67 'git branch j &&
68 git branch -d j &&
69 git branch j/k'
71 test_expect_success \
72 'git branch l should work after branch l/m has been deleted' \
73 'git branch l/m &&
74 git branch -d l/m &&
75 git branch l'
77 test_expect_success \
78 'git branch -m m m/m should work' \
79 'git branch -l m &&
80 git branch -m m m/m &&
81 test_path_is_file .git/logs/refs/heads/m/m'
83 test_expect_success \
84 'git branch -m n/n n should work' \
85 'git branch -l n/n &&
86 git branch -m n/n n
87 test_path_is_file .git/logs/refs/heads/n'
89 test_expect_success 'git branch -m o/o o should fail when o/p exists' '
90 git branch o/o &&
91 git branch o/p &&
92 test_must_fail git branch -m o/o o
93 '
95 test_expect_success 'git branch -m q r/q should fail when r exists' '
96 git branch q &&
97 git branch r &&
98 test_must_fail git branch -m q r/q
99 '
101 test_expect_success 'git branch -M foo bar should fail when bar is checked out' '
102 git branch bar &&
103 git checkout -b foo &&
104 test_must_fail git branch -M bar foo
105 '
107 test_expect_success 'git branch -M baz bam should succeed when baz is checked out' '
108 git checkout -b baz &&
109 git branch bam &&
110 git branch -M baz bam
111 '
113 test_expect_success 'git branch -v -d t should work' '
114 git branch t &&
115 test_path_is_file .git/refs/heads/t &&
116 git branch -v -d t &&
117 test_path_is_missing .git/refs/heads/t
118 '
120 test_expect_success 'git branch -v -m t s should work' '
121 git branch t &&
122 test_path_is_file .git/refs/heads/t &&
123 git branch -v -m t s &&
124 test_path_is_missing .git/refs/heads/t &&
125 test_path_is_file .git/refs/heads/s &&
126 git branch -d s
127 '
129 test_expect_success 'git branch -m -d t s should fail' '
130 git branch t &&
131 test_path_is_file .git/refs/heads/t &&
132 test_must_fail git branch -m -d t s &&
133 git branch -d t &&
134 test_path_is_missing .git/refs/heads/t
135 '
137 test_expect_success 'git branch --list -d t should fail' '
138 git branch t &&
139 test_path_is_file .git/refs/heads/t &&
140 test_must_fail git branch --list -d t &&
141 git branch -d t &&
142 test_path_is_missing .git/refs/heads/t
143 '
145 mv .git/config .git/config-saved
147 test_expect_success 'git branch -m q q2 without config should succeed' '
148 git branch -m q q2 &&
149 git branch -m q2 q
150 '
152 mv .git/config-saved .git/config
154 git config branch.s/s.dummy Hello
156 test_expect_success \
157 'git branch -m s/s s should work when s/t is deleted' \
158 'git branch -l s/s &&
159 test_path_is_file .git/logs/refs/heads/s/s &&
160 git branch -l s/t &&
161 test_path_is_file .git/logs/refs/heads/s/t &&
162 git branch -d s/t &&
163 git branch -m s/s s &&
164 test_path_is_file .git/logs/refs/heads/s'
166 test_expect_success 'config information was renamed, too' \
167 "test $(git config branch.s.dummy) = Hello &&
168 test_must_fail git config branch.s/s/dummy"
170 test_expect_success 'renaming a symref is not allowed' \
171 '
172 git symbolic-ref refs/heads/master2 refs/heads/master &&
173 test_must_fail git branch -m master2 master3 &&
174 git symbolic-ref refs/heads/master2 &&
175 test_path_is_file .git/refs/heads/master &&
176 test_path_is_missing .git/refs/heads/master3
177 '
179 test_expect_success SYMLINKS \
180 'git branch -m u v should fail when the reflog for u is a symlink' '
181 git branch -l u &&
182 mv .git/logs/refs/heads/u real-u &&
183 ln -s real-u .git/logs/refs/heads/u &&
184 test_must_fail git branch -m u v
185 '
187 test_expect_success 'test tracking setup via --track' \
188 'git config remote.local.url . &&
189 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
190 (git show-ref -q refs/remotes/local/master || git fetch local) &&
191 git branch --track my1 local/master &&
192 test $(git config branch.my1.remote) = local &&
193 test $(git config branch.my1.merge) = refs/heads/master'
195 test_expect_success 'test tracking setup (non-wildcard, matching)' \
196 'git config remote.local.url . &&
197 git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
198 (git show-ref -q refs/remotes/local/master || git fetch local) &&
199 git branch --track my4 local/master &&
200 test $(git config branch.my4.remote) = local &&
201 test $(git config branch.my4.merge) = refs/heads/master'
203 test_expect_success 'test tracking setup (non-wildcard, not matching)' \
204 'git config remote.local.url . &&
205 git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
206 (git show-ref -q refs/remotes/local/master || git fetch local) &&
207 git branch --track my5 local/master &&
208 ! test "$(git config branch.my5.remote)" = local &&
209 ! test "$(git config branch.my5.merge)" = refs/heads/master'
211 test_expect_success 'test tracking setup via config' \
212 'git config branch.autosetupmerge true &&
213 git config remote.local.url . &&
214 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
215 (git show-ref -q refs/remotes/local/master || git fetch local) &&
216 git branch my3 local/master &&
217 test $(git config branch.my3.remote) = local &&
218 test $(git config branch.my3.merge) = refs/heads/master'
220 test_expect_success 'test overriding tracking setup via --no-track' \
221 'git config branch.autosetupmerge true &&
222 git config remote.local.url . &&
223 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
224 (git show-ref -q refs/remotes/local/master || git fetch local) &&
225 git branch --no-track my2 local/master &&
226 git config branch.autosetupmerge false &&
227 ! test "$(git config branch.my2.remote)" = local &&
228 ! test "$(git config branch.my2.merge)" = refs/heads/master'
230 test_expect_success 'no tracking without .fetch entries' \
231 'git config branch.autosetupmerge true &&
232 git branch my6 s &&
233 git config branch.automsetupmerge false &&
234 test -z "$(git config branch.my6.remote)" &&
235 test -z "$(git config branch.my6.merge)"'
237 test_expect_success 'test tracking setup via --track but deeper' \
238 'git config remote.local.url . &&
239 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
240 (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
241 git branch --track my7 local/o/o &&
242 test "$(git config branch.my7.remote)" = local &&
243 test "$(git config branch.my7.merge)" = refs/heads/o/o'
245 test_expect_success 'test deleting branch deletes branch config' \
246 'git branch -d my7 &&
247 test -z "$(git config branch.my7.remote)" &&
248 test -z "$(git config branch.my7.merge)"'
250 test_expect_success 'test deleting branch without config' \
251 'git branch my7 s &&
252 sha1=$(git rev-parse my7 | cut -c 1-7) &&
253 echo "Deleted branch my7 (was $sha1)." >expect &&
254 git branch -d my7 >actual 2>&1 &&
255 test_i18ncmp expect actual'
257 test_expect_success 'test --track without .fetch entries' \
258 'git branch --track my8 &&
259 test "$(git config branch.my8.remote)" &&
260 test "$(git config branch.my8.merge)"'
262 test_expect_success \
263 'branch from non-branch HEAD w/autosetupmerge=always' \
264 'git config branch.autosetupmerge always &&
265 git branch my9 HEAD^ &&
266 git config branch.autosetupmerge false'
268 test_expect_success \
269 'branch from non-branch HEAD w/--track causes failure' \
270 'test_must_fail git branch --track my10 HEAD^'
272 test_expect_success \
273 'branch from tag w/--track causes failure' \
274 'git tag foobar &&
275 test_must_fail git branch --track my11 foobar'
277 # Keep this test last, as it changes the current branch
278 cat >expect <<EOF
279 $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
280 EOF
281 test_expect_success \
282 'git checkout -b g/h/i -l should create a branch and a log' \
283 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
284 git checkout -b g/h/i -l master &&
285 test_path_is_file .git/refs/heads/g/h/i &&
286 test_path_is_file .git/logs/refs/heads/g/h/i &&
287 test_cmp expect .git/logs/refs/heads/g/h/i'
289 test_expect_success 'checkout -b makes reflog by default' '
290 git checkout master &&
291 git config --unset core.logAllRefUpdates &&
292 git checkout -b alpha &&
293 git rev-parse --verify alpha@{0}
294 '
296 test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
297 git checkout master &&
298 git config core.logAllRefUpdates false &&
299 git checkout -b beta &&
300 test_must_fail git rev-parse --verify beta@{0}
301 '
303 test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
304 git checkout master &&
305 git checkout -lb gamma &&
306 git config --unset core.logAllRefUpdates &&
307 git rev-parse --verify gamma@{0}
308 '
310 test_expect_success 'avoid ambiguous track' '
311 git config branch.autosetupmerge true &&
312 git config remote.ambi1.url lalala &&
313 git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
314 git config remote.ambi2.url lilili &&
315 git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
316 git branch all1 master &&
317 test -z "$(git config branch.all1.merge)"
318 '
320 test_expect_success 'autosetuprebase local on a tracked local branch' '
321 git config remote.local.url . &&
322 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
323 git config branch.autosetuprebase local &&
324 (git show-ref -q refs/remotes/local/o || git fetch local) &&
325 git branch mybase &&
326 git branch --track myr1 mybase &&
327 test "$(git config branch.myr1.remote)" = . &&
328 test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
329 test "$(git config branch.myr1.rebase)" = true
330 '
332 test_expect_success 'autosetuprebase always on a tracked local branch' '
333 git config remote.local.url . &&
334 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
335 git config branch.autosetuprebase always &&
336 (git show-ref -q refs/remotes/local/o || git fetch local) &&
337 git branch mybase2 &&
338 git branch --track myr2 mybase &&
339 test "$(git config branch.myr2.remote)" = . &&
340 test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
341 test "$(git config branch.myr2.rebase)" = true
342 '
344 test_expect_success 'autosetuprebase remote on a tracked local branch' '
345 git config remote.local.url . &&
346 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
347 git config branch.autosetuprebase remote &&
348 (git show-ref -q refs/remotes/local/o || git fetch local) &&
349 git branch mybase3 &&
350 git branch --track myr3 mybase2 &&
351 test "$(git config branch.myr3.remote)" = . &&
352 test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
353 ! test "$(git config branch.myr3.rebase)" = true
354 '
356 test_expect_success 'autosetuprebase never on a tracked local branch' '
357 git config remote.local.url . &&
358 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
359 git config branch.autosetuprebase never &&
360 (git show-ref -q refs/remotes/local/o || git fetch local) &&
361 git branch mybase4 &&
362 git branch --track myr4 mybase2 &&
363 test "$(git config branch.myr4.remote)" = . &&
364 test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
365 ! test "$(git config branch.myr4.rebase)" = true
366 '
368 test_expect_success 'autosetuprebase local on a tracked remote branch' '
369 git config remote.local.url . &&
370 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
371 git config branch.autosetuprebase local &&
372 (git show-ref -q refs/remotes/local/master || git fetch local) &&
373 git branch --track myr5 local/master &&
374 test "$(git config branch.myr5.remote)" = local &&
375 test "$(git config branch.myr5.merge)" = refs/heads/master &&
376 ! test "$(git config branch.myr5.rebase)" = true
377 '
379 test_expect_success 'autosetuprebase never on a tracked remote branch' '
380 git config remote.local.url . &&
381 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
382 git config branch.autosetuprebase never &&
383 (git show-ref -q refs/remotes/local/master || git fetch local) &&
384 git branch --track myr6 local/master &&
385 test "$(git config branch.myr6.remote)" = local &&
386 test "$(git config branch.myr6.merge)" = refs/heads/master &&
387 ! test "$(git config branch.myr6.rebase)" = true
388 '
390 test_expect_success 'autosetuprebase remote on a tracked remote branch' '
391 git config remote.local.url . &&
392 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
393 git config branch.autosetuprebase remote &&
394 (git show-ref -q refs/remotes/local/master || git fetch local) &&
395 git branch --track myr7 local/master &&
396 test "$(git config branch.myr7.remote)" = local &&
397 test "$(git config branch.myr7.merge)" = refs/heads/master &&
398 test "$(git config branch.myr7.rebase)" = true
399 '
401 test_expect_success 'autosetuprebase always on a tracked remote branch' '
402 git config remote.local.url . &&
403 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
404 git config branch.autosetuprebase remote &&
405 (git show-ref -q refs/remotes/local/master || git fetch local) &&
406 git branch --track myr8 local/master &&
407 test "$(git config branch.myr8.remote)" = local &&
408 test "$(git config branch.myr8.merge)" = refs/heads/master &&
409 test "$(git config branch.myr8.rebase)" = true
410 '
412 test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
413 git config --unset branch.autosetuprebase &&
414 git config remote.local.url . &&
415 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
416 (git show-ref -q refs/remotes/local/master || git fetch local) &&
417 git branch --track myr9 local/master &&
418 test "$(git config branch.myr9.remote)" = local &&
419 test "$(git config branch.myr9.merge)" = refs/heads/master &&
420 test "z$(git config branch.myr9.rebase)" = z
421 '
423 test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
424 git config remote.local.url . &&
425 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
426 (git show-ref -q refs/remotes/local/o || git fetch local) &&
427 git branch mybase10 &&
428 git branch --track myr10 mybase2 &&
429 test "$(git config branch.myr10.remote)" = . &&
430 test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
431 test "z$(git config branch.myr10.rebase)" = z
432 '
434 test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
435 git config remote.local.url . &&
436 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
437 (git show-ref -q refs/remotes/local/master || git fetch local) &&
438 git branch --no-track myr11 mybase2 &&
439 test "z$(git config branch.myr11.remote)" = z &&
440 test "z$(git config branch.myr11.merge)" = z &&
441 test "z$(git config branch.myr11.rebase)" = z
442 '
444 test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
445 git config remote.local.url . &&
446 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
447 (git show-ref -q refs/remotes/local/master || git fetch local) &&
448 git branch --no-track myr12 local/master &&
449 test "z$(git config branch.myr12.remote)" = z &&
450 test "z$(git config branch.myr12.merge)" = z &&
451 test "z$(git config branch.myr12.rebase)" = z
452 '
454 test_expect_success 'autosetuprebase never on an untracked local branch' '
455 git config branch.autosetuprebase never &&
456 git config remote.local.url . &&
457 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
458 (git show-ref -q refs/remotes/local/master || git fetch local) &&
459 git branch --no-track myr13 mybase2 &&
460 test "z$(git config branch.myr13.remote)" = z &&
461 test "z$(git config branch.myr13.merge)" = z &&
462 test "z$(git config branch.myr13.rebase)" = z
463 '
465 test_expect_success 'autosetuprebase local on an untracked local branch' '
466 git config branch.autosetuprebase local &&
467 git config remote.local.url . &&
468 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
469 (git show-ref -q refs/remotes/local/master || git fetch local) &&
470 git branch --no-track myr14 mybase2 &&
471 test "z$(git config branch.myr14.remote)" = z &&
472 test "z$(git config branch.myr14.merge)" = z &&
473 test "z$(git config branch.myr14.rebase)" = z
474 '
476 test_expect_success 'autosetuprebase remote on an untracked local branch' '
477 git config branch.autosetuprebase remote &&
478 git config remote.local.url . &&
479 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
480 (git show-ref -q refs/remotes/local/master || git fetch local) &&
481 git branch --no-track myr15 mybase2 &&
482 test "z$(git config branch.myr15.remote)" = z &&
483 test "z$(git config branch.myr15.merge)" = z &&
484 test "z$(git config branch.myr15.rebase)" = z
485 '
487 test_expect_success 'autosetuprebase always on an untracked local branch' '
488 git config branch.autosetuprebase always &&
489 git config remote.local.url . &&
490 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
491 (git show-ref -q refs/remotes/local/master || git fetch local) &&
492 git branch --no-track myr16 mybase2 &&
493 test "z$(git config branch.myr16.remote)" = z &&
494 test "z$(git config branch.myr16.merge)" = z &&
495 test "z$(git config branch.myr16.rebase)" = z
496 '
498 test_expect_success 'autosetuprebase never on an untracked remote branch' '
499 git config branch.autosetuprebase never &&
500 git config remote.local.url . &&
501 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
502 (git show-ref -q refs/remotes/local/master || git fetch local) &&
503 git branch --no-track myr17 local/master &&
504 test "z$(git config branch.myr17.remote)" = z &&
505 test "z$(git config branch.myr17.merge)" = z &&
506 test "z$(git config branch.myr17.rebase)" = z
507 '
509 test_expect_success 'autosetuprebase local on an untracked remote branch' '
510 git config branch.autosetuprebase local &&
511 git config remote.local.url . &&
512 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
513 (git show-ref -q refs/remotes/local/master || git fetch local) &&
514 git branch --no-track myr18 local/master &&
515 test "z$(git config branch.myr18.remote)" = z &&
516 test "z$(git config branch.myr18.merge)" = z &&
517 test "z$(git config branch.myr18.rebase)" = z
518 '
520 test_expect_success 'autosetuprebase remote on an untracked remote branch' '
521 git config branch.autosetuprebase remote &&
522 git config remote.local.url . &&
523 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
524 (git show-ref -q refs/remotes/local/master || git fetch local) &&
525 git branch --no-track myr19 local/master &&
526 test "z$(git config branch.myr19.remote)" = z &&
527 test "z$(git config branch.myr19.merge)" = z &&
528 test "z$(git config branch.myr19.rebase)" = z
529 '
531 test_expect_success 'autosetuprebase always on an untracked remote branch' '
532 git config branch.autosetuprebase always &&
533 git config remote.local.url . &&
534 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
535 (git show-ref -q refs/remotes/local/master || git fetch local) &&
536 git branch --no-track myr20 local/master &&
537 test "z$(git config branch.myr20.remote)" = z &&
538 test "z$(git config branch.myr20.merge)" = z &&
539 test "z$(git config branch.myr20.rebase)" = z
540 '
542 test_expect_success 'autosetuprebase always on detached HEAD' '
543 git config branch.autosetupmerge always &&
544 test_when_finished git checkout master &&
545 git checkout HEAD^0 &&
546 git branch my11 &&
547 test -z "$(git config branch.my11.remote)" &&
548 test -z "$(git config branch.my11.merge)"
549 '
551 test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
552 git config branch.autosetuprebase garbage &&
553 test_must_fail git branch
554 '
556 test_expect_success 'detect misconfigured autosetuprebase (no value)' '
557 git config --unset branch.autosetuprebase &&
558 echo "[branch] autosetuprebase" >> .git/config &&
559 test_must_fail git branch &&
560 git config --unset branch.autosetuprebase
561 '
563 test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
564 git checkout my9 &&
565 git config --unset branch.my8.merge &&
566 test_must_fail git branch -d my8
567 '
569 test_expect_success 'attempt to delete a branch merged to its base' '
570 # we are on my9 which is the initial commit; traditionally
571 # we would not have allowed deleting my8 that is not merged
572 # to my9, but it is set to track master that already has my8
573 git config branch.my8.merge refs/heads/master &&
574 git branch -d my8
575 '
577 test_expect_success 'attempt to delete a branch merged to its base' '
578 git checkout master &&
579 echo Third >>A &&
580 git commit -m "Third commit" A &&
581 git branch -t my10 my9 &&
582 git branch -f my10 HEAD^ &&
583 # we are on master which is at the third commit, and my10
584 # is behind us, so traditionally we would have allowed deleting
585 # it; but my10 is set to track my9 that is further behind.
586 test_must_fail git branch -d my10
587 '
589 test_expect_success 'use set-upstream on the current branch' '
590 git checkout master &&
591 git --bare init myupstream.git &&
592 git push myupstream.git master:refs/heads/frotz &&
593 git remote add origin myupstream.git &&
594 git fetch &&
595 git branch --set-upstream master origin/frotz &&
597 test "z$(git config branch.master.remote)" = "zorigin" &&
598 test "z$(git config branch.master.merge)" = "zrefs/heads/frotz"
600 '
602 test_done