summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorOlivier Marin <dkr@freesurf.fr>2008-06-27 02:18:48 +0200
committerJunio C Hamano <gitster@pobox.com>2008-06-28 20:55:26 -0700
commit861d1af36ae168353fc352126c0bf2d189c2324a (patch)
tree4880b0f1d550b10cb1b9975b4a25a99e12414119 /diff.c
parent8813df9066427ffe40d1d77d18f20643f396f153 (diff)
downloadgit-861d1af36ae168353fc352126c0bf2d189c2324a.tar.gz
show_stats(): fix stats width calculation
Before this patch, name_width becomes negative or null for width values less than 15 and name_width values greater than 25 (default: 50). This leads to output random data. This patch checks for minimal width and name_width values. Signed-off-by: Olivier Marin <dkr@freesurf.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index 893942359b..66851b5647 100644
--- a/diff.c
+++ b/diff.c
@@ -830,12 +830,12 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
/* Sanity: give at least 5 columns to the graph,
* but leave at least 10 columns for the name.
*/
- if (width < name_width + 15) {
- if (name_width <= 25)
- width = name_width + 15;
- else
- name_width = width - 15;
- }
+ if (width < 25)
+ width = 25;
+ if (name_width < 10)
+ name_width = 10;
+ else if (width < name_width + 15)
+ name_width = width - 15;
/* Find the longest filename and max number of changes */
reset = diff_get_color_opt(options, DIFF_RESET);