Prevent graph_width of stat width from falling below min
authorLucian Poston <lucian.poston@gmail.com>
Wed, 18 Apr 2012 21:12:18 +0000 (14:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Apr 2012 23:08:11 +0000 (16:08 -0700)
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>
diff.c
t/t4052-stat-output.sh

diff --git a/diff.c b/diff.c
index 0b61cf7c7f2b682df09360e059958bfca12f459a..f08b41a663fe24a6b2cad51c0edcedff81fe7d2b 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1473,8 +1473,12 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
         * Adjust adjustable widths not to exceed maximum width
         */
        if (name_width + number_width + 6 + graph_width > width) {
-               if (graph_width > width * 3/8 - number_width - 6)
+               if (graph_width > width * 3/8 - number_width - 6) {
                        graph_width = width * 3/8 - number_width - 6;
+                       if (graph_width < 6)
+                               graph_width = 6;
+               }
+
                if (options->stat_graph_width &&
                    graph_width > options->stat_graph_width)
                        graph_width = options->stat_graph_width;
index b8eec8fd2646c15f289c2174eb5b25a532ded49d..ced32dbbcad38bfaf24dcb557777dea0db97ee4a 100755 (executable)
@@ -290,9 +290,9 @@ EOF
 cat >expect1-graph <<'EOF'
 |  ...aaaaaaa | 1000 ++++++
 EOF
-while read teststate verb expect cmd args
+while read verb expect cmd args
 do
-       test_expect_$teststate "$cmd $verb prefix greater than COLUMNS (big change)" '
+       test_expect_success "$cmd $verb prefix greater than COLUMNS (big change)" '
                COLUMNS=1 git $cmd $args >output
                grep " | " output >actual &&
                test_cmp "$expect" actual
@@ -300,16 +300,16 @@ do
 
        test "$cmd" != diff || continue
 
-       test_expect_$teststate "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
+       test_expect_success "$cmd --graph $verb prefix greater than COLUMNS (big change)" '
                COLUMNS=1 git $cmd $args --graph >output
                grep " | " output >actual &&
                test_cmp "$expect-graph" actual
        '
 done <<\EOF
-success ignores expect80 format-patch -1 --stdout
-failure respects expect1 diff HEAD^ HEAD --stat
-failure respects expect1 show --stat
-failure respects expect1 log -1 --stat
+ignores expect80 format-patch -1 --stdout
+respects expect1 diff HEAD^ HEAD --stat
+respects expect1 show --stat
+respects expect1 log -1 --stat
 EOF
 
 cat >expect <<'EOF'