Skip to content

Commit

Permalink
blame: make sure that the last line ends in an LF
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Oct 22, 2009
1 parent 78d553b commit a5ca836
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin-blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a5ca836

Please sign in to comment.