summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-04-03 16:28:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-05 23:30:03 (GMT)
commit83b7fd87714c4b70553c56987756ff319ccc7ec6 (patch)
treebbb94c3e8d3b7dee83bb0cb79e25ed3169b35782 /config.c
parentd32eb83c1db7d0a8bb54fe743c6d1dd674d372c5 (diff)
downloadgit-83b7fd87714c4b70553c56987756ff319ccc7ec6.zip
git-83b7fd87714c4b70553c56987756ff319ccc7ec6.tar.gz
git-83b7fd87714c4b70553c56987756ff319ccc7ec6.tar.bz2
git_config_set: fix off-by-two
Currently, we are slightly overzealous When removing an entry from a config file of this form: [abc]a [xyz] key = value When calling `git config --unset abc.a` on this file, it leaves this (invalid) config behind: [ [xyz] key = value The reason is that we try to search for the beginning of the line (or for the end of the preceding section header on the same line) that defines abc.a, but as an optimization, we subtract 2 from the offset pointing just after the definition before we call find_beginning_of_line(). That function, however, *also* performs that optimization and promptly fails to find the section header correctly. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/config.c b/config.c
index e617c20..4c8571a 100644
--- a/config.c
+++ b/config.c
@@ -2624,7 +2624,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
} else
copy_end = find_beginning_of_line(
contents, contents_sz,
- store.offset[i]-2, &new_line);
+ store.offset[i], &new_line);
if (copy_end > 0 && contents[copy_end-1] != '\n')
new_line = 1;