vendor/libgit2/src/diff_stats.c in rugged-0.25.0b10 vs vendor/libgit2/src/diff_stats.c in rugged-0.25.0

- old
+ new

@@ -298,19 +298,28 @@ return error; } } 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" : ""); + git_buf_printf( + out, " %" PRIuZ " file%s changed", + stats->files_changed, stats->files_changed != 1 ? "s" : ""); - if (error < 0) - return error; + 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) { for (i = 0; i < stats->files_changed; ++i) { if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) @@ -332,6 +341,5 @@ git_diff_free(stats->diff); /* bumped refcount in constructor */ git__free(stats->filestats); git__free(stats); } -