summaryrefslogtreecommitdiff
path: root/t/t5606-clone-options.sh
diff options
context:
space:
mode:
authorLibravatar Sean Barag <sean@barag.org>2020-10-01 03:46:16 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-09-30 22:09:13 -0700
commitde9ed3ef3740f8227cc924e845032954d1f1b1b7 (patch)
tree2854c591199100050994c1bf4876b6e4e8ba4d30 /t/t5606-clone-options.sh
parentclone: read new remote name from remote_name instead of option_origin (diff)
downloadtgif-de9ed3ef3740f8227cc924e845032954d1f1b1b7.tar.xz
clone: allow configurable default for `-o`/`--origin`
While the default remote name of "origin" can be changed at clone-time with `git clone`'s `--origin` option, it was previously not possible to specify a default value for the name of that remote. Add support for a new `clone.defaultRemoteName` config, with the newly-created remote name resolved in priority order: 1. (Highest priority) A remote name passed directly to `git clone -o` 2. A `clone.defaultRemoteName=new_name` in config `git clone -c` 3. A `clone.defaultRemoteName` value set in `/path/to/template/config`, where `--template=/path/to/template` is provided 4. A `clone.defaultRemoteName` value set in a non-template config file 5. The default value of `origin` Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Helped-by: Derrick Stolee <stolee@gmail.com> Helped-by: Andrei Rybak <rybak.a.v@gmail.com> Signed-off-by: Sean Barag <sean@barag.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5606-clone-options.sh')
-rwxr-xr-xt/t5606-clone-options.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t5606-clone-options.sh b/t/t5606-clone-options.sh
index 0422b24258..5e201e7d85 100755
--- a/t/t5606-clone-options.sh
+++ b/t/t5606-clone-options.sh
@@ -19,6 +19,13 @@ test_expect_success 'clone -o' '
'
+test_expect_success 'rejects invalid -o/--origin' '
+
+ test_must_fail git clone -o "bad...name" parent clone-bad-name 2>err &&
+ test_i18ngrep "'\''bad...name'\'' is not a valid remote name" err
+
+'
+
test_expect_success 'disallows --bare with --origin' '
test_must_fail git clone -o foo --bare parent clone-bare-o 2>err &&
@@ -63,6 +70,21 @@ test_expect_success 'prefers -c config over --template config' '
'
+test_expect_success 'prefers config "clone.defaultRemoteName" over default' '
+
+ test_config_global clone.defaultRemoteName from_config &&
+ git clone parent clone-config-origin &&
+ git -C clone-config-origin rev-parse --verify refs/remotes/from_config/master
+
+'
+
+test_expect_success 'prefers --origin over -c config' '
+
+ git clone -c clone.defaultRemoteName=inline --origin from_option parent clone-o-and-inline-config &&
+ git -C clone-o-and-inline-config rev-parse --verify refs/remotes/from_option/master
+
+'
+
test_expect_success 'redirected clone does not show progress' '
git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&