@matheusbsbs / matheus-bagliano / commits / a5ca8367c2
Fork 0

blame: make sure that the last line ends in an LF

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 <srabbelier@gmail.com> CC: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Oct 19, 2009 at 22:06 UTC a5ca8367c223b154b485ea51dc8c97201498caa4
1 file changed +6
builtin-blame.c
+6
@@ -1604,6 +1604,9 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
1604 } while (ch != '\n' &&
1605 cp < sb->final_buf + sb->final_buf_size);
1606 }
1607 +
1608 + if (sb->final_buf_size && cp[-1] != '\n')
1609 + putchar('\n');
1610 }
1611
1612 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)
1670 } while (ch != '\n' &&
1671 cp < sb->final_buf + sb->final_buf_size);
1672 }
1673 +
1674 + if (sb->final_buf_size && cp[-1] != '\n')
1675 + putchar('\n');
1676 }
1677
1678 static void output(struct scoreboard *sb, int option)