summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 39bc5e4)
raw | patch | inline | side by side (parent: 39bc5e4)
author | Jeff King <peff@peff.net> | |
Thu, 24 Feb 2011 14:29:50 +0000 (09:29 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 8 Mar 2011 20:12:04 +0000 (12:12 -0800) |
If you happen to have a strbuf, it is a little more readable
and a little more efficient to be able to print it directly
instead of jamming it through the trace_printf interface.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and a little more efficient to be able to print it directly
instead of jamming it through the trace_printf interface.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
trace.c | patch | blob | history |
index 211d7bb26ec2499bb5f2a5733b61e0963f17b1fb..3978112f55e258bf67fef16dcbed2dd49feb4552 100644 (file)
--- a/cache.h
+++ b/cache.h
extern void trace_argv_printf(const char **argv, const char *format, ...);
extern void trace_repo_setup(const char *prefix);
extern int trace_want(const char *key);
+extern void trace_strbuf(const char *key, const struct strbuf *buf);
/* convert.c */
/* returns 1 if *dst was used */
index ca0ab0448bd3981e740e99e14935670cae729ede..9f39eab025248511449a2dc6921578510e8429b4 100644 (file)
--- a/trace.c
+++ b/trace.c
void trace_vprintf(const char *key, const char *fmt, va_list ap)
{
struct strbuf buf = STRBUF_INIT;
- int fd, need_close = 0;
- fd = get_trace_fd(key, &need_close);
- if (!fd)
+ if (!trace_want(key))
return;
set_try_to_free_routine(NULL); /* is never reset */
strbuf_vaddf(&buf, fmt, ap);
- write_or_whine_pipe(fd, buf.buf, buf.len, err_msg);
+ trace_strbuf(key, &buf);
strbuf_release(&buf);
-
- if (need_close)
- close(fd);
}
void trace_printf_key(const char *key, const char *fmt, ...)
va_end(ap);
}
+void trace_strbuf(const char *key, const struct strbuf *buf)
+{
+ int fd, need_close = 0;
+
+ fd = get_trace_fd(key, &need_close);
+ if (!fd)
+ return;
+
+ write_or_whine_pipe(fd, buf->buf, buf->len, err_msg);
+
+ if (need_close)
+ close(fd);
+}
+
void trace_argv_printf(const char **argv, const char *fmt, ...)
{
struct strbuf buf = STRBUF_INIT;