Merge branch 'lp/diffstat-with-graph'
[gitweb.git] / diff.c
diff --git a/diff.c b/diff.c
index 5d6349feb3f8f9483c463961e526767e2f81e4c9..7da16c9590805dc687d7dc67acac2cb104144036 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1509,7 +1509,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
         */
 
        if (options->stat_width == -1)
-               width = term_columns();
+               width = term_columns() - options->output_prefix_length;
        else
                width = options->stat_width ? options->stat_width : 80;
 
@@ -1537,8 +1537,12 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
         * Adjust adjustable widths not to exceed maximum width
         */
        if (name_width + number_width + 6 + graph_width > width) {
-               if (graph_width > width * 3/8 - number_width - 6)
+               if (graph_width > width * 3/8 - number_width - 6) {
                        graph_width = width * 3/8 - number_width - 6;
+                       if (graph_width < 6)
+                               graph_width = 6;
+               }
+
                if (options->stat_graph_width &&
                    graph_width > options->stat_graph_width)
                        graph_width = options->stat_graph_width;
@@ -4414,6 +4418,12 @@ void diff_flush(struct diff_options *options)
 
        if (output_format & DIFF_FORMAT_PATCH) {
                if (separator) {
+                       if (options->output_prefix) {
+                               struct strbuf *msg = NULL;
+                               msg = options->output_prefix(options,
+                                       options->output_prefix_data);
+                               fwrite(msg->buf, msg->len, 1, stdout);
+                       }
                        putc(options->line_termination, options->file);
                        if (options->stat_sep) {
                                /* attach patch instead of inline */