[PATCH v4 4/4] 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>
---
diff.c | 6 +++++-
t/t4052-stat-output.sh | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 0b61cf7..f08b41a 100644
--- 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;
diff --git a/t/t4052-stat-output.sh b/t/t4052-stat-output.sh
index 6305c99..ced32db 100755
--- a/t/t4052-stat-output.sh
+++ b/t/t4052-stat-output.sh
@@ -292,7 +292,7 @@ cat >expect1-graph <<'EOF'
EOF
while read verb expect cmd args
do
- test_expect_failure "$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,7 +300,7 @@ do
test "$cmd" != diff || continue
- test_expect_failure "$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
--
1.7.3.4