use strpbrk(3) to search for characters from a given set
[git/debian.git] / t / t5609-clone-branch.sh
blob6e7a7be052276613bf5f83551d93b4d90536ea4e
1 #!/bin/sh
3 test_description='clone --branch option'
4 . ./test-lib.sh
6 check_HEAD() {
7 echo refs/heads/"$1" >expect &&
8 git symbolic-ref HEAD >actual &&
9 test_cmp expect actual
12 check_file() {
13 echo "$1" >expect &&
14 test_cmp expect file
17 test_expect_success 'setup' '
18 mkdir parent &&
19 (cd parent && git init &&
20 echo one >file && git add file && git commit -m one &&
21 git checkout -b two &&
22 echo two >file && git add file && git commit -m two &&
23 git checkout master) &&
24 mkdir empty &&
25 (cd empty && git init)
28 test_expect_success 'vanilla clone chooses HEAD' '
29 git clone parent clone &&
30 (cd clone &&
31 check_HEAD master &&
32 check_file one
36 test_expect_success 'clone -b chooses specified branch' '
37 git clone -b two parent clone-two &&
38 (cd clone-two &&
39 check_HEAD two &&
40 check_file two
44 test_expect_success 'clone -b sets up tracking' '
45 (cd clone-two &&
46 echo origin >expect &&
47 git config branch.two.remote >actual &&
48 echo refs/heads/two >>expect &&
49 git config branch.two.merge >>actual &&
50 test_cmp expect actual
54 test_expect_success 'clone -b does not munge remotes/origin/HEAD' '
55 (cd clone-two &&
56 echo refs/remotes/origin/master >expect &&
57 git symbolic-ref refs/remotes/origin/HEAD >actual &&
58 test_cmp expect actual
62 test_expect_success 'clone -b with bogus branch' '
63 test_must_fail git clone -b bogus parent clone-bogus
66 test_expect_success 'clone -b not allowed with empty repos' '
67 test_must_fail git clone -b branch empty clone-branch-empty
70 test_done