Prevent graph_width of stat width from falling below min

Update tests in t4052 fixed by this change. Signed-off-by: Lucian Poston <lucian.poston@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lucian Poston committed Apr 18, 2012 at 14:12 UTC 678c5741118729dc9072182bd368e0a3402dd4f1
2 files changed +12 -8
diff.c
+5 -1
@@ -1473,8 +1473,12 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
1473 * Adjust adjustable widths not to exceed maximum width
1474 */
1475 if (name_width + number_width + 6 + graph_width > width) {
1476 - if (graph_width > width * 3/8 - number_width - 6)
1476 + if (graph_width > width * 3/8 - number_width - 6) {
1477 graph_width = width * 3/8 - number_width - 6;
1478 + if (graph_width < 6)
1479 + graph_width = 6;
1480 + }
1481 +
1482 if (options->stat_graph_width &&
1483 graph_width > options->stat_graph_width)
1484 graph_width = options->stat_graph_width;
t/t4052-stat-output.sh
+7 -7
@@ -290,9 +290,9 @@ EOF
290 cat >expect1-graph <<'EOF'
291 | ...aaaaaaa | 1000 ++++++
292 EOF
293 -while read teststate verb expect cmd args
293 +while read verb expect cmd args
294 do
295 - test_expect_$teststate "$cmd $verb prefix greater than COLUMNS (big change)" '
295 + test_expect_success "$cmd $verb prefix greater than COLUMNS (big change)" '
296 COLUMNS=1 git $cmd $args >output
297 grep " | " output >actual &&
298 test_cmp "$expect" actual
@@ -300,16 +300,16 @@ do
300
301 test "$cmd" != diff || continue
302
303 - test_expect_$teststate "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
303 + test_expect_success "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
304 COLUMNS=1 git $cmd $args --graph >output
305 grep " | " output >actual &&
306 test_cmp "$expect-graph" actual
307 '
308 done <<\EOF
309 -success ignores expect80 format-patch -1 --stdout
310 -failure respects expect1 diff HEAD^ HEAD --stat
311 -failure respects expect1 show --stat
312 -failure respects expect1 log -1 --stat
309 +ignores expect80 format-patch -1 --stdout
310 +respects expect1 diff HEAD^ HEAD --stat
311 +respects expect1 show --stat
312 +respects expect1 log -1 --stat
313 EOF
314
315 cat >expect <<'EOF'