t1010: fix unnoticed failure on Windows
[git.git] / t / t5609-clone-branch.sh
blobf86a674a0321e7e39f4df16461d5da0eab84969b
1 #!/bin/sh
3 test_description='clone --branch option'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 check_HEAD() {
10 echo refs/heads/"$1" >expect &&
11 git symbolic-ref HEAD >actual &&
12 test_cmp expect actual
15 check_file() {
16 echo "$1" >expect &&
17 test_cmp expect file
20 test_expect_success 'setup' '
21 mkdir parent &&
22 (cd parent && git init &&
23 echo one >file && git add file && git commit -m one &&
24 git checkout -b two &&
25 echo two >file && git add file && git commit -m two &&
26 git checkout main) &&
27 mkdir empty &&
28 (cd empty && git init)
31 test_expect_success 'vanilla clone chooses HEAD' '
32 git clone parent clone &&
33 (cd clone &&
34 check_HEAD main &&
35 check_file one
39 test_expect_success 'clone -b chooses specified branch' '
40 git clone -b two parent clone-two &&
41 (cd clone-two &&
42 check_HEAD two &&
43 check_file two
47 test_expect_success 'clone -b sets up tracking' '
48 (cd clone-two &&
49 echo origin >expect &&
50 git config branch.two.remote >actual &&
51 echo refs/heads/two >>expect &&
52 git config branch.two.merge >>actual &&
53 test_cmp expect actual
57 test_expect_success 'clone -b does not munge remotes/origin/HEAD' '
58 (cd clone-two &&
59 echo refs/remotes/origin/main >expect &&
60 git symbolic-ref refs/remotes/origin/HEAD >actual &&
61 test_cmp expect actual
65 test_expect_success 'clone -b with bogus branch' '
66 test_must_fail git clone -b bogus parent clone-bogus
69 test_expect_success 'clone -b not allowed with empty repos' '
70 test_must_fail git clone -b branch empty clone-branch-empty
73 test_done