t / t3200-branch.shon commit branch: -v does not automatically imply --list (7b78759)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Amos Waterland
   4#
   5
   6test_description='git branch --foo should not create bogus branch
   7
   8This test runs git branch --help and checks that the argument is properly
   9handled.  Specifically, that a bogus branch is not created.
  10'
  11. ./test-lib.sh
  12
  13test_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)'
  22
  23test_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 -f .git/refs/heads/--help
  27'
  28
  29test_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'
  39
  40test_expect_success \
  41    'git branch abc should create a branch' \
  42    'git branch abc && test -f .git/refs/heads/abc'
  43
  44test_expect_success \
  45    'git branch a/b/c should create a branch' \
  46    'git branch a/b/c && test -f .git/refs/heads/a/b/c'
  47
  48cat >expect <<EOF
  49$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
  50EOF
  51test_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 -f .git/refs/heads/d/e/f &&
  56         test -f .git/logs/refs/heads/d/e/f &&
  57         test_cmp expect .git/logs/refs/heads/d/e/f'
  58
  59test_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 ! -f .git/refs/heads/d/e/f &&
  63         test ! -f .git/logs/refs/heads/d/e/f'
  64
  65test_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'
  70
  71test_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'
  76
  77test_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 -f .git/logs/refs/heads/m/m'
  82
  83test_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 -f .git/logs/refs/heads/n'
  88
  89test_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'
  94
  95test_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'
 100
 101test_expect_success 'git branch -v -d t should work' '
 102        git branch t &&
 103        test .git/refs/heads/t &&
 104        git branch -v -d t &&
 105        test ! -f .git/refs/heads/t
 106'
 107
 108test_expect_success 'git branch -v -m t s should work' '
 109        git branch t &&
 110        test .git/refs/heads/t &&
 111        git branch -v -m t s &&
 112        test ! -f .git/refs/heads/t &&
 113        test -f .git/refs/heads/s &&
 114        git branch -d s
 115'
 116
 117test_expect_success 'git branch -m -d t s should fail' '
 118        git branch t &&
 119        test .git/refs/heads/t &&
 120        test_must_fail git branch -m -d t s &&
 121        git branch -d t &&
 122        test ! -f .git/refs/heads/t
 123'
 124
 125test_expect_success 'git branch --list -d t should fail' '
 126        git branch t &&
 127        test .git/refs/heads/t &&
 128        test_must_fail git branch --list -d t &&
 129        git branch -d t &&
 130        test ! -f .git/refs/heads/t
 131'
 132
 133mv .git/config .git/config-saved
 134
 135test_expect_success 'git branch -m q q2 without config should succeed' '
 136        git branch -m q q2 &&
 137        git branch -m q2 q
 138'
 139
 140mv .git/config-saved .git/config
 141
 142git config branch.s/s.dummy Hello
 143
 144test_expect_success \
 145    'git branch -m s/s s should work when s/t is deleted' \
 146       'git branch -l s/s &&
 147        test -f .git/logs/refs/heads/s/s &&
 148        git branch -l s/t &&
 149        test -f .git/logs/refs/heads/s/t &&
 150        git branch -d s/t &&
 151        git branch -m s/s s &&
 152        test -f .git/logs/refs/heads/s'
 153
 154test_expect_success 'config information was renamed, too' \
 155        "test $(git config branch.s.dummy) = Hello &&
 156         test_must_fail git config branch.s/s/dummy"
 157
 158test_expect_success 'renaming a symref is not allowed' \
 159'
 160        git symbolic-ref refs/heads/master2 refs/heads/master &&
 161        test_must_fail git branch -m master2 master3 &&
 162        git symbolic-ref refs/heads/master2 &&
 163        test -f .git/refs/heads/master &&
 164        ! test -f .git/refs/heads/master3
 165'
 166
 167test_expect_success SYMLINKS \
 168    'git branch -m u v should fail when the reflog for u is a symlink' '
 169     git branch -l u &&
 170     mv .git/logs/refs/heads/u real-u &&
 171     ln -s real-u .git/logs/refs/heads/u &&
 172     test_must_fail git branch -m u v
 173'
 174
 175test_expect_success 'test tracking setup via --track' \
 176    'git config remote.local.url . &&
 177     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 178     (git show-ref -q refs/remotes/local/master || git fetch local) &&
 179     git branch --track my1 local/master &&
 180     test $(git config branch.my1.remote) = local &&
 181     test $(git config branch.my1.merge) = refs/heads/master'
 182
 183test_expect_success 'test tracking setup (non-wildcard, matching)' \
 184    'git config remote.local.url . &&
 185     git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
 186     (git show-ref -q refs/remotes/local/master || git fetch local) &&
 187     git branch --track my4 local/master &&
 188     test $(git config branch.my4.remote) = local &&
 189     test $(git config branch.my4.merge) = refs/heads/master'
 190
 191test_expect_success 'test tracking setup (non-wildcard, not matching)' \
 192    'git config remote.local.url . &&
 193     git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
 194     (git show-ref -q refs/remotes/local/master || git fetch local) &&
 195     git branch --track my5 local/master &&
 196     ! test "$(git config branch.my5.remote)" = local &&
 197     ! test "$(git config branch.my5.merge)" = refs/heads/master'
 198
 199test_expect_success 'test tracking setup via config' \
 200    'git config branch.autosetupmerge true &&
 201     git config remote.local.url . &&
 202     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 203     (git show-ref -q refs/remotes/local/master || git fetch local) &&
 204     git branch my3 local/master &&
 205     test $(git config branch.my3.remote) = local &&
 206     test $(git config branch.my3.merge) = refs/heads/master'
 207
 208test_expect_success 'test overriding tracking setup via --no-track' \
 209    'git config branch.autosetupmerge true &&
 210     git config remote.local.url . &&
 211     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 212     (git show-ref -q refs/remotes/local/master || git fetch local) &&
 213     git branch --no-track my2 local/master &&
 214     git config branch.autosetupmerge false &&
 215     ! test "$(git config branch.my2.remote)" = local &&
 216     ! test "$(git config branch.my2.merge)" = refs/heads/master'
 217
 218test_expect_success 'no tracking without .fetch entries' \
 219    'git config branch.autosetupmerge true &&
 220     git branch my6 s &&
 221     git config branch.automsetupmerge false &&
 222     test -z "$(git config branch.my6.remote)" &&
 223     test -z "$(git config branch.my6.merge)"'
 224
 225test_expect_success 'test tracking setup via --track but deeper' \
 226    'git config remote.local.url . &&
 227     git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 228     (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
 229     git branch --track my7 local/o/o &&
 230     test "$(git config branch.my7.remote)" = local &&
 231     test "$(git config branch.my7.merge)" = refs/heads/o/o'
 232
 233test_expect_success 'test deleting branch deletes branch config' \
 234    'git branch -d my7 &&
 235     test -z "$(git config branch.my7.remote)" &&
 236     test -z "$(git config branch.my7.merge)"'
 237
 238test_expect_success 'test deleting branch without config' \
 239    'git branch my7 s &&
 240     sha1=$(git rev-parse my7 | cut -c 1-7) &&
 241     echo "Deleted branch my7 (was $sha1)." >expect &&
 242     git branch -d my7 >actual 2>&1 &&
 243     test_i18ncmp expect actual'
 244
 245test_expect_success 'test --track without .fetch entries' \
 246    'git branch --track my8 &&
 247     test "$(git config branch.my8.remote)" &&
 248     test "$(git config branch.my8.merge)"'
 249
 250test_expect_success \
 251    'branch from non-branch HEAD w/autosetupmerge=always' \
 252    'git config branch.autosetupmerge always &&
 253     git branch my9 HEAD^ &&
 254     git config branch.autosetupmerge false'
 255
 256test_expect_success \
 257    'branch from non-branch HEAD w/--track causes failure' \
 258    'test_must_fail git branch --track my10 HEAD^'
 259
 260test_expect_success \
 261    'branch from tag w/--track causes failure' \
 262    'git tag foobar &&
 263     test_must_fail git branch --track my11 foobar'
 264
 265# Keep this test last, as it changes the current branch
 266cat >expect <<EOF
 267$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
 268EOF
 269test_expect_success \
 270    'git checkout -b g/h/i -l should create a branch and a log' \
 271        'GIT_COMMITTER_DATE="2005-05-26 23:30" \
 272     git checkout -b g/h/i -l master &&
 273         test -f .git/refs/heads/g/h/i &&
 274         test -f .git/logs/refs/heads/g/h/i &&
 275         test_cmp expect .git/logs/refs/heads/g/h/i'
 276
 277test_expect_success 'checkout -b makes reflog by default' '
 278        git checkout master &&
 279        git config --unset core.logAllRefUpdates &&
 280        git checkout -b alpha &&
 281        git rev-parse --verify alpha@{0}
 282'
 283
 284test_expect_success 'checkout -b does not make reflog when core.logAllRefUpdates = false' '
 285        git checkout master &&
 286        git config core.logAllRefUpdates false &&
 287        git checkout -b beta &&
 288        test_must_fail git rev-parse --verify beta@{0}
 289'
 290
 291test_expect_success 'checkout -b with -l makes reflog when core.logAllRefUpdates = false' '
 292        git checkout master &&
 293        git checkout -lb gamma &&
 294        git config --unset core.logAllRefUpdates &&
 295        git rev-parse --verify gamma@{0}
 296'
 297
 298test_expect_success 'avoid ambiguous track' '
 299        git config branch.autosetupmerge true &&
 300        git config remote.ambi1.url lalala &&
 301        git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
 302        git config remote.ambi2.url lilili &&
 303        git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
 304        git branch all1 master &&
 305        test -z "$(git config branch.all1.merge)"
 306'
 307
 308test_expect_success 'autosetuprebase local on a tracked local branch' '
 309        git config remote.local.url . &&
 310        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 311        git config branch.autosetuprebase local &&
 312        (git show-ref -q refs/remotes/local/o || git fetch local) &&
 313        git branch mybase &&
 314        git branch --track myr1 mybase &&
 315        test "$(git config branch.myr1.remote)" = . &&
 316        test "$(git config branch.myr1.merge)" = refs/heads/mybase &&
 317        test "$(git config branch.myr1.rebase)" = true
 318'
 319
 320test_expect_success 'autosetuprebase always 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 always &&
 324        (git show-ref -q refs/remotes/local/o || git fetch local) &&
 325        git branch mybase2 &&
 326        git branch --track myr2 mybase &&
 327        test "$(git config branch.myr2.remote)" = . &&
 328        test "$(git config branch.myr2.merge)" = refs/heads/mybase &&
 329        test "$(git config branch.myr2.rebase)" = true
 330'
 331
 332test_expect_success 'autosetuprebase remote 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 remote &&
 336        (git show-ref -q refs/remotes/local/o || git fetch local) &&
 337        git branch mybase3 &&
 338        git branch --track myr3 mybase2 &&
 339        test "$(git config branch.myr3.remote)" = . &&
 340        test "$(git config branch.myr3.merge)" = refs/heads/mybase2 &&
 341        ! test "$(git config branch.myr3.rebase)" = true
 342'
 343
 344test_expect_success 'autosetuprebase never 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 never &&
 348        (git show-ref -q refs/remotes/local/o || git fetch local) &&
 349        git branch mybase4 &&
 350        git branch --track myr4 mybase2 &&
 351        test "$(git config branch.myr4.remote)" = . &&
 352        test "$(git config branch.myr4.merge)" = refs/heads/mybase2 &&
 353        ! test "$(git config branch.myr4.rebase)" = true
 354'
 355
 356test_expect_success 'autosetuprebase local on a tracked remote branch' '
 357        git config remote.local.url . &&
 358        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 359        git config branch.autosetuprebase local &&
 360        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 361        git branch --track myr5 local/master &&
 362        test "$(git config branch.myr5.remote)" = local &&
 363        test "$(git config branch.myr5.merge)" = refs/heads/master &&
 364        ! test "$(git config branch.myr5.rebase)" = true
 365'
 366
 367test_expect_success 'autosetuprebase never on a tracked remote branch' '
 368        git config remote.local.url . &&
 369        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 370        git config branch.autosetuprebase never &&
 371        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 372        git branch --track myr6 local/master &&
 373        test "$(git config branch.myr6.remote)" = local &&
 374        test "$(git config branch.myr6.merge)" = refs/heads/master &&
 375        ! test "$(git config branch.myr6.rebase)" = true
 376'
 377
 378test_expect_success 'autosetuprebase remote on a tracked remote branch' '
 379        git config remote.local.url . &&
 380        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 381        git config branch.autosetuprebase remote &&
 382        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 383        git branch --track myr7 local/master &&
 384        test "$(git config branch.myr7.remote)" = local &&
 385        test "$(git config branch.myr7.merge)" = refs/heads/master &&
 386        test "$(git config branch.myr7.rebase)" = true
 387'
 388
 389test_expect_success 'autosetuprebase always 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 remote &&
 393        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 394        git branch --track myr8 local/master &&
 395        test "$(git config branch.myr8.remote)" = local &&
 396        test "$(git config branch.myr8.merge)" = refs/heads/master &&
 397        test "$(git config branch.myr8.rebase)" = true
 398'
 399
 400test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' '
 401        git config --unset branch.autosetuprebase &&
 402        git config remote.local.url . &&
 403        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 404        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 405        git branch --track myr9 local/master &&
 406        test "$(git config branch.myr9.remote)" = local &&
 407        test "$(git config branch.myr9.merge)" = refs/heads/master &&
 408        test "z$(git config branch.myr9.rebase)" = z
 409'
 410
 411test_expect_success 'autosetuprebase unconfigured on a tracked local branch' '
 412        git config remote.local.url . &&
 413        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 414        (git show-ref -q refs/remotes/local/o || git fetch local) &&
 415        git branch mybase10 &&
 416        git branch --track myr10 mybase2 &&
 417        test "$(git config branch.myr10.remote)" = . &&
 418        test "$(git config branch.myr10.merge)" = refs/heads/mybase2 &&
 419        test "z$(git config branch.myr10.rebase)" = z
 420'
 421
 422test_expect_success 'autosetuprebase unconfigured on untracked local branch' '
 423        git config remote.local.url . &&
 424        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 425        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 426        git branch --no-track myr11 mybase2 &&
 427        test "z$(git config branch.myr11.remote)" = z &&
 428        test "z$(git config branch.myr11.merge)" = z &&
 429        test "z$(git config branch.myr11.rebase)" = z
 430'
 431
 432test_expect_success 'autosetuprebase unconfigured on untracked remote branch' '
 433        git config remote.local.url . &&
 434        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 435        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 436        git branch --no-track myr12 local/master &&
 437        test "z$(git config branch.myr12.remote)" = z &&
 438        test "z$(git config branch.myr12.merge)" = z &&
 439        test "z$(git config branch.myr12.rebase)" = z
 440'
 441
 442test_expect_success 'autosetuprebase never on an untracked local branch' '
 443        git config branch.autosetuprebase never &&
 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 --no-track myr13 mybase2 &&
 448        test "z$(git config branch.myr13.remote)" = z &&
 449        test "z$(git config branch.myr13.merge)" = z &&
 450        test "z$(git config branch.myr13.rebase)" = z
 451'
 452
 453test_expect_success 'autosetuprebase local on an untracked local branch' '
 454        git config branch.autosetuprebase local &&
 455        git config remote.local.url . &&
 456        git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
 457        (git show-ref -q refs/remotes/local/master || git fetch local) &&
 458        git branch --no-track myr14 mybase2 &&
 459        test "z$(git config branch.myr14.remote)" = z &&
 460        test "z$(git config branch.myr14.merge)" = z &&
 461        test "z$(git config branch.myr14.rebase)" = z
 462'
 463
 464test_expect_success 'autosetuprebase remote on an untracked local branch' '
 465        git config branch.autosetuprebase remote &&
 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 myr15 mybase2 &&
 470        test "z$(git config branch.myr15.remote)" = z &&
 471        test "z$(git config branch.myr15.merge)" = z &&
 472        test "z$(git config branch.myr15.rebase)" = z
 473'
 474
 475test_expect_success 'autosetuprebase always on an untracked local branch' '
 476        git config branch.autosetuprebase always &&
 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 myr16 mybase2 &&
 481        test "z$(git config branch.myr16.remote)" = z &&
 482        test "z$(git config branch.myr16.merge)" = z &&
 483        test "z$(git config branch.myr16.rebase)" = z
 484'
 485
 486test_expect_success 'autosetuprebase never on an untracked remote branch' '
 487        git config branch.autosetuprebase never &&
 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 myr17 local/master &&
 492        test "z$(git config branch.myr17.remote)" = z &&
 493        test "z$(git config branch.myr17.merge)" = z &&
 494        test "z$(git config branch.myr17.rebase)" = z
 495'
 496
 497test_expect_success 'autosetuprebase local on an untracked remote branch' '
 498        git config branch.autosetuprebase local &&
 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 myr18 local/master &&
 503        test "z$(git config branch.myr18.remote)" = z &&
 504        test "z$(git config branch.myr18.merge)" = z &&
 505        test "z$(git config branch.myr18.rebase)" = z
 506'
 507
 508test_expect_success 'autosetuprebase remote on an untracked remote branch' '
 509        git config branch.autosetuprebase remote &&
 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 myr19 local/master &&
 514        test "z$(git config branch.myr19.remote)" = z &&
 515        test "z$(git config branch.myr19.merge)" = z &&
 516        test "z$(git config branch.myr19.rebase)" = z
 517'
 518
 519test_expect_success 'autosetuprebase always on an untracked remote branch' '
 520        git config branch.autosetuprebase always &&
 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 myr20 local/master &&
 525        test "z$(git config branch.myr20.remote)" = z &&
 526        test "z$(git config branch.myr20.merge)" = z &&
 527        test "z$(git config branch.myr20.rebase)" = z
 528'
 529
 530test_expect_success 'autosetuprebase always on detached HEAD' '
 531        git config branch.autosetupmerge always &&
 532        test_when_finished git checkout master &&
 533        git checkout HEAD^0 &&
 534        git branch my11 &&
 535        test -z "$(git config branch.my11.remote)" &&
 536        test -z "$(git config branch.my11.merge)"
 537'
 538
 539test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
 540        git config branch.autosetuprebase garbage &&
 541        test_must_fail git branch
 542'
 543
 544test_expect_success 'detect misconfigured autosetuprebase (no value)' '
 545        git config --unset branch.autosetuprebase &&
 546        echo "[branch] autosetuprebase" >> .git/config &&
 547        test_must_fail git branch &&
 548        git config --unset branch.autosetuprebase
 549'
 550
 551test_expect_success 'attempt to delete a branch without base and unmerged to HEAD' '
 552        git checkout my9 &&
 553        git config --unset branch.my8.merge &&
 554        test_must_fail git branch -d my8
 555'
 556
 557test_expect_success 'attempt to delete a branch merged to its base' '
 558        # we are on my9 which is the initial commit; traditionally
 559        # we would not have allowed deleting my8 that is not merged
 560        # to my9, but it is set to track master that already has my8
 561        git config branch.my8.merge refs/heads/master &&
 562        git branch -d my8
 563'
 564
 565test_expect_success 'attempt to delete a branch merged to its base' '
 566        git checkout master &&
 567        echo Third >>A &&
 568        git commit -m "Third commit" A &&
 569        git branch -t my10 my9 &&
 570        git branch -f my10 HEAD^ &&
 571        # we are on master which is at the third commit, and my10
 572        # is behind us, so traditionally we would have allowed deleting
 573        # it; but my10 is set to track my9 that is further behind.
 574        test_must_fail git branch -d my10
 575'
 576
 577test_done