{"thread":{"id":"14174","subject":"[PATCH] show_stats(): fix stats width calculation","startedAt":"2008-06-27T00:18:48Z","lastAt":"2008-06-27T00:18:48Z","messageCount":1,"participants":["Olivier Marin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"81346","messageId":"1214525928-31025-1-git-send-email-dkr+ml.git@free.fr","threadId":"14174","inReplyTo":null,"subject":"[PATCH] show_stats(): fix stats width calculation","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-06-27T00:18:48Z","receivedAt":"2008-06-27T00:18:48Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"From: Olivier Marin <dkr@freesurf.fr>\n\nBefore this patch, name_width becomes negative or null for width values\nless than 15 and name_width values greater than 25 (default: 50). This\nleads to output random data.\n\nThis patch checks for minimal width and name_width values.\n\nSigned-off-by: Olivier Marin <dkr@freesurf.fr>\n---\n diff.c |   12 ++++++------\n 1 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 44e8790..a85c8ca 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -830,12 +830,12 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)\n \t/* Sanity: give at least 5 columns to the graph,\n \t * but leave at least 10 columns for the name.\n \t */\n-\tif (width < name_width + 15) {\n-\t\tif (name_width <= 25)\n-\t\t\twidth = name_width + 15;\n-\t\telse\n-\t\t\tname_width = width - 15;\n-\t}\n+\tif (width < 25)\n+\t\twidth = 25;\n+\tif (name_width < 10)\n+\t\tname_width = 10;\n+\telse if (width < name_width + 15)\n+\t\tname_width = width - 15;\n \n \t/* Find the longest filename and max number of changes */\n \treset = diff_get_color_opt(options, DIFF_RESET);\n-- \n1.5.6.1.141.ge3ab.dirty\n"}]}