Skip to content

Commit 349cff7

Browse files
sjbaraggitster
authored andcommitted
clone: add tests for --template and some disallowed option pairs
Some combinations of command-line options to `git clone` are invalid, but there were previously no tests ensuring those combinations reported errors. Similarly, `git clone --template` didn't appear to have any tests. Helped-by: Jeff King <[email protected]> Helped-by: Derrick Stolee <[email protected]> Signed-off-by: Sean Barag <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 54e85e7 commit 349cff7

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

t/t5606-clone-options.sh

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,51 @@ test_expect_success 'setup' '
1515
test_expect_success 'clone -o' '
1616
1717
git clone -o foo parent clone-o &&
18-
(cd clone-o && git rev-parse --verify refs/remotes/foo/master)
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"
1963
2064
'
2165

0 commit comments

Comments
 (0)