(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"git branch assorted tests">)}
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <"prepare a trivial repository">)} 
      {
        (SQ <"\n"> <"\techo Hello >A &&\n"> <"\tgit update-index --add A &&\n"> 
          <"\tgit commit -m \"Initial commit.\" &&\n"> <"\techo World >>A &&\n"> <"\tgit update-index --add A &&\n"> 
          <"\tgit commit -m \"Second commit.\" &&\n"> <"\tHEAD=$(git rev-parse --verify HEAD)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch --help should not have created a bogus branch">)} 
      {
        (SQ <"\n"> <"\ttest_might_fail git branch --man --help </dev/null >/dev/null 2>&1 &&\n"> 
          <"\ttest_path_is_missing .git/refs/heads/--help\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"branch -h in broken repository">)} 
      {
        (SQ <"\n"> <"\tmkdir broken &&\n"> <"\t(\n"> <"\t\tcd broken &&\n"> <"\t\tgit init &&\n"> 
          <"\t\t>.git/refs/heads/master &&\n"> <"\t\ttest_expect_code 129 git branch -h >usage 2>&1\n"> <"\t) &&\n"> 
          <"\ttest_i18ngrep \"[Uu]sage\" broken/usage\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch abc should create a branch">)} 
      {(SQ <"\n"> <"\tgit branch abc && test_path_is_file .git/refs/heads/abc\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch a/b/c should create a branch">)} 
      {(SQ <"\n"> <"\tgit branch a/b/c && test_path_is_file .git/refs/heads/a/b/c\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch HEAD should fail">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch HEAD\n">)}
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[112])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ VSub_Name "$_z40") (" ") ($ VSub_Name "$HEAD") (" ") 
                ($ VSub_Name "$GIT_COMMITTER_NAME") (" <") ($ VSub_Name "$GIT_COMMITTER_EMAIL") ("> 1117150200 +0000\tbranch: Created from master\n")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [115]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"git branch -l d/e/f should create a branch and a log">)} 
      {
        (SQ <"\n"> <"\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n"> <"\tgit branch -l d/e/f &&\n"> 
          <"\ttest_path_is_file .git/refs/heads/d/e/f &&\n"> <"\ttest_path_is_file .git/logs/refs/heads/d/e/f &&\n"> 
          <"\ttest_cmp expect .git/logs/refs/heads/d/e/f\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -d d/e/f should delete a branch and a log">)} 
      {
        (SQ <"\n"> <"\tgit branch -d d/e/f &&\n"> <"\ttest_path_is_missing .git/refs/heads/d/e/f &&\n"> 
          <"\ttest_must_fail git reflog exists refs/heads/d/e/f\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch j/k should work after branch j has been deleted">)} 
      {(SQ <"\n"> <"\tgit branch j &&\n"> <"\tgit branch -d j &&\n"> <"\tgit branch j/k\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch l should work after branch l/m has been deleted">)} 
      {(SQ <"\n"> <"\tgit branch l/m &&\n"> <"\tgit branch -d l/m &&\n"> <"\tgit branch l\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch -m dumps usage">)} 
      {
        (SQ <"\n"> <"\ttest_expect_code 128 git branch -m 2>err &&\n"> 
          <"\ttest_i18ngrep \"branch name required\" err\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -m m broken_symref should work">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished \"git branch -D broken_symref\" &&\n"> 
          <"\tgit branch -l m &&\n"> <"\tgit symbolic-ref refs/heads/broken_symref refs/heads/i_am_broken &&\n"> 
          <"\tgit branch -m m broken_symref &&\n"> <"\tgit reflog exists refs/heads/broken_symref &&\n"> 
          <"\ttest_must_fail git reflog exists refs/heads/i_am_broken\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -m m m/m should work">)} 
      {
        (SQ <"\n"> <"\tgit branch -l m &&\n"> <"\tgit branch -m m m/m &&\n"> 
          <"\tgit reflog exists refs/heads/m/m\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -m n/n n should work">)} 
      {
        (SQ <"\n"> <"\tgit branch -l n/n &&\n"> <"\tgit branch -m n/n n &&\n"> 
          <"\tgit reflog exists refs/heads/n\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -m o/o o should fail when o/p exists">)} 
      {
        (SQ <"\n"> <"\tgit branch o/o &&\n"> <"\tgit branch o/p &&\n"> 
          <"\ttest_must_fail git branch -m o/o o\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -m o/q o/p should fail when o/p exists">)} 
      {(SQ <"\n"> <"\tgit branch o/q &&\n"> <"\ttest_must_fail git branch -m o/q o/p\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch -M o/q o/p should work when o/p exists">)} 
      {(SQ <"\n"> <"\tgit branch -M o/q o/p\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch -m -f o/q o/p should work when o/p exists">)} 
      {(SQ <"\n"> <"\tgit branch o/q &&\n"> <"\tgit branch -m -f o/q o/p\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch -m q r/q should fail when r exists">)} 
      {
        (SQ <"\n"> <"\tgit branch q &&\n"> <"\tgit branch r &&\n"> 
          <"\ttest_must_fail git branch -m q r/q\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -M foo bar should fail when bar is checked out">)} 
      {
        (SQ <"\n"> <"\tgit branch bar &&\n"> <"\tgit checkout -b foo &&\n"> 
          <"\ttest_must_fail git branch -M bar foo\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -M baz bam should succeed when baz is checked out">)} 
      {
        (SQ <"\n"> <"\tgit checkout -b baz &&\n"> <"\tgit branch bam &&\n"> 
          <"\tgit branch -M baz bam &&\n"> <"\ttest $(git rev-parse --abbrev-ref HEAD) = bam\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"git branch -M baz bam should succeed when baz is checked out as linked working tree">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit worktree add -b baz bazdir &&\n"> 
          <"\tgit worktree add -f bazdir2 baz &&\n"> <"\tgit branch -M baz bam &&\n"> <"\ttest $(git -C bazdir rev-parse --abbrev-ref HEAD) = bam &&\n"> 
          <"\ttest $(git -C bazdir2 rev-parse --abbrev-ref HEAD) = bam\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"git branch -M baz bam should succeed within a worktree in which baz is checked out">)} 
      {
        (SQ <"\n"> <"\tgit checkout -b baz &&\n"> <"\tgit worktree add -f bazdir3 baz &&\n"> <"\t(\n"> 
          <"\t\tcd bazdir3 &&\n"> <"\t\tgit branch -M baz bam &&\n"> <"\t\ttest $(git rev-parse --abbrev-ref HEAD) = bam\n"> <"\t) &&\n"> 
          <"\ttest $(git rev-parse --abbrev-ref HEAD) = bam\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -M master should work when master is checked out">)} 
      {(SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit branch -M master\n">)}
    )
    (C {(test_expect_success)} 
      {(SQ <"git branch -M master master should work when master is checked out">)} {(SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit branch -M master master\n">)}
    )
    (C {(test_expect_success)} 
      {(SQ <"git branch -M master2 master2 should work when master is checked out">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit branch master2 &&\n"> 
          <"\tgit branch -M master2 master2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -v -d t should work">)} 
      {
        (SQ <"\n"> <"\tgit branch t &&\n"> <"\ttest_path_is_file .git/refs/heads/t &&\n"> 
          <"\tgit branch -v -d t &&\n"> <"\ttest_path_is_missing .git/refs/heads/t\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -v -m t s should work">)} 
      {
        (SQ <"\n"> <"\tgit branch t &&\n"> <"\ttest_path_is_file .git/refs/heads/t &&\n"> 
          <"\tgit branch -v -m t s &&\n"> <"\ttest_path_is_missing .git/refs/heads/t &&\n"> <"\ttest_path_is_file .git/refs/heads/s &&\n"> 
          <"\tgit branch -d s\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch -m -d t s should fail">)} 
      {
        (SQ <"\n"> <"\tgit branch t &&\n"> <"\ttest_path_is_file .git/refs/heads/t &&\n"> 
          <"\ttest_must_fail git branch -m -d t s &&\n"> <"\tgit branch -d t &&\n"> <"\ttest_path_is_missing .git/refs/heads/t\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch --list -d t should fail">)} 
      {
        (SQ <"\n"> <"\tgit branch t &&\n"> <"\ttest_path_is_file .git/refs/heads/t &&\n"> 
          <"\ttest_must_fail git branch --list -d t &&\n"> <"\tgit branch -d t &&\n"> <"\ttest_path_is_missing .git/refs/heads/t\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch --column">)} 
      {
        (SQ <"\n"> <"\tCOLUMNS=81 git branch --column=column >actual &&\n"> 
          <"\tcat >expected <<\\EOF &&\n"> <"  a/b/c     bam       foo       l       * master    n         o/p       r\n"> 
          <"  abc       bar       j/k       m/m       master2   o/o       q\n"> <"EOF\n"> <"\ttest_cmp expected actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch --column with an extremely long branch name">)} 
      {
        (SQ <"\n"> <"\tlong=this/is/a/part/of/long/branch/name &&\n"> 
          <"\tlong=z$long/$long/$long/$long &&\n"> <"\ttest_when_finished \"git branch -d $long\" &&\n"> <"\tgit branch $long &&\n"> 
          <"\tCOLUMNS=80 git branch --column=column >actual &&\n"> <"\tcat >expected <<EOF &&\n"> <"  a/b/c\n"> <"  abc\n"> <"  bam\n"> <"  bar\n"> <"  foo\n"> <"  j/k\n"> 
          <"  l\n"> <"  m/m\n"> <"* master\n"> <"  master2\n"> <"  n\n"> <"  o/o\n"> <"  o/p\n"> <"  q\n"> <"  r\n"> 
          <"  $long\n"> <"EOF\n"> <"\ttest_cmp expected actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch with column.*">)} 
      {
        (SQ <"\n"> <"\tgit config column.ui column &&\n"> <"\tgit config column.branch \"dense\" &&\n"> 
          <"\tCOLUMNS=80 git branch >actual &&\n"> <"\tgit config --unset column.branch &&\n"> <"\tgit config --unset column.ui &&\n"> 
          <"\tcat >expected <<\\EOF &&\n"> <"  a/b/c   bam   foo   l   * master    n     o/p   r\n"> 
          <"  abc     bar   j/k   m/m   master2   o/o   q\n"> <"EOF\n"> <"\ttest_cmp expected actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"git branch --column -v should fail">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --column -v\n">)}
    )
    (C {(test_expect_success)} {(SQ <"git branch -v with column.ui ignored">)} 
      {
        (SQ <"\n"> <"\tgit config column.ui column &&\n"> 
          <"\tCOLUMNS=80 git branch -v | cut -c -10 | sed \"s/ *$//\" >actual &&\n"> <"\tgit config --unset column.ui &&\n"> <"\tcat >expected <<\\EOF &&\n"> <"  a/b/c\n"> <"  abc\n"> 
          <"  bam\n"> <"  bar\n"> <"  foo\n"> <"  j/k\n"> <"  l\n"> <"  m/m\n"> <"* master\n"> <"  master2\n"> <"  n\n"> 
          <"  o/o\n"> <"  o/p\n"> <"  q\n"> <"  r\n"> <"EOF\n"> <"\ttest_cmp expected actual\n">
        )
      }
    )
    (C {(mv)} {(.git/config)} {(.git/config-saved)})
    (C {(test_expect_success)} {(SQ <"git branch -m q q2 without config should succeed">)} 
      {(SQ <"\n"> <"\tgit branch -m q q2 &&\n"> <"\tgit branch -m q2 q\n">)}
    )
    (C {(mv)} {(.git/config-saved)} {(.git/config)})
    (C {(git)} {(config)} {(branch.s/s.dummy)} {(Hello)})
    (C {(test_expect_success)} {(SQ <"git branch -m s/s s should work when s/t is deleted">)} 
      {
        (SQ <"\n"> <"\tgit branch -l s/s &&\n"> <"\tgit reflog exists refs/heads/s/s &&\n"> 
          <"\tgit branch -l s/t &&\n"> <"\tgit reflog exists refs/heads/s/t &&\n"> <"\tgit branch -d s/t &&\n"> <"\tgit branch -m s/s s &&\n"> 
          <"\tgit reflog exists refs/heads/s\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"config information was renamed, too">)} 
      {
        (SQ <"\n"> <"\ttest $(git config branch.s.dummy) = Hello &&\n"> 
          <"\ttest_must_fail git config branch.s/s/dummy\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"deleting a symref">)} 
      {
        (SQ <"\n"> <"\tgit branch target &&\n"> 
          <"\tgit symbolic-ref refs/heads/symref refs/heads/target &&\n"> <"\techo \"Deleted branch symref (was refs/heads/target).\" >expect &&\n"> 
          <"\tgit branch -d symref >actual &&\n"> <"\ttest_path_is_file .git/refs/heads/target &&\n"> 
          <"\ttest_path_is_missing .git/refs/heads/symref &&\n"> <"\ttest_i18ncmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"deleting a dangling symref">)} 
      {
        (SQ <"\n"> <"\tgit symbolic-ref refs/heads/dangling-symref nowhere &&\n"> 
          <"\ttest_path_is_file .git/refs/heads/dangling-symref &&\n"> <"\techo \"Deleted branch dangling-symref (was nowhere).\" >expect &&\n"> 
          <"\tgit branch -d dangling-symref >actual &&\n"> <"\ttest_path_is_missing .git/refs/heads/dangling-symref &&\n"> <"\ttest_i18ncmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"deleting a self-referential symref">)} 
      {
        (SQ <"\n"> <"\tgit symbolic-ref refs/heads/self-reference refs/heads/self-reference &&\n"> 
          <"\ttest_path_is_file .git/refs/heads/self-reference &&\n"> <"\techo \"Deleted branch self-reference (was refs/heads/self-reference).\" >expect &&\n"> 
          <"\tgit branch -d self-reference >actual &&\n"> <"\ttest_path_is_missing .git/refs/heads/self-reference &&\n"> <"\ttest_i18ncmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"renaming a symref is not allowed">)} 
      {
        (SQ <"\n"> <"\tgit symbolic-ref refs/heads/master2 refs/heads/master &&\n"> 
          <"\ttest_must_fail git branch -m master2 master3 &&\n"> <"\tgit symbolic-ref refs/heads/master2 &&\n"> <"\ttest_path_is_file .git/refs/heads/master &&\n"> 
          <"\ttest_path_is_missing .git/refs/heads/master3\n">
        )
      }
    )
    (C {(test_expect_success)} {(SYMLINKS)} 
      {(SQ <"git branch -m u v should fail when the reflog for u is a symlink">)} 
      {
        (SQ <"\n"> <"\tgit branch -l u &&\n"> <"\tmv .git/logs/refs/heads/u real-u &&\n"> 
          <"\tln -s real-u .git/logs/refs/heads/u &&\n"> <"\ttest_must_fail git branch -m u v\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test tracking setup via --track">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> 
          <"\tgit branch --track my1 local/master &&\n"> <"\ttest $(git config branch.my1.remote) = local &&\n"> 
          <"\ttest $(git config branch.my1.merge) = refs/heads/master\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test tracking setup (non-wildcard, matching)">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/master:refs/remotes/local/master &&\n"> <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> 
          <"\tgit branch --track my4 local/master &&\n"> <"\ttest $(git config branch.my4.remote) = local &&\n"> 
          <"\ttest $(git config branch.my4.merge) = refs/heads/master\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"tracking setup fails on non-matching refspec">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/s:refs/remotes/local/s &&\n"> <"\ttest_must_fail git branch --track my5 local/master &&\n"> 
          <"\ttest_must_fail git config branch.my5.remote &&\n"> <"\ttest_must_fail git config branch.my5.merge\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test tracking setup via config">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetupmerge true &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch my3 local/master &&\n"> <"\ttest $(git config branch.my3.remote) = local &&\n"> 
          <"\ttest $(git config branch.my3.merge) = refs/heads/master\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test overriding tracking setup via --no-track">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetupmerge true &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track my2 local/master &&\n"> <"\tgit config branch.autosetupmerge false &&\n"> 
          <"\t! test \"$(git config branch.my2.remote)\" = local &&\n"> <"\t! test \"$(git config branch.my2.merge)\" = refs/heads/master\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"no tracking without .fetch entries">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetupmerge true &&\n"> <"\tgit branch my6 s &&\n"> 
          <"\tgit config branch.autosetupmerge false &&\n"> <"\ttest -z \"$(git config branch.my6.remote)\" &&\n"> 
          <"\ttest -z \"$(git config branch.my6.merge)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test tracking setup via --track but deeper">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\t(git show-ref -q refs/remotes/local/o/o || git fetch local) &&\n"> 
          <"\tgit branch --track my7 local/o/o &&\n"> <"\ttest \"$(git config branch.my7.remote)\" = local &&\n"> 
          <"\ttest \"$(git config branch.my7.merge)\" = refs/heads/o/o\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test deleting branch deletes branch config">)} 
      {
        (SQ <"\n"> <"\tgit branch -d my7 &&\n"> <"\ttest -z \"$(git config branch.my7.remote)\" &&\n"> 
          <"\ttest -z \"$(git config branch.my7.merge)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test deleting branch without config">)} 
      {
        (SQ <"\n"> <"\tgit branch my7 s &&\n"> <"\tsha1=$(git rev-parse my7 | cut -c 1-7) &&\n"> 
          <"\techo \"Deleted branch my7 (was $sha1).\" >expect &&\n"> <"\tgit branch -d my7 >actual 2>&1 &&\n"> <"\ttest_i18ncmp expect actual\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"deleting currently checked out branch fails">)} 
      {
        (SQ <"\n"> <"\tgit worktree add -b my7 my7 &&\n"> 
          <"\ttest_must_fail git -C my7 branch -d my7 &&\n"> <"\ttest_must_fail git branch -d my7\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test --track without .fetch entries">)} 
      {
        (SQ <"\n"> <"\tgit branch --track my8 &&\n"> 
          <"\ttest \"$(git config branch.my8.remote)\" &&\n"> <"\ttest \"$(git config branch.my8.merge)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"branch from non-branch HEAD w/autosetupmerge=always">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetupmerge always &&\n"> <"\tgit branch my9 HEAD^ &&\n"> 
          <"\tgit config branch.autosetupmerge false\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"branch from non-branch HEAD w/--track causes failure">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --track my10 HEAD^\n">)}
    )
    (C {(test_expect_success)} {(SQ <"branch from tag w/--track causes failure">)} 
      {(SQ <"\n"> <"\tgit tag foobar &&\n"> <"\ttest_must_fail git branch --track my11 foobar\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--set-upstream-to fails on multiple branches">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --set-upstream-to master a b c\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--set-upstream-to fails on detached HEAD">)} 
      {
        (SQ <"\n"> <"\tgit checkout HEAD^{} &&\n"> 
          <"\ttest_must_fail git branch --set-upstream-to master &&\n"> <"\tgit checkout -\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--set-upstream-to fails on a missing dst branch">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --set-upstream-to master does-not-exist\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--set-upstream-to fails on a missing src branch">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --set-upstream-to does-not-exist master\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--set-upstream-to fails on a non-ref">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --set-upstream-to HEAD^{}\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--set-upstream-to fails on locked config">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished \"rm -f .git/config.lock\" &&\n"> 
          <"\t>.git/config.lock &&\n"> <"\tgit branch locked &&\n"> <"\ttest_must_fail git branch --set-upstream-to locked\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"use --set-upstream-to modify HEAD">)} 
      {
        (SQ <"\n"> <"\ttest_config branch.master.remote foo &&\n"> 
          <"\ttest_config branch.master.merge foo &&\n"> <"\tgit branch my12 &&\n"> <"\tgit branch --set-upstream-to my12 &&\n"> 
          <"\ttest \"$(git config branch.master.remote)\" = \".\" &&\n"> <"\ttest \"$(git config branch.master.merge)\" = \"refs/heads/my12\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"use --set-upstream-to modify a particular branch">)} 
      {
        (SQ <"\n"> <"\tgit branch my13 &&\n"> <"\tgit branch --set-upstream-to master my13 &&\n"> 
          <"\ttest \"$(git config branch.my13.remote)\" = \".\" &&\n"> <"\ttest \"$(git config branch.my13.merge)\" = \"refs/heads/master\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--unset-upstream should fail if given a non-existent branch">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --unset-upstream i-dont-exist\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--unset-upstream should fail if config is locked">)} 
      {
        (SQ <"\n"> <"\ttest_when_finished \"rm -f .git/config.lock\" &&\n"> 
          <"\tgit branch --set-upstream-to locked &&\n"> <"\t>.git/config.lock &&\n"> <"\ttest_must_fail git branch --unset-upstream\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test --unset-upstream on HEAD">)} 
      {
        (SQ <"\n"> <"\tgit branch my14 &&\n"> <"\ttest_config branch.master.remote foo &&\n"> 
          <"\ttest_config branch.master.merge foo &&\n"> <"\tgit branch --set-upstream-to my14 &&\n"> <"\tgit branch --unset-upstream &&\n"> 
          <"\ttest_must_fail git config branch.master.remote &&\n"> <"\ttest_must_fail git config branch.master.merge &&\n"> 
          <"\t# fail for a branch without upstream set\n"> <"\ttest_must_fail git branch --unset-upstream\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--unset-upstream should fail on multiple branches">)} 
      {(SQ <"\n"> <"\ttest_must_fail git branch --unset-upstream a b c\n">)}
    )
    (C {(test_expect_success)} {(SQ <"--unset-upstream should fail on detached HEAD">)} 
      {
        (SQ <"\n"> <"\tgit checkout HEAD^{} &&\n"> 
          <"\ttest_must_fail git branch --unset-upstream &&\n"> <"\tgit checkout -\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"test --unset-upstream on a particular branch">)} 
      {
        (SQ <"\n"> <"\tgit branch my15 &&\n"> <"\tgit branch --set-upstream-to master my14 &&\n"> 
          <"\tgit branch --unset-upstream my14 &&\n"> <"\ttest_must_fail git config branch.my14.remote &&\n"> 
          <"\ttest_must_fail git config branch.my14.merge\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {
        (SQ 
          <
"--set-upstream shows message when creating a new branch that exists as remote-tracking"
          >
        )
      } 
      {
        (SQ <"\n"> <"\tgit update-ref refs/remotes/origin/master HEAD &&\n"> 
          <"\tgit branch --set-upstream origin/master 2>actual &&\n"> <"\ttest_when_finished git update-ref -d refs/remotes/origin/master &&\n"> 
          <"\ttest_when_finished git branch -d origin/master &&\n"> <"\tcat >expected <<EOF &&\n"> 
          <
"The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n"
          > <"\n"> <"If you wanted to make ">
        ) (DQ ("'master'")) (SQ <" track ">) (DQ ("'origin/master'")) 
        (SQ <", do this:\n"> <"\n"> <"    git branch -d origin/master\n"> 
          <"    git branch --set-upstream-to origin/master\n"> <"EOF\n"> <"\ttest_i18ncmp expected actual\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"--set-upstream with two args only shows the deprecation message">)} 
      {
        (SQ <"\n"> <"\tgit branch --set-upstream master my13 2>actual &&\n"> 
          <"\ttest_when_finished git branch --unset-upstream master &&\n"> <"\tcat >expected <<EOF &&\n"> 
          <
"The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n"
          > <"EOF\n"> <"\ttest_i18ncmp expected actual\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"--set-upstream with one arg only shows the deprecation message if the branch existed">)} 
      {
        (SQ <"\n"> <"\tgit branch --set-upstream my13 2>actual &&\n"> 
          <"\ttest_when_finished git branch --unset-upstream my13 &&\n"> <"\tcat >expected <<EOF &&\n"> 
          <
"The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n"
          > <"EOF\n"> <"\ttest_i18ncmp expected actual\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"--set-upstream-to notices an error to set branch as own upstream">)} 
      {
        (SQ <"\n"> <"\tgit branch --set-upstream-to refs/heads/my13 my13 2>actual &&\n"> 
          <"\tcat >expected <<-\\EOF &&\n"> <"\twarning: Not setting branch my13 as its own upstream.\n"> <"\tEOF\n"> 
          <"\ttest_expect_code 1 git config branch.my13.remote &&\n"> <"\ttest_expect_code 1 git config branch.my13.merge &&\n"> <"\ttest_i18ncmp expected actual\n">
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[1256])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {
              (DQ ($ VSub_Name "$_z40") (" ") ($ VSub_Name "$HEAD") (" ") 
                ($ VSub_Name "$GIT_COMMITTER_NAME") (" <") ($ VSub_Name "$GIT_COMMITTER_EMAIL") ("> 1117150200 +0000\tbranch: Created from master\n")
              )
            }
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [1259]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <"git checkout -b g/h/i -l should create a branch and a log">)} 
      {
        (SQ <"\n"> <"\tGIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n"> 
          <"\tgit checkout -b g/h/i -l master &&\n"> <"\ttest_path_is_file .git/refs/heads/g/h/i &&\n"> 
          <"\ttest_path_is_file .git/logs/refs/heads/g/h/i &&\n"> <"\ttest_cmp expect .git/logs/refs/heads/g/h/i\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"checkout -b makes reflog by default">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit config --unset core.logAllRefUpdates &&\n"> 
          <"\tgit checkout -b alpha &&\n"> <"\tgit rev-parse --verify alpha@{0}\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"checkout -b does not make reflog when core.logAllRefUpdates = false">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit config core.logAllRefUpdates false &&\n"> 
          <"\tgit checkout -b beta &&\n"> <"\ttest_must_fail git rev-parse --verify beta@{0}\n">
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <"checkout -b with -l makes reflog when core.logAllRefUpdates = false">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit checkout -lb gamma &&\n"> 
          <"\tgit config --unset core.logAllRefUpdates &&\n"> <"\tgit rev-parse --verify gamma@{0}\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"avoid ambiguous track">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetupmerge true &&\n"> 
          <"\tgit config remote.ambi1.url lalala &&\n"> <"\tgit config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&\n"> 
          <"\tgit config remote.ambi2.url lilili &&\n"> <"\tgit config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&\n"> 
          <"\ttest_must_fail git branch all1 master &&\n"> <"\ttest -z \"$(git config branch.all1.merge)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase local on a tracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase local &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n"> <"\tgit branch mybase &&\n"> <"\tgit branch --track myr1 mybase &&\n"> 
          <"\ttest \"$(git config branch.myr1.remote)\" = . &&\n"> <"\ttest \"$(git config branch.myr1.merge)\" = refs/heads/mybase &&\n"> 
          <"\ttest \"$(git config branch.myr1.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase always on a tracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase always &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n"> <"\tgit branch mybase2 &&\n"> <"\tgit branch --track myr2 mybase &&\n"> 
          <"\ttest \"$(git config branch.myr2.remote)\" = . &&\n"> <"\ttest \"$(git config branch.myr2.merge)\" = refs/heads/mybase &&\n"> 
          <"\ttest \"$(git config branch.myr2.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase remote on a tracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase remote &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n"> <"\tgit branch mybase3 &&\n"> <"\tgit branch --track myr3 mybase2 &&\n"> 
          <"\ttest \"$(git config branch.myr3.remote)\" = . &&\n"> <"\ttest \"$(git config branch.myr3.merge)\" = refs/heads/mybase2 &&\n"> 
          <"\t! test \"$(git config branch.myr3.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase never on a tracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase never &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n"> <"\tgit branch mybase4 &&\n"> <"\tgit branch --track myr4 mybase2 &&\n"> 
          <"\ttest \"$(git config branch.myr4.remote)\" = . &&\n"> <"\ttest \"$(git config branch.myr4.merge)\" = refs/heads/mybase2 &&\n"> 
          <"\t! test \"$(git config branch.myr4.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase local on a tracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase local &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --track myr5 local/master &&\n"> 
          <"\ttest \"$(git config branch.myr5.remote)\" = local &&\n"> <"\ttest \"$(git config branch.myr5.merge)\" = refs/heads/master &&\n"> 
          <"\t! test \"$(git config branch.myr5.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase never on a tracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase never &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --track myr6 local/master &&\n"> 
          <"\ttest \"$(git config branch.myr6.remote)\" = local &&\n"> <"\ttest \"$(git config branch.myr6.merge)\" = refs/heads/master &&\n"> 
          <"\t! test \"$(git config branch.myr6.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase remote on a tracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase remote &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --track myr7 local/master &&\n"> 
          <"\ttest \"$(git config branch.myr7.remote)\" = local &&\n"> <"\ttest \"$(git config branch.myr7.merge)\" = refs/heads/master &&\n"> 
          <"\ttest \"$(git config branch.myr7.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase always on a tracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\tgit config branch.autosetuprebase remote &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --track myr8 local/master &&\n"> 
          <"\ttest \"$(git config branch.myr8.remote)\" = local &&\n"> <"\ttest \"$(git config branch.myr8.merge)\" = refs/heads/master &&\n"> 
          <"\ttest \"$(git config branch.myr8.rebase)\" = true\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase unconfigured on a tracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config --unset branch.autosetuprebase &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --track myr9 local/master &&\n"> 
          <"\ttest \"$(git config branch.myr9.remote)\" = local &&\n"> <"\ttest \"$(git config branch.myr9.merge)\" = refs/heads/master &&\n"> 
          <"\ttest \"z$(git config branch.myr9.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase unconfigured on a tracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\t(git show-ref -q refs/remotes/local/o || git fetch local) &&\n"> <"\tgit branch mybase10 &&\n"> 
          <"\tgit branch --track myr10 mybase2 &&\n"> <"\ttest \"$(git config branch.myr10.remote)\" = . &&\n"> 
          <"\ttest \"$(git config branch.myr10.merge)\" = refs/heads/mybase2 &&\n"> <"\ttest \"z$(git config branch.myr10.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase unconfigured on untracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> 
          <"\tgit branch --no-track myr11 mybase2 &&\n"> <"\ttest \"z$(git config branch.myr11.remote)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr11.merge)\" = z &&\n"> <"\ttest \"z$(git config branch.myr11.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase unconfigured on untracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config remote.local.url . &&\n"> 
          <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> 
          <"\tgit branch --no-track myr12 local/master &&\n"> <"\ttest \"z$(git config branch.myr12.remote)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr12.merge)\" = z &&\n"> <"\ttest \"z$(git config branch.myr12.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase never on an untracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase never &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr13 mybase2 &&\n"> 
          <"\ttest \"z$(git config branch.myr13.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr13.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr13.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase local on an untracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase local &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr14 mybase2 &&\n"> 
          <"\ttest \"z$(git config branch.myr14.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr14.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr14.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase remote on an untracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase remote &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr15 mybase2 &&\n"> 
          <"\ttest \"z$(git config branch.myr15.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr15.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr15.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase always on an untracked local branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase always &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr16 mybase2 &&\n"> 
          <"\ttest \"z$(git config branch.myr16.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr16.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr16.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase never on an untracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase never &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr17 local/master &&\n"> 
          <"\ttest \"z$(git config branch.myr17.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr17.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr17.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase local on an untracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase local &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr18 local/master &&\n"> 
          <"\ttest \"z$(git config branch.myr18.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr18.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr18.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase remote on an untracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase remote &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr19 local/master &&\n"> 
          <"\ttest \"z$(git config branch.myr19.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr19.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr19.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase always on an untracked remote branch">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase always &&\n"> 
          <"\tgit config remote.local.url . &&\n"> <"\tgit config remote.local.fetch refs/heads/*:refs/remotes/local/* &&\n"> 
          <"\t(git show-ref -q refs/remotes/local/master || git fetch local) &&\n"> <"\tgit branch --no-track myr20 local/master &&\n"> 
          <"\ttest \"z$(git config branch.myr20.remote)\" = z &&\n"> <"\ttest \"z$(git config branch.myr20.merge)\" = z &&\n"> 
          <"\ttest \"z$(git config branch.myr20.rebase)\" = z\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"autosetuprebase always on detached HEAD">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetupmerge always &&\n"> 
          <"\ttest_when_finished git checkout master &&\n"> <"\tgit checkout HEAD^0 &&\n"> <"\tgit branch my11 &&\n"> 
          <"\ttest -z \"$(git config branch.my11.remote)\" &&\n"> <"\ttest -z \"$(git config branch.my11.merge)\"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"detect misconfigured autosetuprebase (bad value)">)} 
      {
        (SQ <"\n"> <"\tgit config branch.autosetuprebase garbage &&\n"> 
          <"\ttest_must_fail git branch\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"detect misconfigured autosetuprebase (no value)">)} 
      {
        (SQ <"\n"> <"\tgit config --unset branch.autosetuprebase &&\n"> 
          <"\techo \"[branch] autosetuprebase\" >>.git/config &&\n"> <"\ttest_must_fail git branch &&\n"> <"\tgit config --unset branch.autosetuprebase\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"attempt to delete a branch without base and unmerged to HEAD">)} 
      {
        (SQ <"\n"> <"\tgit checkout my9 &&\n"> <"\tgit config --unset branch.my8.merge &&\n"> 
          <"\ttest_must_fail git branch -d my8\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"attempt to delete a branch merged to its base">)} 
      {
        (SQ <"\n"> <"\t# we are on my9 which is the initial commit; traditionally\n"> 
          <"\t# we would not have allowed deleting my8 that is not merged\n"> <"\t# to my9, but it is set to track master that already has my8\n"> 
          <"\tgit config branch.my8.merge refs/heads/master &&\n"> <"\tgit branch -d my8\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"attempt to delete a branch merged to its base">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\techo Third >>A &&\n"> 
          <"\tgit commit -m \"Third commit\" A &&\n"> <"\tgit branch -t my10 my9 &&\n"> <"\tgit branch -f my10 HEAD^ &&\n"> 
          <"\t# we are on master which is at the third commit, and my10\n"> <"\t# is behind us, so traditionally we would have allowed deleting\n"> 
          <"\t# it; but my10 is set to track my9 that is further behind.\n"> <"\ttest_must_fail git branch -d my10\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"use set-upstream on the current branch">)} 
      {
        (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit --bare init myupstream.git &&\n"> 
          <"\tgit push myupstream.git master:refs/heads/frotz &&\n"> <"\tgit remote add origin myupstream.git &&\n"> <"\tgit fetch &&\n"> 
          <"\tgit branch --set-upstream master origin/frotz &&\n"> <"\n"> <"\ttest \"z$(git config branch.master.remote)\" = \"zorigin\" &&\n"> 
          <"\ttest \"z$(git config branch.master.merge)\" = \"zrefs/heads/frotz\"\n"> <"\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"use --edit-description">)} 
      {
        (SQ <"\n"> <"\twrite_script editor <<-\\EOF &&\n"> <"\t\techo \"New contents\" >\"$1\"\n"> 
          <"\tEOF\n"> <"\tEDITOR=./editor git branch --edit-description &&\n"> <"\t\twrite_script editor <<-\\EOF &&\n"> 
          <"\t\tgit stripspace -s <\"$1\" >\"EDITOR_OUTPUT\"\n"> <"\tEOF\n"> <"\tEDITOR=./editor git branch --edit-description &&\n"> 
          <"\techo \"New contents\" >expect &&\n"> <"\ttest_cmp EDITOR_OUTPUT expect\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"detect typo in branch name when using --edit-description">)} 
      {
        (SQ <"\n"> <"\twrite_script editor <<-\\EOF &&\n"> <"\t\techo \"New contents\" >\"$1\"\n"> 
          <"\tEOF\n"> <"\ttest_must_fail env EDITOR=./editor git branch --edit-description no-such-branch\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"refuse --edit-description on unborn branch for now">)} 
      {
        (SQ <"\n"> <"\twrite_script editor <<-\\EOF &&\n"> <"\t\techo \"New contents\" >\"$1\"\n"> 
          <"\tEOF\n"> <"\tgit checkout --orphan unborn &&\n"> 
          <"\ttest_must_fail env EDITOR=./editor git branch --edit-description\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--merged catches invalid object names">)} 
      {
        (SQ <"\n"> <"\ttest_must_fail git branch --merged 0000000000000000000000000000000000000000\n">)
      }
    )
    (C {(test_expect_success)} {(SQ <"tracking with unexpected .fetch refspec">)} 
      {
        (SQ <"\n"> <"\trm -rf a b c d &&\n"> <"\tgit init a &&\n"> <"\t(\n"> <"\t\tcd a &&\n"> 
          <"\t\ttest_commit a\n"> <"\t) &&\n"> <"\tgit init b &&\n"> <"\t(\n"> <"\t\tcd b &&\n"> <"\t\ttest_commit b\n"> <"\t) &&\n"> 
          <"\tgit init c &&\n"> <"\t(\n"> <"\t\tcd c &&\n"> <"\t\ttest_commit c &&\n"> <"\t\tgit remote add a ../a &&\n"> 
          <"\t\tgit remote add b ../b &&\n"> <"\t\tgit fetch --all\n"> <"\t) &&\n"> <"\tgit init d &&\n"> <"\t(\n"> <"\t\tcd d &&\n"> 
          <"\t\tgit remote add c ../c &&\n"> <"\t\tgit config remote.c.fetch \"+refs/remotes/*:refs/remotes/*\" &&\n"> <"\t\tgit fetch c &&\n"> 
          <"\t\tgit branch --track local/a/master remotes/a/master &&\n"> <"\t\ttest \"$(git config branch.local/a/master.remote)\" = \"c\" &&\n"> 
          <
"\t\ttest \"$(git config branch.local/a/master.merge)\" = \"refs/remotes/a/master\" &&\n"
          > <"\t\tgit rev-parse --verify a >expect &&\n"> 
          <"\t\tgit rev-parse --verify local/a/master >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n">
        )
      }
    )
    (C {(test_done)})
  ]
)