@matheusbsbs / matheus-bagliano / commits / 349cff76de
Fork 0

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 <peff@peff.net> Helped-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Sean Barag <sean@barag.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sean Barag committed Sep 29, 2020 at 03:36 UTC 349cff76de7fdb3b44c7018474134566a7a4ee19
1 file changed +45 -1
t/t5606-clone-options.sh
+45 -1
@@ -15,7 +15,51 @@ test_expect_success 'setup' '
15 test_expect_success 'clone -o' '
16
17 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"
63
64 '
65