Skip to content

Commit

Permalink
Merge branch 'jk/maint-rev-list-nul' into maint
Browse files Browse the repository at this point in the history
* jk/maint-rev-list-nul:
  rev-list: handle %x00 NUL in user format
  • Loading branch information
Junio C Hamano committed Nov 24, 2010
2 parents 9cffe20 + 9130ac9 commit e7b9b80
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions builtin/rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions t/t4012-diff-binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions t/t6006-rev-list-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
4 changes: 4 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
}
Expand Down

0 comments on commit e7b9b80

Please sign in to comment.