stat/shortstat: Color added and removed lines and the corresponding signs ('+' and '-') in the summary. numstat: Color added and removed lines per file. Signed-off-by: Markus Heidelberg <markus.heidelberg@xxxxxx> --- I didn't consider --summary and --name-status. Also in --stat it would be possible to color filenames in renames and copies and the mode in mode changes. Not sure if it would be nice or distracting. At least it wouldn't look so consistent, I think. diff.c | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/diff.c b/diff.c index d581d4d..bc8377d 100644 --- a/diff.c +++ b/diff.c @@ -994,18 +994,24 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options) show_graph(options->file, '-', del, del_c, reset); fprintf(options->file, "\n"); } - fprintf(options->file, - " %d files changed, %d insertions(+), %d deletions(-)\n", - total_files, adds, dels); + fprintf(options->file, " %d files changed, %s%d%s insertions(%s+%s), " + "%s%d%s deletions(%s-%s)\n", + total_files, add_c, adds, reset, add_c, reset, + del_c, dels, reset, del_c, reset); } static void show_shortstats(struct diffstat_t* data, struct diff_options *options) { int i, adds = 0, dels = 0, total_files = data->nr; + const char *reset, *add_c, *del_c; if (data->nr == 0) return; + reset = diff_get_color_opt(options, DIFF_RESET); + add_c = diff_get_color_opt(options, DIFF_FILE_NEW); + del_c = diff_get_color_opt(options, DIFF_FILE_OLD); + for (i = 0; i < data->nr; i++) { if (!data->files[i]->is_binary && !data->files[i]->is_unmerged) { @@ -1020,17 +1026,24 @@ static void show_shortstats(struct diffstat_t* data, struct diff_options *option } } } - fprintf(options->file, " %d files changed, %d insertions(+), %d deletions(-)\n", - total_files, adds, dels); + fprintf(options->file, " %d files changed, %s%d%s insertions(%s+%s), " + "%s%d%s deletions(%s-%s)\n", + total_files, add_c, adds, reset, add_c, reset, + del_c, dels, reset, del_c, reset); } static void show_numstat(struct diffstat_t* data, struct diff_options *options) { int i; + const char *reset, *add_c, *del_c; if (data->nr == 0) return; + reset = diff_get_color_opt(options, DIFF_RESET); + add_c = diff_get_color_opt(options, DIFF_FILE_NEW); + del_c = diff_get_color_opt(options, DIFF_FILE_OLD); + for (i = 0; i < data->nr; i++) { struct diffstat_file *file = data->files[i]; @@ -1038,7 +1051,8 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options) fprintf(options->file, "-\t-\t"); else fprintf(options->file, - "%d\t%d\t", file->added, file->deleted); + "%s%d%s\t%s%d%s\t", add_c, file->added, reset, + del_c, file->deleted, reset); if (options->line_termination) { fill_print_name(file); if (!file->is_renamed) -- 1.6.3.rc1.84.g1036b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html