]> git.ipfire.org Git - thirdparty/git.git/commitdiff
clone: add tests for --template and some disallowed option pairs
authorSean Barag <sean@barag.org>
Tue, 29 Sep 2020 03:36:49 +0000 (03:36 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Sep 2020 19:36:10 +0000 (12:36 -0700)
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>
t/t5606-clone-options.sh

index e69427f8817a6e2170ce1175991e8badb0e78ecb..0422b242589a2f94ac324741e8c4aa28005488f2 100755 (executable)
@@ -15,7 +15,51 @@ test_expect_success 'setup' '
 test_expect_success 'clone -o' '
 
        git clone -o foo parent clone-o &&
-       (cd clone-o && git rev-parse --verify refs/remotes/foo/master)
+       git -C clone-o rev-parse --verify refs/remotes/foo/master
+
+'
+
+test_expect_success 'disallows --bare with --origin' '
+
+       test_must_fail git clone -o foo --bare parent clone-bare-o 2>err &&
+       test_debug "cat err" &&
+       test_i18ngrep -e "--bare and --origin foo options are incompatible" err
+
+'
+
+test_expect_success 'disallows --bare with --separate-git-dir' '
+
+       test_must_fail git clone --bare --separate-git-dir dot-git-destiation parent clone-bare-sgd 2>err &&
+       test_debug "cat err" &&
+       test_i18ngrep -e "--bare and --separate-git-dir are incompatible" err
+
+'
+
+test_expect_success 'uses "origin" for default remote name' '
+
+       git clone parent clone-default-origin &&
+       git -C clone-default-origin rev-parse --verify refs/remotes/origin/master
+
+'
+
+test_expect_success 'prefers --template config over normal config' '
+
+       template="$TRASH_DIRECTORY/template-with-config" &&
+       mkdir "$template" &&
+       git config --file "$template/config" foo.bar from_template &&
+       test_config_global foo.bar from_global &&
+       git clone "--template=$template" parent clone-template-config &&
+       test "$(git -C clone-template-config config --local foo.bar)" = "from_template"
+
+'
+
+test_expect_success 'prefers -c config over --template config' '
+
+       template="$TRASH_DIRECTORY/template-with-ignored-config" &&
+       mkdir "$template" &&
+       git config --file "$template/config" foo.bar from_template &&
+       git clone "--template=$template" -c foo.bar=inline parent clone-template-inline-config &&
+       test "$(git -C clone-template-inline-config config --local foo.bar)" = "inline"
 
 '