[PATCH] blame: make sure that the last line ends in an LF
From: Sverre Rabbelier <hidden>
Date: 2016-06-15 22:47:35
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Johannes Schindelin <redacted>
This is convenient when parsing multiple the blame of multiple files,
for example:
git ls-files -z --exclude-standard -- "*.[ch]" |
xargs --null -n 1 git blame -p > output
and then analyzing the 'output' file using a seperate script.
Currently the parsing is difficult when not all files have a newline
at EOF, this patch ensures that even such files have a newline at the
end of the blame output.
Signed-off-by: Sverre Rabbelier <redacted>
CC: Johannes Schindelin <redacted>
---
Patch by Dscho, commit message by me. Apologies to Dscho for
taking so long to send it :).
builtin-blame.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index 7512773..dd16b22 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c@@ -1604,6 +1604,9 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent) } while (ch != '\n' && cp < sb->final_buf + sb->final_buf_size); } + + if (sb->final_buf_size && cp[-1] != '\n') + putchar('\n'); } static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
@@ -1667,6 +1670,9 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt) } while (ch != '\n' && cp < sb->final_buf + sb->final_buf_size); } + + if (sb->final_buf_size && cp[-1] != '\n') + putchar('\n'); } static void output(struct scoreboard *sb, int option)
--
1.6.5.1.123.ge01f7