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