summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2010-10-07 14:25:43 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-10-13 18:58:33 -0700
commit9130ac9fe17831445690ebbb60f09b86f96516b3 (patch)
tree36e2c5204978d544b6277526e5a31157acb818c9 /builtin
parentt/t3415: use && where applicable. (diff)
downloadtgif-9130ac9fe17831445690ebbb60f09b86f96516b3.tar.xz
rev-list: handle %x00 NUL in user format
The code paths for showing commits in "git log" and "git rev-list --graph" correctly handle embedded NULs by looking only at the resulting strbuf's length, and never treating it as a C string. The code path for regular rev-list, however, used printf("%s"), which resulted in truncated output. This patch uses fwrite instead, like the --graph code path. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rev-list.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index efe9360e2f..3b2dca0809 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -147,8 +147,10 @@ static void show_commit(struct commit *commit, void *data)
}
} else {
if (revs->commit_format != CMIT_FMT_USERFORMAT ||
- buf.len)
- printf("%s%c", buf.buf, info->hdr_termination);
+ buf.len) {
+ fwrite(buf.buf, 1, buf.len, stdout);
+ putchar(info->hdr_termination);
+ }
}
strbuf_release(&buf);
} else {