On Fri, Sep 21, 2007 at 06:17:12AM +0000, Junio C Hamano wrote:
Pierre Habouzit [off-list ref] writes:
quoted
This reinstates the trace_argv_printf API. The implementation is
stupid, but is rewritten in a latter commit. I didn't wanted to bother
optimizing it.
...
cache.h | 2 -
imap-send.c | 13 ++++++++
merge-recursive.c | 74 ++++++++++++++++++++-----------------------
trace.c | 90 ++++++++++++++++-------------------------------------
4 files changed, 74 insertions(+), 105 deletions(-)
...
diff --git a/merge-recursive.c b/merge-recursive.c
index 14b56c2..4e27549 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -85,63 +85,57 @@ struct stage_data
+static void flush_output(void)
{
+ if (obuf.len) {
+ fputs(obuf.buf, stdout);
+ strbuf_reset(&obuf);
}
}
This assumes obuf.buf has necessary indentations and line
breaks, which is sensible. However...
quoted
+static void output(int v, const char *fmt, ...)
{
+ if (show(v)) {
+ int len;
+ va_list ap;
Yuck, this single if statement covers the entirety of the
function. Let's do
if (!show(v))
return;
quoted
+ strbuf_grow(&obuf, call_depth);
+ memset(obuf.buf + obuf.len, ' ', call_depth);
+ strbuf_setlen(&obuf, obuf.len + call_depth);
Per depth indentation used to be two whitespaces.
quoted
+ va_start(ap, fmt);
+ len = vsnprintf(obuf.buf, strbuf_avail(&obuf) + 1, fmt, ap);
+ va_end(ap);
And you overwrite whatever used to be in the buffer, including
the previous buffered message and indentation you added. Not
nice...
ooops, I wrote it too quickly.
I'll squash this on top of yours for now.
works for me except the little remark in the end :)
merge-recursive.c | 45 +++++++++++++++++++++++----------------------
1 files changed, 23 insertions(+), 22 deletions(-)
+ strbuf_setlen(&obuf, obuf.len + len);
+ strbuf_add(&obuf, "\n", 1);
rather use strbuf_addch(&obuf, '\n')
+ if (!buffer_output)
+ flush_output();
}
static void output_commit_title(struct commit *commit)
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org