(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"clone --branch option">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: check_HEAD
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(echo)} {(refs/heads/) (DQ ($ VSub_Number "$1"))}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[28])]
                )
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [{(git)} {(symbolic-ref)} {(HEAD)}]
                      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[40])]
                    )
                    (C {(test_cmp)} {(expect)} {(actual)})
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [18]
        )
      spids: [14 17]
    )
    (FuncDef
      name: check_file
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(echo)} {(DQ ($ VSub_Number "$1"))}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[68])]
                )
                (C {(test_cmp)} {(expect)} {(file)})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [59]
        )
      spids: [55 58]
    )
    (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)})
  ]
)