Skip to content

Commit a5ca836

Browse files
dschogitster
authored andcommitted
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 <[email protected]> CC: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78d553b commit a5ca836

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builtin-blame.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,6 +1604,9 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
16041604
} while (ch != '\n' &&
16051605
cp < sb->final_buf + sb->final_buf_size);
16061606
}
1607+
1608+
if (sb->final_buf_size && cp[-1] != '\n')
1609+
putchar('\n');
16071610
}
16081611

16091612
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)
16671670
} while (ch != '\n' &&
16681671
cp < sb->final_buf + sb->final_buf_size);
16691672
}
1673+
1674+
if (sb->final_buf_size && cp[-1] != '\n')
1675+
putchar('\n');
16701676
}
16711677

16721678
static void output(struct scoreboard *sb, int option)

0 commit comments

Comments
 (0)