(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description spids:[12])
          op: Equal
          rhs: {(SQ <'clone --branch option'>)}
          spids: [12]
        )
      ]
      spids: [12]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.FuncDef
      name: check_HEAD
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (command.SimpleCommand
                  words: [{(echo)} {(refs/heads/) (DQ ($ VSub_Number '$1'))}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})]
                )
                (command.SimpleCommand
                  words: [{(git)} {(symbolic-ref)} {(HEAD)}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})]
                )
                (C {(test_cmp)} {(expect)} {(actual)})
              ]
            )
          ]
          spids: [26]
        )
      spids: [22 25]
    )
    (command.FuncDef
      name: check_file
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (command.SimpleCommand
                  words: [{(echo)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})]
                )
                (C {(test_cmp)} {(expect)} {(file)})
              ]
            )
          ]
          spids: [67]
        )
      spids: [63 66]
    )
    (C {(test_expect_success)} {(SQ <setup>)} 
      {
        (SQ <'\n'> <'\tmkdir parent &&\n'> <'\t(cd parent && git init &&\n'> 
          <'\t echo one >file && git add file && git commit -m one &&\n'> <'\t git checkout -b two &&\n'> <'\t echo two >file && git add file && git commit -m two &&\n'> 
          <'\t git checkout master) &&\n'> <'\tmkdir empty &&\n'> <'\t(cd empty && git init)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'vanilla clone chooses HEAD'>)} 
      {
        (SQ <'\n'> <'\tgit clone parent clone &&\n'> <'\t(cd clone &&\n'> <'\t check_HEAD master &&\n'> 
          <'\t check_file one\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone -b chooses specified branch'>)} 
      {
        (SQ <'\n'> <'\tgit clone -b two parent clone-two &&\n'> <'\t(cd clone-two &&\n'> 
          <'\t check_HEAD two &&\n'> <'\t check_file two\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone -b sets up tracking'>)} 
      {
        (SQ <'\n'> <'\t(cd clone-two &&\n'> <'\t echo origin >expect &&\n'> 
          <'\t git config branch.two.remote >actual &&\n'> <'\t echo refs/heads/two >>expect &&\n'> <'\t git config branch.two.merge >>actual &&\n'> 
          <'\t test_cmp expect actual\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone -b does not munge remotes/origin/HEAD'>)} 
      {
        (SQ <'\n'> <'\t(cd clone-two &&\n'> <'\t echo refs/remotes/origin/master >expect &&\n'> 
          <'\t git symbolic-ref refs/remotes/origin/HEAD >actual &&\n'> <'\t test_cmp expect actual\n'> <'\t)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'clone -b with bogus branch'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git clone -b bogus parent clone-bogus\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'clone -b not allowed with empty repos'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git clone -b branch empty clone-branch-empty\n'>)}
    )
    (C {(test_done)})
  ]
)