diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-11-17 14:59:33 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-11-17 14:59:33 -0800 |
commit | 07e0a8314d69986d368b08f8b602ac573fa7d9b6 (patch) | |
tree | 1c238e3e91d83d3dae5b31eac9bb11f353ed7c60 | |
parent | dd9d290bc983255a24c70e26e7fad40c6212b636 (diff) | |
parent | 9130ac9fe17831445690ebbb60f09b86f96516b3 (diff) | |
download | git-07e0a8314d69986d368b08f8b602ac573fa7d9b6.tar.gz |
Merge branch 'jk/maint-rev-list-nul'
* jk/maint-rev-list-nul:
rev-list: handle %x00 NUL in user format
-rw-r--r-- | builtin/rev-list.c | 6 | ||||
-rwxr-xr-x | t/t4012-diff-binary.sh | 4 | ||||
-rwxr-xr-x | t/t6006-rev-list-format.sh | 8 | ||||
-rw-r--r-- | t/test-lib.sh | 4 |
4 files changed, 16 insertions, 6 deletions
diff --git a/builtin/rev-list.c b/builtin/rev-list.c index 158ce1111a..ba27d39f97 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 { diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index bc46563afc..05ec062832 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -77,10 +77,6 @@ test_expect_success 'apply binary patch' \ 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 diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index cccacd4add..d918cc02d0 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -162,6 +162,14 @@ commit 131a310eb913d107dd3c09a65d1651175898735d 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 2af8f10c83..bbe79e0fcb 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -248,6 +248,10 @@ test_decode_color () { -e 's/.\[m/<RESET>/g' } +nul_to_q () { + perl -pe 'y/\000/Q/' +} + q_to_nul () { perl -pe 'y/Q/\000/' } |