summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--merge-recursive.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index ef9932a..9237a57 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -67,11 +67,19 @@ struct stage_data
unsigned processed:1;
};
+struct output_buffer
+{
+ struct output_buffer *next;
+ char *str;
+};
+
static struct path_list current_file_set = {NULL, 0, 0, 1};
static struct path_list current_directory_set = {NULL, 0, 0, 1};
static int call_depth = 0;
static int verbosity = 2;
+static int buffer_output = 1;
+static struct output_buffer *output_list, *output_end;
static int show (int v)
{
@@ -82,7 +90,16 @@ static void output(int v, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- if (show(v)) {
+ if (buffer_output && show(v)) {
+ struct output_buffer *b = xmalloc(sizeof(*b));
+ nfvasprintf(&b->str, fmt, args);
+ b->next = NULL;
+ if (output_end)
+ output_end->next = b;
+ else
+ output_list = b;
+ output_end = b;
+ } else if (show(v)) {
int i;
for (i = call_depth; i--;)
fputs(" ", stdout);
@@ -92,9 +109,27 @@ static void output(int v, const char *fmt, ...)
va_end(args);
}
+static void flush_output()
+{
+ struct output_buffer *b, *n;
+ for (b = output_list; b; b = n) {
+ int i;
+ for (i = call_depth; i--;)
+ fputs(" ", stdout);
+ fputs(b->str, stdout);
+ fputc('\n', stdout);
+ n = b->next;
+ free(b->str);
+ free(b);
+ }
+ output_list = NULL;
+ output_end = NULL;
+}
+
static void output_commit_title(struct commit *commit)
{
int i;
+ flush_output();
for (i = call_depth; i--;)
fputs(" ", stdout);
if (commit->util)
@@ -1175,6 +1210,7 @@ static int merge(struct commit *h1,
commit_list_insert(h1, &(*result)->parents);
commit_list_insert(h2, &(*result)->parents->next);
}
+ flush_output();
return clean;
}
@@ -1252,6 +1288,8 @@ int main(int argc, char *argv[])
branch1 = better_branch_name(branch1);
branch2 = better_branch_name(branch2);
+ if (verbosity >= 5)
+ buffer_output = 0;
if (show(3))
printf("Merging %s with %s\n", branch1, branch2);