Skip to content

Commit

Permalink
show_stats(): fix stats width calculation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Olivier Marin authored and Junio C Hamano committed Jun 29, 2008
1 parent 8813df9 commit 861d1af
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 861d1af

Please sign in to comment.