Skip to content

Commit c8c3321

Browse files
committed
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
2 parents b19174e + db4eca1 commit c8c3321

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,9 @@ static int checkout(int submodule_progress)
773773

774774
static int write_one_config(const char *key, const char *value, void *data)
775775
{
776-
return git_config_set_multivar_gently(key, value ? value : "true", "^$", 0);
776+
return git_config_set_multivar_gently(key,
777+
value ? value : "true",
778+
CONFIG_REGEX_NONE, 0);
777779
}
778780

779781
static void write_config(struct string_list *config)

t/t5611-clone-config.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ test_expect_success 'clone -c can set multi-keys' '
1919
test_cmp expect actual
2020
'
2121

22+
test_expect_success 'clone -c can set multi-keys, including some empty' '
23+
rm -rf child &&
24+
git clone -c credential.helper= -c credential.helper=hi . child &&
25+
printf "%s\n" "" hi >expect &&
26+
git --git-dir=child/.git config --get-all credential.helper >actual &&
27+
test_cmp expect actual
28+
'
29+
2230
test_expect_success 'clone -c without a value is boolean true' '
2331
rm -rf child &&
2432
git clone -c core.foo . child &&

0 commit comments

Comments
 (0)