From ce3b71d91b9cac3b462dec9ac2c7e397b55c00a6 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 12 May 2014 10:28:45 -0700 Subject: [PATCH] Don't scale diff stat when not needed --- src/diff_stats.c | 2 ++ tests/diff/stats.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/diff_stats.c b/src/diff_stats.c index 6ad670c42..42ccbfb87 100644 --- a/src/diff_stats.c +++ b/src/diff_stats.c @@ -284,6 +284,8 @@ int git_diff_stats_to_buf( if (width < STATS_FULL_MIN_SCALE) width = STATS_FULL_MIN_SCALE; } + if (width > stats->max_filestat) + width = 0; for (i = 0; i < stats->files_changed; ++i) { if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) diff --git a/tests/diff/stats.c b/tests/diff/stats.c index 055019f69..f731997da 100644 --- a/tests/diff/stats.c +++ b/tests/diff/stats.c @@ -54,6 +54,10 @@ void test_diff_stats__stat(void) cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0)); cl_assert(strcmp(git_buf_cstr(&buf), stat) == 0); git_buf_free(&buf); + + cl_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 80)); + cl_assert(strcmp(git_buf_cstr(&buf), stat) == 0); + git_buf_free(&buf); } void test_diff_stats__multiple_hunks(void) -- 2.39.5