aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-06-29 17:06:47 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-30 13:13:01 -0700
commitdfb7728f637e8178189f9f8f0092797403c73509 (patch)
tree31f34af07631a5c52f8a6e1f1c9a88e3fe5934dd /diff.c
parentf2d2a5def088b474586eedfa4fa547bc2c955bb9 (diff)
downloadgit-dfb7728f637e8178189f9f8f0092797403c73509.tar.gz
git-dfb7728f637e8178189f9f8f0092797403c73509.tar.xz
diff.c: move line ending check into emit_hunk_header
The emit_hunk_header() function is responsible for assembling a hunk header and calling emit_line() to send the hunk header to the output file. Its only caller fn_out_consume() needs to prepare for a case where the function emits an incomplete line and add the terminating LF. Instead make sure emit_hunk_header() to always send a completed line to emit_line(). Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index 2874dfc6f..94fdb5792 100644
--- a/diff.c
+++ b/diff.c
@@ -678,6 +678,8 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
}
strbuf_add(&msgbuf, line + len, org_len - len);
+ strbuf_complete_line(&msgbuf);
+
emit_line(ecbdata->opt, "", "", msgbuf.buf, msgbuf.len);
strbuf_release(&msgbuf);
}
@@ -1315,8 +1317,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
len = sane_truncate_line(ecbdata, line, len);
find_lno(line, ecbdata);
emit_hunk_header(ecbdata, line, len);
- if (line[len-1] != '\n')
- putc('\n', o->file);
return;
}