Skip to content

Commit 46fc89c

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

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
26172617
store.seen = 1;
26182618

26192619
for (i = 0, copy_begin = 0; i < store.seen; i++) {
2620+
new_line = 0;
26202621
if (store.offset[i] == 0) {
26212622
store.offset[i] = copy_end = contents_sz;
26222623
} else if (store.state != KEY_SEEN) {

t/t1300-config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ test_expect_success '--local requires a repo' '
15881588
test_expect_code 128 nongit git config --local foo.bar
15891589
'
15901590

1591-
test_expect_failure '--replace-all does not invent newlines' '
1591+
test_expect_success '--replace-all does not invent newlines' '
15921592
q_to_tab >.git/config <<-\EOF &&
15931593
[abc]key
15941594
QkeepSection

0 commit comments

Comments
 (0)