Skip to content
  • Jonathan Nieder's avatar
    clone: handle empty config values in -c · db4eca1f
    Jonathan Nieder authored and Junio C Hamano's avatar Junio C Hamano committed
    "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: default avatarJonathan Nieder <jrnieder@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    db4eca1f