]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'jk/maint-rev-list-nul' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Nov 2010 20:46:32 +0000 (12:46 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Nov 2010 20:46:32 +0000 (12:46 -0800)
* jk/maint-rev-list-nul:
  rev-list: handle %x00 NUL in user format

builtin/rev-list.c
t/t4012-diff-binary.sh
t/t6006-rev-list-format.sh
t/test-lib.sh

index 158ce1111af12db1445d82cfa5728bc19837570d..ba27d39f977f2807cddb6e18364837b9fd50e970 100644 (file)
@@ -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 {
index bc46563afc607e6fba9acbd2773d88207c878981..05ec0628322ccc103343515feb70d27a9a0e6c76 100755 (executable)
@@ -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
index cccacd4add48524abd4a3021f8048a6c45c245ea..d918cc02d090157485d404d34d49005e50cd9f1a 100755 (executable)
@@ -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 &&
index 830e5e7360350a424a2fe6016a03c913209f7557..25f8bf95cdc7624c80ca57affb7eae799e0090c0 100644 (file)
@@ -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/'
 }