Skip to content
  • Tanay Abhra's avatar
    make config --add behave correctly for empty and NULL values · c8466645
    Tanay Abhra authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Currently if we have a config file like,
    [foo]
            baz
            bar =
    
    and we try something like, "git config --add foo.baz roll", Git will
    segfault. Moreover, for "git config --add foo.bar roll", it will
    overwrite the original value instead of appending after the existing
    empty value.
    
    The problem lies with the regexp used for simulating --add in
    `git_config_set_multivar_in_file()`, "^$", which in ideal case should
    not match with any string but is true for empty strings. Instead use a
    regexp like "a^" which can not be true for any string, empty or not.
    
    For removing the segfault add a check for NULL values in `matches()` in
    config.c.
    
    Signed-off-by: default avatarTanay Abhra <tanayabh@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    c8466645