From: Olivier Marin <dkr+ml.git@free.fr>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] show_stats(): fix stats width calculation
Date: Fri, 27 Jun 2008 02:18:48 +0200 [thread overview]
Message-ID: <1214525928-31025-1-git-send-email-dkr+ml.git@free.fr> (raw)
From: Olivier Marin <dkr@freesurf.fr>
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>
---
diff.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/diff.c b/diff.c
index 44e8790..a85c8ca 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);
--
1.5.6.1.141.ge3ab.dirty
reply other threads:[~2008-06-27 0:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1214525928-31025-1-git-send-email-dkr+ml.git@free.fr \
--to=dkr+ml.git@free.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox