Skip to content

Commit 07e0a83

Browse files
committed
Merge branch 'jk/maint-rev-list-nul'
* jk/maint-rev-list-nul: rev-list: handle %x00 NUL in user format
2 parents dd9d290 + 9130ac9 commit 07e0a83

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

builtin/rev-list.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ static void show_commit(struct commit *commit, void *data)
147147
}
148148
} else {
149149
if (revs->commit_format != CMIT_FMT_USERFORMAT ||
150-
buf.len)
151-
printf("%s%c", buf.buf, info->hdr_termination);
150+
buf.len) {
151+
fwrite(buf.buf, 1, buf.len, stdout);
152+
putchar(info->hdr_termination);
153+
}
152154
}
153155
strbuf_release(&buf);
154156
} else {

t/t4012-diff-binary.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ test_expect_success 'apply binary patch' \
7777
tree1=`git write-tree` &&
7878
test "$tree1" = "$tree0"'
7979

80-
nul_to_q() {
81-
perl -pe 'y/\000/Q/'
82-
}
83-
8480
test_expect_success 'diff --no-index with binary creation' '
8581
echo Q | q_to_nul >binary &&
8682
(: hide error code from diff, which just indicates differences

t/t6006-rev-list-format.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ commit 131a310eb913d107dd3c09a65d1651175898735d
162162
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
163163
EOF
164164

165+
test_expect_success '%x00 shows NUL' '
166+
echo >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
167+
echo >>expect fooQbar &&
168+
git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
169+
nul_to_q <actual.nul >actual &&
170+
test_cmp expect actual
171+
'
172+
165173
test_expect_success '%ad respects --date=' '
166174
echo 2005-04-07 >expect.ad-short &&
167175
git log -1 --date=short --pretty=tformat:%ad >output.ad-short master &&

t/test-lib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ test_decode_color () {
248248
-e 's/.\[m/<RESET>/g'
249249
}
250250

251+
nul_to_q () {
252+
perl -pe 'y/\000/Q/'
253+
}
254+
251255
q_to_nul () {
252256
perl -pe 'y/Q/\000/'
253257
}

0 commit comments

Comments
 (0)