aboutsummaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-31 20:50:49 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-31 20:50:49 -0700
commit95bedc9eecfa4d905a9d85dff8b406049476d9e7 (patch)
treea2f99ab2af90b6aeae2b6d1f77829e5aa102218f /apply.c
parent66204988fe2e5a2a18c4ff55798c7203775d9fd4 (diff)
downloadgit-95bedc9eecfa4d905a9d85dff8b406049476d9e7.tar.gz
git-95bedc9eecfa4d905a9d85dff8b406049476d9e7.tar.xz
git-apply --stat: limit lines to 79 characters
It had already tried to do that, but with the independent rounding of the number of '+' and '-' characters, it would sometimes do 80-char lines after all.
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/apply.c b/apply.c
index dba829226..e0a154902 100644
--- a/apply.c
+++ b/apply.c
@@ -699,7 +699,7 @@ const char minuses[]= "---------------------------------------------------------
static void show_stats(struct patch *patch)
{
char *name = patch->old_name;
- int len, max, add, del;
+ int len, max, add, del, total;
if (!name)
name = patch->new_name;
@@ -721,9 +721,14 @@ static void show_stats(struct patch *patch)
max = max_change;
if (max + len > 70)
max = 70 - len;
-
- add = (patch->lines_added * max + max_change/2) / max_change;
- del = (patch->lines_deleted * max + max_change/2) / max_change;
+
+ add = patch->lines_added;
+ del = patch->lines_deleted;
+ total = add + del;
+
+ total = (total * max + max_change / 2) / max_change;
+ add = (add * max + max_change / 2) / max_change;
+ del = total - add;
printf(" %-*s |%5d %.*s%.*s\n",
len, name, patch->lines_added + patch->lines_deleted,
add, pluses, del, minuses);