Merge branch 'lt/dirwalk'
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 1601783..77c09a8 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -237,7 +237,7 @@ static char *pprint_rename(const char *a, const char *b)
                if (a_midlen < 0) a_midlen = 0;
                if (b_midlen < 0) b_midlen = 0;
 
-               name = xmalloc(len_a + len_b - pfx_length - sfx_length + 7);
+               name = xmalloc(pfx_length + a_midlen + b_midlen + sfx_length + 7);
                sprintf(name, "%.*s{%.*s => %.*s}%s",
                        pfx_length, a,
                        a_midlen, a + pfx_length,
@@ -1988,6 +1988,9 @@ void diff_flush(struct diff_options *options)
                show_stats(diffstat);
                free(diffstat);
                diffstat = NULL;
+               if (options->summary)
+                       for (i = 0; i < q->nr; i++)
+                               diff_summary(q->queue[i]);
                putchar(options->line_termination);
        }
        for (i = 0; i < q->nr; i++) {
@@ -2001,7 +2004,7 @@ void diff_flush(struct diff_options *options)
        }
 
        for (i = 0; i < q->nr; i++) {
-               if (options->summary)
+               if (diffstat && options->summary)
                        diff_summary(q->queue[i]);
                diff_free_filepair(q->queue[i]);
        }