pretty_print_commit: add different formats
[git.git] / apply.c
diff --git a/apply.c b/apply.c
index 74908cd..e0a1549 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -116,9 +116,8 @@ static int is_dev_null(const char *str)
        return !memcmp("/dev/null", str, 9) && isspace(str[9]);
 }
 
-#define TERM_EXIST     1
-#define TERM_SPACE     2
-#define TERM_TAB       4
+#define TERM_SPACE     1
+#define TERM_TAB       2
 
 static int name_terminate(const char *name, int namelen, int c, int terminate)
 {
@@ -127,13 +126,6 @@ static int name_terminate(const char *name, int namelen, int c, int terminate)
        if (c == '\t' && !(terminate & TERM_TAB))
                return 0;
 
-       /*
-        * Do we want an existing name? Return false and
-        * continue if it's not there.
-        */
-       if (terminate & TERM_EXIST)
-               return cache_name_pos(name, namelen) >= 0;
-
        return 1;
 }
 
@@ -205,11 +197,11 @@ static void parse_traditional_patch(const char *first, const char *second, struc
        } else if (is_dev_null(second)) {
                patch->is_new = 0;
                patch->is_delete = 1;
-               name = find_name(first, NULL, p_value, TERM_EXIST | TERM_SPACE | TERM_TAB);
+               name = find_name(first, NULL, p_value, TERM_SPACE | TERM_TAB);
                patch->old_name = name;
        } else {
-               name = find_name(first, NULL, p_value, TERM_EXIST | TERM_SPACE | TERM_TAB);
-               name = find_name(second, name, p_value, TERM_EXIST | TERM_SPACE | TERM_TAB);
+               name = find_name(first, NULL, p_value, TERM_SPACE | TERM_TAB);
+               name = find_name(second, name, p_value, TERM_SPACE | TERM_TAB);
                patch->old_name = patch->new_name = name;
        }
        if (!name)
@@ -707,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;
@@ -729,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);