submodule: convert show_submodule_summary to use struct object_id *
[gitweb.git] / merge-recursive.c
index 99c963558b08ae59bff629e5980329a124bf099f..c9e4dbc349243caed51ab524edf3d3ebb31a0d2c 100644 (file)
@@ -25,7 +25,7 @@
 
 static void flush_output(struct merge_options *o)
 {
-       if (o->obuf.len) {
+       if (o->buffer_output < 2 && o->obuf.len) {
                fputs(o->obuf.buf, stdout);
                strbuf_reset(&o->obuf);
        }
@@ -35,12 +35,21 @@ static int err(struct merge_options *o, const char *err, ...)
 {
        va_list params;
 
-       flush_output(o);
+       if (o->buffer_output < 2)
+               flush_output(o);
+       else {
+               strbuf_complete(&o->obuf, '\n');
+               strbuf_addstr(&o->obuf, "error: ");
+       }
        va_start(params, err);
        strbuf_vaddf(&o->obuf, err, params);
        va_end(params);
-       error("%s", o->obuf.buf);
-       strbuf_reset(&o->obuf);
+       if (o->buffer_output > 1)
+               strbuf_addch(&o->obuf, '\n');
+       else {
+               error("%s", o->obuf.buf);
+               strbuf_reset(&o->obuf);
+       }
 
        return -1;
 }
@@ -2060,8 +2069,10 @@ int merge_recursive(struct merge_options *o,
        o->ancestor = "merged common ancestors";
        clean = merge_trees(o, h1->tree, h2->tree, merged_common_ancestors->tree,
                            &mrtree);
-       if (clean < 0)
+       if (clean < 0) {
+               flush_output(o);
                return clean;
+       }
 
        if (o->call_depth) {
                *result = make_virtual_commit(mrtree, "merged tree");
@@ -2069,6 +2080,8 @@ int merge_recursive(struct merge_options *o,
                commit_list_insert(h2, &(*result)->parents->next);
        }
        flush_output(o);
+       if (!o->call_depth && o->buffer_output < 2)
+               strbuf_release(&o->obuf);
        if (show(o, 2))
                diff_warn_rename_limit("merge.renamelimit",
                                       o->needed_rename_limit, 0);