]>
Commit | Line | Data |
---|---|---|
ecaa0cff JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='basic clone options' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_expect_success 'setup' ' | |
7 | ||
8 | mkdir parent && | |
9 | (cd parent && git init && | |
10 | echo one >file && git add file && | |
11 | git commit -m one) | |
12 | ||
13 | ' | |
14 | ||
15 | test_expect_success 'clone -o' ' | |
16 | ||
17 | git clone -o foo parent clone-o && | |
349cff76 SB |
18 | git -C clone-o rev-parse --verify refs/remotes/foo/master |
19 | ||
20 | ' | |
21 | ||
22 | test_expect_success 'disallows --bare with --origin' ' | |
23 | ||
24 | test_must_fail git clone -o foo --bare parent clone-bare-o 2>err && | |
25 | test_debug "cat err" && | |
26 | test_i18ngrep -e "--bare and --origin foo options are incompatible" err | |
27 | ||
28 | ' | |
29 | ||
30 | test_expect_success 'disallows --bare with --separate-git-dir' ' | |
31 | ||
32 | test_must_fail git clone --bare --separate-git-dir dot-git-destiation parent clone-bare-sgd 2>err && | |
33 | test_debug "cat err" && | |
34 | test_i18ngrep -e "--bare and --separate-git-dir are incompatible" err | |
35 | ||
36 | ' | |
37 | ||
38 | test_expect_success 'uses "origin" for default remote name' ' | |
39 | ||
40 | git clone parent clone-default-origin && | |
41 | git -C clone-default-origin rev-parse --verify refs/remotes/origin/master | |
42 | ||
43 | ' | |
44 | ||
45 | test_expect_success 'prefers --template config over normal config' ' | |
46 | ||
47 | template="$TRASH_DIRECTORY/template-with-config" && | |
48 | mkdir "$template" && | |
49 | git config --file "$template/config" foo.bar from_template && | |
50 | test_config_global foo.bar from_global && | |
51 | git clone "--template=$template" parent clone-template-config && | |
52 | test "$(git -C clone-template-config config --local foo.bar)" = "from_template" | |
53 | ||
54 | ' | |
55 | ||
56 | test_expect_success 'prefers -c config over --template config' ' | |
57 | ||
58 | template="$TRASH_DIRECTORY/template-with-ignored-config" && | |
59 | mkdir "$template" && | |
60 | git config --file "$template/config" foo.bar from_template && | |
61 | git clone "--template=$template" -c foo.bar=inline parent clone-template-inline-config && | |
62 | test "$(git -C clone-template-inline-config config --local foo.bar)" = "inline" | |
ecaa0cff JK |
63 | |
64 | ' | |
65 | ||
68b939b2 | 66 | test_expect_success 'redirected clone does not show progress' ' |
21188b1e MV |
67 | |
68 | git clone "file://$(pwd)/parent" clone-redirected >out 2>err && | |
2856cbf0 JK |
69 | ! grep % err && |
70 | test_i18ngrep ! "Checking connectivity" err | |
21188b1e MV |
71 | |
72 | ' | |
68b939b2 JK |
73 | |
74 | test_expect_success 'redirected clone -v does show progress' ' | |
21188b1e | 75 | |
5a518ad4 TRC |
76 | git clone --progress "file://$(pwd)/parent" clone-redirected-progress \ |
77 | >out 2>err && | |
68b939b2 | 78 | grep % err |
21188b1e MV |
79 | |
80 | ' | |
81 | ||
0cc1b475 JS |
82 | test_expect_success 'chooses correct default initial branch name' ' |
83 | git init --bare empty && | |
84 | git -c init.defaultBranch=up clone empty whats-up && | |
85 | test refs/heads/up = $(git -C whats-up symbolic-ref HEAD) && | |
86 | test refs/heads/up = $(git -C whats-up config branch.up.merge) | |
87 | ' | |
88 | ||
89 | test_expect_success 'guesses initial branch name correctly' ' | |
90 | git init --initial-branch=guess initial-branch && | |
91 | test_commit -C initial-branch no-spoilers && | |
92 | git -C initial-branch branch abc guess && | |
93 | git clone initial-branch is-it && | |
a471214b JS |
94 | test refs/heads/guess = $(git -C is-it symbolic-ref HEAD) && |
95 | ||
96 | git -c init.defaultBranch=none init --bare no-head && | |
97 | git -C initial-branch push ../no-head guess abc && | |
98 | git clone no-head is-it2 && | |
99 | test_must_fail git -C is-it2 symbolic-ref refs/remotes/origin/HEAD && | |
100 | git -C no-head update-ref --no-deref HEAD refs/heads/guess && | |
101 | git -c init.defaultBranch=guess clone no-head is-it3 && | |
102 | test refs/remotes/origin/guess = \ | |
103 | $(git -C is-it3 symbolic-ref refs/remotes/origin/HEAD) | |
0cc1b475 JS |
104 | ' |
105 | ||
ecaa0cff | 106 | test_done |