diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2017-05-01 17:05:15 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-02 11:02:37 +0900 |
commit | db4eca1feaafa0669b7ba64c10314dfe8836576a (patch) | |
tree | 1bc338be729cf190a78f962a68569843c8a79544 /builtin | |
parent | Git 2.11.1 (diff) | |
download | tgif-db4eca1feaafa0669b7ba64c10314dfe8836576a.tar.xz |
clone: handle empty config values in -c
"git clone --config" uses the following incantation to add an item to
a config file, instead of replacing an existing value:
git_config_set_multivar_gently(key, value, "^$", 0)
As long as no existing value matches the regex ^$, that works as
intended and adds to the config. When a value is empty, though, it
replaces the existing value.
Noticed while trying to set credential.helper during a clone to use a
specific helper without inheriting from ~/.gitconfig and
/etc/gitconfig. That is, I ran
git clone -c credential.helper= \
-c credential.helper=myhelper \
https://example.com/repo
intending to produce the configuration
[credential]
helper =
helper = myhelper
Without this patch, the 'helper =' line is not included and the
credential helper from /etc/gitconfig gets used.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/clone.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index 6c76a6ed66..8f45a95c83 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -755,7 +755,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) |