summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7c6eafa)
raw | patch | inline | side by side (parent: 7c6eafa)
author | Jeff King <peff@peff.net> | |
Thu, 7 Oct 2010 18:25:43 +0000 (14:25 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 14 Oct 2010 01:58:33 +0000 (18:58 -0700) |
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>
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>
builtin/rev-list.c | patch | blob | history | |
t/t4012-diff-binary.sh | patch | blob | history | |
t/t6006-rev-list-format.sh | patch | blob | history | |
t/test-lib.sh | patch | blob | history |
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index efe9360e2fdb9aac3bae0c61c85531041f24708a..3b2dca08093bf5eb8fe1a2ffe08036fdd903cedb 100644 (file)
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
}
} 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 {
diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh
index bc46563afc607e6fba9acbd2773d88207c878981..05ec0628322ccc103343515feb70d27a9a0e6c76 100755 (executable)
--- a/t/t4012-diff-binary.sh
+++ b/t/t4012-diff-binary.sh
tree1=`git write-tree` &&
test "$tree1" = "$tree0"'
-nul_to_q() {
- perl -pe 'y/\000/Q/'
-}
-
test_expect_success 'diff --no-index with binary creation' '
echo Q | q_to_nul >binary &&
(: hide error code from diff, which just indicates differences
index cccacd4add48524abd4a3021f8048a6c45c245ea..d918cc02d090157485d404d34d49005e50cd9f1a 100755 (executable)
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
EOF
+test_expect_success '%x00 shows NUL' '
+ echo >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+ echo >>expect fooQbar &&
+ git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
+ nul_to_q <actual.nul >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '%ad respects --date=' '
echo 2005-04-07 >expect.ad-short &&
git log -1 --date=short --pretty=tformat:%ad >output.ad-short master &&
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 830e5e7360350a424a2fe6016a03c913209f7557..25f8bf95cdc7624c80ca57affb7eae799e0090c0 100644 (file)
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
-e 's/.\[m/<RESET>/g'
}
+nul_to_q () {
+ perl -pe 'y/\000/Q/'
+}
+
q_to_nul () {
perl -pe 'y/Q/\000/'
}