Merge branch 'jn/clone-add-empty-config-from-command-line' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 5 Jun 2017 00:03:11 +0000 (09:03 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Jun 2017 00:03:11 +0000 (09:03 +0900)
"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

builtin/clone.c
t/t5611-clone-config.sh
index de85b85254e49ba0211ea6476179fc6d4c774ca9..a6ae7d6180ebee6e199b40b4e0c720d4049b68e9 100644 (file)
@@ -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)
index e4850b778c2f20df02ce187cc8cd057df2759d7d..39329eb7a8a64b177794b83ef8828b866fead547 100755 (executable)
@@ -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 &&