]>
Commit | Line | Data |
---|---|---|
7a4ee28f JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='clone --branch option' | |
4 | . ./test-lib.sh | |
5 | ||
6 | check_HEAD() { | |
7 | echo refs/heads/"$1" >expect && | |
8 | git symbolic-ref HEAD >actual && | |
9 | test_cmp expect actual | |
10 | } | |
11 | ||
12 | check_file() { | |
13 | echo "$1" >expect && | |
14 | test_cmp expect file | |
15 | } | |
16 | ||
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 | ' | |
25 | ||
26 | test_expect_success 'vanilla clone chooses HEAD' ' | |
27 | git clone parent clone && | |
28 | (cd clone && | |
29 | check_HEAD master && | |
30 | check_file one | |
31 | ) | |
32 | ' | |
33 | ||
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 | |
39 | ) | |
40 | ' | |
41 | ||
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 | |
49 | ) | |
50 | ' | |
51 | ||
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 | |
57 | ) | |
58 | ' | |
59 | ||
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 | |
65 | ) | |
66 | ' | |
67 | ||
68 | test_done |