Skip to content

Commit 83b7fd8

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d32eb83 commit 83b7fd8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2624,7 +2624,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26242624
} else
26252625
copy_end = find_beginning_of_line(
26262626
contents, contents_sz,
2627-
store.offset[i]-2, &new_line);
2627+
store.offset[i], &new_line);
26282628

26292629
if (copy_end > 0 && contents[copy_end-1] != '\n')
26302630
new_line = 1;

0 commit comments

Comments
 (0)