config --replace-all: avoid extra line breaks
When replacing multiple config entries at once, we did not re-set the flag that indicates whether we need to insert a new-line before the new entry. As a consequence, an extra new-line was inserted under certain circumstances. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Apr 3, 2018 at 18:28 UTC
46fc89ce74b46e88764c796b3ab20d5ab90a5e96
2 files changed
+2
-1
config.c
+1
@@ -2617,6 +2617,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2617
store.seen = 1;
2618
2619
for (i = 0, copy_begin = 0; i < store.seen; i++) {
2620
+ new_line = 0;
2621
if (store.offset[i] == 0) {
2622
store.offset[i] = copy_end = contents_sz;
2623
} else if (store.state != KEY_SEEN) {
t/t1300-config.sh
+1
-1
@@ -1588,7 +1588,7 @@ test_expect_success '--local requires a repo' '
1588
test_expect_code 128 nongit git config --local foo.bar
1589
'
1590
1591
-test_expect_failure '--replace-all does not invent newlines' '
1591
+test_expect_success '--replace-all does not invent newlines' '
1592
q_to_tab >.git/config <<-\EOF &&
1593
[abc]key
1594
QkeepSection