git_config_set: fix off-by-two
commit83b7fd87714c4b70553c56987756ff319ccc7ec6
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 3 Apr 2018 16:28:00 +0000 (3 18:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Apr 2018 23:30:03 +0000 (6 08:30 +0900)
treebbb94c3e8d3b7dee83bb0cb79e25ed3169b35782
parentd32eb83c1db7d0a8bb54fe743c6d1dd674d372c5
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>
config.c