summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-05-10 10:06:52 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-05-10 10:06:53 -0700
commit9aa620dfae29183c57ecc351a097f9553d1b1ac1 (patch)
tree5a24f5193fdbba1eb13de0944220f4f27407bc64 /diff.c
parentStart preparing for 1.7.10.2 (diff)
parentt4052: work around shells unable to set COLUMNS to 1 (diff)
downloadtgif-9aa620dfae29183c57ecc351a097f9553d1b1ac1.tar.xz
Merge branch 'lp/diffstat-with-graph' into maint
"log --graph" was not very friendly with "--stat" option and its output had line breaks at wrong places. By Lucian Poston (5) and Zbigniew Jędrzejewski-Szmek (3) * lp/diffstat-with-graph: t4052: work around shells unable to set COLUMNS to 1 test-lib: skip test with COLUMNS=1 under mksh Prevent graph_width of stat width from falling below min t4052: Test diff-stat output with minimum columns t4052: Adjust --graph --stat output for prefixes Adjust stat width calculations to take --graph output into account Add output_prefix_length to diff_options t4052: test --stat output with --graph
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index cd029b33d5..fc3cc73d9e 100644
--- a/diff.c
+++ b/diff.c
@@ -1509,7 +1509,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
*/
if (options->stat_width == -1)
- width = term_columns();
+ width = term_columns() - options->output_prefix_length;
else
width = options->stat_width ? options->stat_width : 80;
@@ -1537,8 +1537,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;