diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/diff_stats.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/diff_stats.c b/src/diff_stats.c index 42ccbfb87..03dbccaed 100644 --- a/src/diff_stats.c +++ b/src/diff_stats.c @@ -299,15 +299,24 @@ int git_diff_stats_to_buf( } if (format & GIT_DIFF_STATS_FULL || format & GIT_DIFF_STATS_SHORT) { - error = git_buf_printf( - out, " %" PRIuZ " file%s changed, %" PRIuZ - " insertion%s(+), %" PRIuZ " deletion%s(-)\n", - stats->files_changed, stats->files_changed != 1 ? "s" : "", - stats->insertions, stats->insertions != 1 ? "s" : "", - stats->deletions, stats->deletions != 1 ? "s" : ""); - - if (error < 0) - return error; + git_buf_printf( + out, " %" PRIuZ " file%s changed", + stats->files_changed, stats->files_changed != 1 ? "s" : ""); + + if (stats->insertions || stats->deletions == 0) + git_buf_printf( + out, ", %" PRIuZ " insertion%s(+)", + stats->insertions, stats->insertions != 1 ? "s" : ""); + + if (stats->deletions || stats->insertions == 0) + git_buf_printf( + out, ", %" PRIuZ " deletion%s(-)", + stats->deletions, stats->deletions != 1 ? "s" : ""); + + git_buf_putc(out, '\n'); + + if (git_buf_oom(out)) + return -1; } if (format & GIT_DIFF_STATS_INCLUDE_SUMMARY) { @@ -333,4 +342,3 @@ void git_diff_stats_free(git_diff_stats *stats) git__free(stats->filestats); git__free(stats); } - |
