3 test_description
='clone --branch option'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
11 echo refs
/heads
/"$1" >expect
&&
12 git symbolic-ref HEAD
>actual
&&
13 test_cmp expect actual
21 test_expect_success
'setup' '
23 (cd parent && git init &&
24 echo one >file && git add file && git commit -m one &&
25 git checkout -b two &&
26 echo two >file && git add file && git commit -m two &&
29 (cd empty && git init)
32 test_expect_success
'vanilla clone chooses HEAD' '
33 git clone parent clone &&
40 test_expect_success
'clone -b chooses specified branch' '
41 git clone -b two parent clone-two &&
48 test_expect_success
'clone -b sets up tracking' '
50 echo origin >expect &&
51 git config branch.two.remote >actual &&
52 echo refs/heads/two >>expect &&
53 git config branch.two.merge >>actual &&
54 test_cmp expect actual
58 test_expect_success
'clone -b does not munge remotes/origin/HEAD' '
60 echo refs/remotes/origin/main >expect &&
61 git symbolic-ref refs/remotes/origin/HEAD >actual &&
62 test_cmp expect actual
66 test_expect_success
'clone -b with bogus branch' '
67 test_must_fail git clone -b bogus parent clone-bogus
70 test_expect_success
'clone -b not allowed with empty repos' '
71 test_must_fail git clone -b branch empty clone-branch-empty