diff options
author | Jeff King <peff@peff.net> | 2010-10-07 14:25:43 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-10-13 18:58:33 -0700 |
commit | 9130ac9fe17831445690ebbb60f09b86f96516b3 (patch) | |
tree | 36e2c5204978d544b6277526e5a31157acb818c9 /builtin/rev-list.c | |
parent | 7c6eafa35af805578990e76b691ff7f1a25a3c57 (diff) | |
download | git-9130ac9fe17831445690ebbb60f09b86f96516b3.tar.gz |
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/rev-list.c')
-rw-r--r-- | builtin/rev-list.c | 6 |
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 { |