Merge branch 'ab/send-email-catfile'
[git/kirr.git] / t / t5706-clone-branch.sh
blobf3f9a76056d25fa7d5e4823b1d05ebc1edff46cc
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)
26 test_expect_success 'vanilla clone chooses HEAD' '
27 git clone parent clone &&
28 (cd clone &&
29 check_HEAD master &&
30 check_file one
34 test_expect_success 'clone -b chooses specified branch' '
35 git clone -b two parent clone-two &&
36 (cd clone-two &&
37 check_HEAD two &&
38 check_file two
42 test_expect_success 'clone -b sets up tracking' '
43 (cd clone-two &&
44 echo origin >expect &&
45 git config branch.two.remote >actual &&
46 echo refs/heads/two >>expect &&
47 git config branch.two.merge >>actual &&
48 test_cmp expect actual
52 test_expect_success 'clone -b does not munge remotes/origin/HEAD' '
53 (cd clone-two &&
54 echo refs/remotes/origin/master >expect &&
55 git symbolic-ref refs/remotes/origin/HEAD >actual &&
56 test_cmp expect actual
60 test_expect_success 'clone -b with bogus branch chooses HEAD' '
61 git clone -b bogus parent clone-bogus &&
62 (cd clone-bogus &&
63 check_HEAD master &&
64 check_file one
68 test_done