summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-08-01 13:44:50 +0200
committerJunio C Hamano <gitster@pobox.com>2016-08-01 11:45:30 -0700
commitf1e2426b28399b563527d110c849acd65b680de6 (patch)
tree5419f5c03468624bee5005f86929e93cdc7c7d7a /merge-recursive.c
parentdde75cb0561fa8a6bbb2de4c3662dbcc33728938 (diff)
downloadgit-f1e2426b28399b563527d110c849acd65b680de6.tar.gz
merge-recursive: offer an option to retain the output in 'obuf'
Since 66a155b (Enable output buffering in merge-recursive., 2007-01-14), we already accumulate the output in a buffer. The idea was to avoid interfering with the progress output that goes to stderr, which is unbuffered, when we write to stdout, which is buffered. We extend that buffering to allow the caller to handle the output (possibly suppressing it). This will help us when extending the sequencer to do rebase -i's brunt work: it does not want the picks to print anything by default but instead determine itself whether to print the output or not. Note that we also redirect the error messages into the output buffer when the caller asked not to flush the output buffer, for two reasons: 1) to retain the correct output order, and 2) to allow the caller to suppress *all* output. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 99c963558b..ec50932210 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -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;
}