Commit ce3b71d9 by Russell Belfer

Don't scale diff stat when not needed

parent b1914c36
...@@ -284,6 +284,8 @@ int git_diff_stats_to_buf( ...@@ -284,6 +284,8 @@ int git_diff_stats_to_buf(
if (width < STATS_FULL_MIN_SCALE) if (width < STATS_FULL_MIN_SCALE)
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) { for (i = 0; i < stats->files_changed; ++i) {
if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) if ((delta = git_diff_get_delta(stats->diff, i)) == NULL)
......
...@@ -54,6 +54,10 @@ void test_diff_stats__stat(void) ...@@ -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_git_pass(git_diff_stats_to_buf(&buf, _stats, GIT_DIFF_STATS_FULL, 0));
cl_assert(strcmp(git_buf_cstr(&buf), stat) == 0); cl_assert(strcmp(git_buf_cstr(&buf), stat) == 0);
git_buf_free(&buf); 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) void test_diff_stats__multiple_hunks(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment