Skip to content

Commit 678c574

Browse files
lucianpostongitster
authored andcommitted
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>
1 parent da79161 commit 678c574

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

diff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,8 +1473,12 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
14731473
* Adjust adjustable widths not to exceed maximum width
14741474
*/
14751475
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) {
14771477
graph_width = width * 3/8 - number_width - 6;
1478+
if (graph_width < 6)
1479+
graph_width = 6;
1480+
}
1481+
14781482
if (options->stat_graph_width &&
14791483
graph_width > options->stat_graph_width)
14801484
graph_width = options->stat_graph_width;

t/t4052-stat-output.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,26 +290,26 @@ EOF
290290
cat >expect1-graph <<'EOF'
291291
| ...aaaaaaa | 1000 ++++++
292292
EOF
293-
while read teststate verb expect cmd args
293+
while read verb expect cmd args
294294
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)" '
296296
COLUMNS=1 git $cmd $args >output
297297
grep " | " output >actual &&
298298
test_cmp "$expect" actual
299299
'
300300

301301
test "$cmd" != diff || continue
302302

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)" '
304304
COLUMNS=1 git $cmd $args --graph >output
305305
grep " | " output >actual &&
306306
test_cmp "$expect-graph" actual
307307
'
308308
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
313313
EOF
314314

315315
cat >expect <<'EOF'

0 commit comments

Comments
 (0)