Git.pm: Use stream-like writing in cat_blob()
[git/dscho.git] / t / t3200-branch.sh
blobea82424e471cd53cd08f91c77500412fa192f960
1 #!/bin/sh
3 # Copyright (c) 2005 Amos Waterland
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.
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 test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
26 test_path_is_missing .git/refs/heads/--help
29 test_expect_success 'branch -h in broken repository' '
30 mkdir broken &&
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
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 dumps usage' \
79 'test_expect_code 129 git branch -m 2>err &&
80 grep "[Uu]sage: git branch" err'
82 test_expect_success \
83 'git branch -m m m/m should work' \
84 'git branch -l m &&
85 git branch -m m m/m &&
86 test_path_is_file .git/logs/refs/heads/m/m'
88 test_expect_success \
89 'git branch -m n/n n should work' \
90 'git branch -l n/n &&
91 git branch -m n/n n &&
92 test_path_is_file .git/logs/refs/heads/n'
94 test_expect_success 'git branch -m o/o o should fail when o/p exists' '
95 git branch o/o &&
96 git branch o/p &&
97 test_must_fail git branch -m o/o o
100 test_expect_success 'git branch -m q r/q should fail when r exists' '
101 git branch q &&
102 git branch r &&
103 test_must_fail git branch -m q r/q
106 test_expect_success 'git branch -M foo bar should fail when bar is checked out' '
107 git branch bar &&
108 git checkout -b foo &&
109 test_must_fail git branch -M bar foo
112 test_expect_success 'git branch -M baz bam should succeed when baz is checked out' '
113 git checkout -b baz &&
114 git branch bam &&
115 git branch -M baz bam
118 test_expect_success 'git branch -M master should work when master is checked out' '
119 git checkout master &&
120 git branch -M master
123 test_expect_success 'git branch -M master master should work when master is checked out' '
124 git checkout master &&
125 git branch -M master master
128 test_expect_success 'git branch -M master2 master2 should work when master is checked out' '
129 git checkout master &&
130 git branch master2 &&
131 git branch -M master2 master2
134 test_expect_success 'git branch -v -d t should work' '
135 git branch t &&
136 test_path_is_file .git/refs/heads/t &&
137 git branch -v -d t &&
138 test_path_is_missing .git/refs/heads/t
141 test_expect_success 'git branch -v -m t s should work' '
142 git branch t &&
143 test_path_is_file .git/refs/heads/t &&
144 git branch -v -m t s &&
145 test_path_is_missing .git/refs/heads/t &&
146 test_path_is_file .git/refs/heads/s &&
147 git branch -d s
150 test_expect_success 'git branch -m -d t s should fail' '
151 git branch t &&
152 test_path_is_file .git/refs/heads/t &&
153 test_must_fail git branch -m -d t s &&
154 git branch -d t &&
155 test_path_is_missing .git/refs/heads/t
158 test_expect_success 'git branch --list -d t should fail' '
159 git branch t &&
160 test_path_is_file .git/refs/heads/t &&
161 test_must_fail git branch --list -d t &&
162 git branch -d t &&
163 test_path_is_missing .git/refs/heads/t
166 mv .git/config .git/config-saved
168 test_expect_success 'git branch -m q q2 without config should succeed' '
169 git branch -m q q2 &&
170 git branch -m q2 q
173 mv .git/config-saved .git/config
175 git config branch.s/s.dummy Hello
177 test_expect_success \
178 'git branch -m s/s s should work when s/t is deleted' \
179 'git branch -l s/s &&
180 test_path_is_file .git/logs/refs/heads/s/s &&
181 git branch -l s/t &&
182 test_path_is_file .git/logs/refs/heads/s/t &&
183 git branch -d s/t &&
184 git branch -m s/s s &&
185 test_path_is_file .git/logs/refs/heads/s'
187 test_expect_success 'config information was renamed, too' \
188 "test $(git config branch.s.dummy) = Hello &&
189 test_must_fail git config branch.s/s/dummy"
191 test_expect_success 'renaming a symref is not allowed' \
193 git symbolic-ref refs/heads/master2 refs/heads/master &&
194 test_must_fail git branch -m master2 master3 &&
195 git symbolic-ref refs/heads/master2 &&
196 test_path_is_file .git/refs/heads/master &&
197 test_path_is_missing .git/refs/heads/master3
200 test_expect_success SYMLINKS \
201 'git branch -m u v should fail when the reflog for u is a symlink' '
202 git branch -l u &&
203 mv .git/logs/refs/heads/u real-u &&
204 ln -s real-u .git/logs/refs/heads/u &&
205 test_must_fail git branch -m u v
208 test_expect_success 'test tracking setup via --track' \
209 'git config remote.local.url . &&
210 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
211 (git show-ref -q refs/remotes/local/master || git fetch local) &&
212 git branch --track my1 local/master &&
213 test $(git config branch.my1.remote) = local &&
214 test $(git config branch.my1.merge) = refs/heads/master'
216 test_expect_success 'test tracking setup (non-wildcard, matching)' \
217 'git config remote.local.url . &&
218 git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
219 (git show-ref -q refs/remotes/local/master || git fetch local) &&
220 git branch --track my4 local/master &&
221 test $(git config branch.my4.remote) = local &&
222 test $(git config branch.my4.merge) = refs/heads/master'
224 test_expect_success 'test tracking setup (non-wildcard, not matching)' \
225 'git config remote.local.url . &&
226 git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
227 (git show-ref -q refs/remotes/local/master || git fetch local) &&
228 git branch --track my5 local/master &&
229 ! test "$(git config branch.my5.remote)" = local &&
230 ! test "$(git config branch.my5.merge)" = refs/heads/master'
232 test_expect_success 'test tracking setup via config' \
233 'git config branch.autosetupmerge true &&
234 git config remote.local.url . &&
235 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
236 (git show-ref -q refs/remotes/local/master || git fetch local) &&
237 git branch my3 local/master &&
238 test $(git config branch.my3.remote) = local &&
239 test $(git config branch.my3.merge) = refs/heads/master'
241 test_expect_success 'test overriding tracking setup via --no-track' \
242 'git config branch.autosetupmerge true &&
243 git config remote.local.url . &&
244 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
245 (git show-ref -q refs/remotes/local/master || git fetch local) &&
246 git branch --no-track my2 local/master &&
247 git config branch.autosetupmerge false &&
248 ! test "$(git config branch.my2.remote)" = local &&
249 ! test "$(git config branch.my2.merge)" = refs/heads/master'
251 test_expect_success 'no tracking without .fetch entries' \
252 'git config branch.autosetupmerge true &&
253 git branch my6 s &&
254 git config branch.automsetupmerge false &&
255 test -z "$(git config branch.my6.remote)" &&
256 test -z "$(git config branch.my6.merge)"'
258 test_expect_success 'test tracking setup via --track but deeper' \
259 'git config remote.local.url . &&
260 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
261 (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
262 git branch --track my7 local/o/o &&
263 test "$(git config branch.my7.remote)" = local &&
264 test "$(git config branch.my7.merge)" = refs/heads/o/o'
266 test_expect_success 'test deleting branch deletes branch config' \
267 'git branch -d my7 &&
268 test -z "$(git config branch.my7.remote)" &&
269 test -z "$(git config branch.my7.merge)"'
271 test_expect_success 'test deleting branch without config' \
272 'git branch my7 s &&
273 sha1=$(git rev-parse my7 | cut -c 1-7) &&
274 echo "Deleted branch my7 (was $sha1)." >expect &&
275 git branch -d my7 >actual 2>&1 &&
276 test_i18ncmp expect actual'
278 test_expect_success 'test --track without .fetch entries' \
279 'git branch --track my8 &&
280 test "$(git config branch.my8.remote)" &&
281 test "$(git config branch.my8.merge)"'
283 test_expect_success \
284 'branch from non-branch HEAD w/autosetupmerge=always' \
285 'git config branch.autosetupmerge always &&
286 git branch my9 HEAD^ &&
287 git config branch.autosetupmerge false'
289 test_expect_success \
290 'branch from non-branch HEAD w/--track causes failure' \
291 'test_must_fail git branch --track my10 HEAD^'
293 test_expect_success \
294 'branch from tag w/--track causes failure' \
295 'git tag foobar &&
296 test_must_fail git branch --track my11 foobar'
298 # Keep this test last, as it changes the current branch
299 cat >expect <<EOF
300 $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
302 test_expect_success \
303 'git checkout -b g/h/i -l should create a branch and a log' \
304 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
305 git checkout -b g/h/i -l master &&
306 test_path_is_file .git/refs/heads/g/h/i &&
307 test_path_is_file .git/logs/refs/heads/g/h/i &&
308 test_cmp expect .git/logs/refs/heads/g/h/i'
310 test_expect_success 'checkout -b makes reflog by default' '
311 git checkout master &&
312 git config --unset core.logAllRefUpdates &&
313 git checkout -b alpha &&
314 git rev-parse --verify alpha@{0}
317 test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
318 git checkout master &&
319 git config core.logAllRefUpdates false &&
320 git checkout -b beta &&
321 test_must_fail git rev-parse --verify beta@{0}
324 test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
325 git checkout master &&
326 git checkout -lb gamma &&
327 git config --unset core.logAllRefUpdates &&
328 git rev-parse --verify gamma@{0}
331 test_expect_success 'avoid ambiguous track' '
332 git config branch.autosetupmerge true &&
333 git config remote.ambi1.url lalala &&
334 git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
335 git config remote.ambi2.url lilili &&
336 git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
337 git branch all1 master &&
338 test -z "$(git config branch.all1.merge)"
341 test_expect_success 'autosetuprebase local on a tracked local branch' '
342 git config remote.local.url . &&
343 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
344 git config branch.autosetuprebase local &&
345 (git show-ref -q refs/remotes/local/o || git fetch local) &&
346 git branch mybase &&
347 git branch --track myr1 mybase &&
348 test "$(git config branch.myr1.remote)" = . &&
349 test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
350 test "$(git config branch.myr1.rebase)" = true
353 test_expect_success 'autosetuprebase always on a tracked local branch' '
354 git config remote.local.url . &&
355 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
356 git config branch.autosetuprebase always &&
357 (git show-ref -q refs/remotes/local/o || git fetch local) &&
358 git branch mybase2 &&
359 git branch --track myr2 mybase &&
360 test "$(git config branch.myr2.remote)" = . &&
361 test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
362 test "$(git config branch.myr2.rebase)" = true
365 test_expect_success 'autosetuprebase remote on a tracked local branch' '
366 git config remote.local.url . &&
367 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
368 git config branch.autosetuprebase remote &&
369 (git show-ref -q refs/remotes/local/o || git fetch local) &&
370 git branch mybase3 &&
371 git branch --track myr3 mybase2 &&
372 test "$(git config branch.myr3.remote)" = . &&
373 test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
374 ! test "$(git config branch.myr3.rebase)" = true
377 test_expect_success 'autosetuprebase never on a tracked local branch' '
378 git config remote.local.url . &&
379 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
380 git config branch.autosetuprebase never &&
381 (git show-ref -q refs/remotes/local/o || git fetch local) &&
382 git branch mybase4 &&
383 git branch --track myr4 mybase2 &&
384 test "$(git config branch.myr4.remote)" = . &&
385 test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
386 ! test "$(git config branch.myr4.rebase)" = true
389 test_expect_success 'autosetuprebase local on a tracked remote branch' '
390 git config remote.local.url . &&
391 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
392 git config branch.autosetuprebase local &&
393 (git show-ref -q refs/remotes/local/master || git fetch local) &&
394 git branch --track myr5 local/master &&
395 test "$(git config branch.myr5.remote)" = local &&
396 test "$(git config branch.myr5.merge)" = refs/heads/master &&
397 ! test "$(git config branch.myr5.rebase)" = true
400 test_expect_success 'autosetuprebase never on a tracked remote branch' '
401 git config remote.local.url . &&
402 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
403 git config branch.autosetuprebase never &&
404 (git show-ref -q refs/remotes/local/master || git fetch local) &&
405 git branch --track myr6 local/master &&
406 test "$(git config branch.myr6.remote)" = local &&
407 test "$(git config branch.myr6.merge)" = refs/heads/master &&
408 ! test "$(git config branch.myr6.rebase)" = true
411 test_expect_success 'autosetuprebase remote on a tracked remote branch' '
412 git config remote.local.url . &&
413 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
414 git config branch.autosetuprebase remote &&
415 (git show-ref -q refs/remotes/local/master || git fetch local) &&
416 git branch --track myr7 local/master &&
417 test "$(git config branch.myr7.remote)" = local &&
418 test "$(git config branch.myr7.merge)" = refs/heads/master &&
419 test "$(git config branch.myr7.rebase)" = true
422 test_expect_success 'autosetuprebase always on a tracked remote branch' '
423 git config remote.local.url . &&
424 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
425 git config branch.autosetuprebase remote &&
426 (git show-ref -q refs/remotes/local/master || git fetch local) &&
427 git branch --track myr8 local/master &&
428 test "$(git config branch.myr8.remote)" = local &&
429 test "$(git config branch.myr8.merge)" = refs/heads/master &&
430 test "$(git config branch.myr8.rebase)" = true
433 test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
434 git config --unset branch.autosetuprebase &&
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 --track myr9 local/master &&
439 test "$(git config branch.myr9.remote)" = local &&
440 test "$(git config branch.myr9.merge)" = refs/heads/master &&
441 test "z$(git config branch.myr9.rebase)" = z
444 test_expect_success 'autosetuprebase unconfigured on a tracked local 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/o || git fetch local) &&
448 git branch mybase10 &&
449 git branch --track myr10 mybase2 &&
450 test "$(git config branch.myr10.remote)" = . &&
451 test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
452 test "z$(git config branch.myr10.rebase)" = z
455 test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
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 myr11 mybase2 &&
460 test "z$(git config branch.myr11.remote)" = z &&
461 test "z$(git config branch.myr11.merge)" = z &&
462 test "z$(git config branch.myr11.rebase)" = z
465 test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
466 git config remote.local.url . &&
467 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
468 (git show-ref -q refs/remotes/local/master || git fetch local) &&
469 git branch --no-track myr12 local/master &&
470 test "z$(git config branch.myr12.remote)" = z &&
471 test "z$(git config branch.myr12.merge)" = z &&
472 test "z$(git config branch.myr12.rebase)" = z
475 test_expect_success 'autosetuprebase never on an untracked local branch' '
476 git config branch.autosetuprebase never &&
477 git config remote.local.url . &&
478 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
479 (git show-ref -q refs/remotes/local/master || git fetch local) &&
480 git branch --no-track myr13 mybase2 &&
481 test "z$(git config branch.myr13.remote)" = z &&
482 test "z$(git config branch.myr13.merge)" = z &&
483 test "z$(git config branch.myr13.rebase)" = z
486 test_expect_success 'autosetuprebase local on an untracked local branch' '
487 git config branch.autosetuprebase local &&
488 git config remote.local.url . &&
489 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
490 (git show-ref -q refs/remotes/local/master || git fetch local) &&
491 git branch --no-track myr14 mybase2 &&
492 test "z$(git config branch.myr14.remote)" = z &&
493 test "z$(git config branch.myr14.merge)" = z &&
494 test "z$(git config branch.myr14.rebase)" = z
497 test_expect_success 'autosetuprebase remote on an untracked local branch' '
498 git config branch.autosetuprebase remote &&
499 git config remote.local.url . &&
500 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
501 (git show-ref -q refs/remotes/local/master || git fetch local) &&
502 git branch --no-track myr15 mybase2 &&
503 test "z$(git config branch.myr15.remote)" = z &&
504 test "z$(git config branch.myr15.merge)" = z &&
505 test "z$(git config branch.myr15.rebase)" = z
508 test_expect_success 'autosetuprebase always on an untracked local branch' '
509 git config branch.autosetuprebase always &&
510 git config remote.local.url . &&
511 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
512 (git show-ref -q refs/remotes/local/master || git fetch local) &&
513 git branch --no-track myr16 mybase2 &&
514 test "z$(git config branch.myr16.remote)" = z &&
515 test "z$(git config branch.myr16.merge)" = z &&
516 test "z$(git config branch.myr16.rebase)" = z
519 test_expect_success 'autosetuprebase never on an untracked remote branch' '
520 git config branch.autosetuprebase never &&
521 git config remote.local.url . &&
522 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
523 (git show-ref -q refs/remotes/local/master || git fetch local) &&
524 git branch --no-track myr17 local/master &&
525 test "z$(git config branch.myr17.remote)" = z &&
526 test "z$(git config branch.myr17.merge)" = z &&
527 test "z$(git config branch.myr17.rebase)" = z
530 test_expect_success 'autosetuprebase local on an untracked remote branch' '
531 git config branch.autosetuprebase local &&
532 git config remote.local.url . &&
533 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
534 (git show-ref -q refs/remotes/local/master || git fetch local) &&
535 git branch --no-track myr18 local/master &&
536 test "z$(git config branch.myr18.remote)" = z &&
537 test "z$(git config branch.myr18.merge)" = z &&
538 test "z$(git config branch.myr18.rebase)" = z
541 test_expect_success 'autosetuprebase remote on an untracked remote branch' '
542 git config branch.autosetuprebase remote &&
543 git config remote.local.url . &&
544 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
545 (git show-ref -q refs/remotes/local/master || git fetch local) &&
546 git branch --no-track myr19 local/master &&
547 test "z$(git config branch.myr19.remote)" = z &&
548 test "z$(git config branch.myr19.merge)" = z &&
549 test "z$(git config branch.myr19.rebase)" = z
552 test_expect_success 'autosetuprebase always on an untracked remote branch' '
553 git config branch.autosetuprebase always &&
554 git config remote.local.url . &&
555 git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
556 (git show-ref -q refs/remotes/local/master || git fetch local) &&
557 git branch --no-track myr20 local/master &&
558 test "z$(git config branch.myr20.remote)" = z &&
559 test "z$(git config branch.myr20.merge)" = z &&
560 test "z$(git config branch.myr20.rebase)" = z
563 test_expect_success 'autosetuprebase always on detached HEAD' '
564 git config branch.autosetupmerge always &&
565 test_when_finished git checkout master &&
566 git checkout HEAD^0 &&
567 git branch my11 &&
568 test -z "$(git config branch.my11.remote)" &&
569 test -z "$(git config branch.my11.merge)"
572 test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
573 git config branch.autosetuprebase garbage &&
574 test_must_fail git branch
577 test_expect_success 'detect misconfigured autosetuprebase (no value)' '
578 git config --unset branch.autosetuprebase &&
579 echo "[branch] autosetuprebase" >> .git/config &&
580 test_must_fail git branch &&
581 git config --unset branch.autosetuprebase
584 test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
585 git checkout my9 &&
586 git config --unset branch.my8.merge &&
587 test_must_fail git branch -d my8
590 test_expect_success 'attempt to delete a branch merged to its base' '
591 # we are on my9 which is the initial commit; traditionally
592 # we would not have allowed deleting my8 that is not merged
593 # to my9, but it is set to track master that already has my8
594 git config branch.my8.merge refs/heads/master &&
595 git branch -d my8
598 test_expect_success 'attempt to delete a branch merged to its base' '
599 git checkout master &&
600 echo Third >>A &&
601 git commit -m "Third commit" A &&
602 git branch -t my10 my9 &&
603 git branch -f my10 HEAD^ &&
604 # we are on master which is at the third commit, and my10
605 # is behind us, so traditionally we would have allowed deleting
606 # it; but my10 is set to track my9 that is further behind.
607 test_must_fail git branch -d my10
610 test_expect_success 'use set-upstream on the current branch' '
611 git checkout master &&
612 git --bare init myupstream.git &&
613 git push myupstream.git master:refs/heads/frotz &&
614 git remote add origin myupstream.git &&
615 git fetch &&
616 git branch --set-upstream master origin/frotz &&
618 test "z$(git config branch.master.remote)" = "zorigin" &&
619 test "z$(git config branch.master.merge)" = "zrefs/heads/frotz"
623 test_done