summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-05 09:03:11 +0900
committerJunio C Hamano <gitster@pobox.com>2017-06-05 09:03:11 +0900
commitc8c33216333c4b2ba86f51d9fa77f7c4daba8d30 (patch)
treed29e0c400cdc00a2cb0084158087a59eacd5f0d3
parentb19174e2f37cc696cbfded9a02c2f2fd6e93bce7 (diff)
parentdb4eca1feaafa0669b7ba64c10314dfe8836576a (diff)
downloadgit-c8c33216333c4b2ba86f51d9fa77f7c4daba8d30.tar.gz
Merge branch 'jn/clone-add-empty-config-from-command-line' into maint
"git clone --config var=val" is a way to populate the per-repository configuration file of the new repository, but it did not work well when val is an empty string. This has been fixed. * jn/clone-add-empty-config-from-command-line: clone: handle empty config values in -c
-rw-r--r--builtin/clone.c4
-rwxr-xr-xt/t5611-clone-config.sh8
2 files changed, 11 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index de85b85254..a6ae7d6180 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -773,7 +773,9 @@ static int checkout(int submodule_progress)
static int write_one_config(const char *key, const char *value, void *data)
{
- return git_config_set_multivar_gently(key, value ? value : "true", "^$", 0);
+ return git_config_set_multivar_gently(key,
+ value ? value : "true",
+ CONFIG_REGEX_NONE, 0);
}
static void write_config(struct string_list *config)
diff --git a/t/t5611-clone-config.sh b/t/t5611-clone-config.sh
index e4850b778c..39329eb7a8 100755
--- a/t/t5611-clone-config.sh
+++ b/t/t5611-clone-config.sh
@@ -19,6 +19,14 @@ test_expect_success 'clone -c can set multi-keys' '
test_cmp expect actual
'
+test_expect_success 'clone -c can set multi-keys, including some empty' '
+ rm -rf child &&
+ git clone -c credential.helper= -c credential.helper=hi . child &&
+ printf "%s\n" "" hi >expect &&
+ git --git-dir=child/.git config --get-all credential.helper >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'clone -c without a value is boolean true' '
rm -rf child &&
git clone -c core.foo . child &&