l10n: README: fix typo
[alt-git.git] / t / t5609-clone-branch.sh
blob252e1f7c20f2b86b3a276a6bfd7adc9ca14d4909
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_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 check_HEAD() {
11 echo refs/heads/"$1" >expect &&
12 git symbolic-ref HEAD >actual &&
13 test_cmp expect actual
16 check_file() {
17 echo "$1" >expect &&
18 test_cmp expect file
21 test_expect_success 'setup' '
22 mkdir parent &&
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 &&
27 git checkout main) &&
28 mkdir empty &&
29 (cd empty && git init)
32 test_expect_success 'vanilla clone chooses HEAD' '
33 git clone parent clone &&
34 (cd clone &&
35 check_HEAD main &&
36 check_file one
40 test_expect_success 'clone -b chooses specified branch' '
41 git clone -b two parent clone-two &&
42 (cd clone-two &&
43 check_HEAD two &&
44 check_file two
48 test_expect_success 'clone -b sets up tracking' '
49 (cd clone-two &&
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' '
59 (cd clone-two &&
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
74 test_done