Junio C Hamano [off-list ref] writes:
Jeff King [off-list ref] writes:
quoted
Hmm. This came up before, and the issue is (or can be) slightly more
complex:
http://thread.gmane.org/gmane.comp.version-control.git/122478/focus=122568
Yeah, the test given completely forgets about "log -p" case, as you said
in the above:
But we can't just modify that to use the specified line terminator,
because sometimes it is acting as a separator between commit message and
diff, and sometimes it is acting as the terminator of the whole record.
So the patch is not quite right for the "log -p -z" (or "log --stat -z")
case.
The correct output would have NUL after each commit, so "-z --format=%s"
would have a single-liner subject with the line-terminating LF replaced
with NUL, and "-p/--stat -z --format=%s" would have a single-liner subject
with its line-terminating LF, followed by the diff/diffstat in which the
terminating LF of the last line is replaced with NUL, but to be consistent
with what "-p/--stat -z --pretty=format:%s" does, I think it is OK to
append NUL to the diff/diffstat part instead of replacing its last LF with
NUL.
In other words, this test on top (the last one only demonstrates the
breakage).
t/t4205-log-pretty-formats.sh | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index f00e446..4afd778 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -83,4 +83,20 @@ test_expect_success 'NUL termination' '
test_cmp expected actual
'
+test_expect_success 'NUL separation with --stat' '
+ stat0_part=$(git diff --stat HEAD^ HEAD) &&
+ stat1_part=$(git diff --stat --root HEAD^) &&
+ printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
+ git log -z --stat --pretty="format:%s" >actual &&
+ test_cmp expected actual
+'
+
+test_expect_failure 'NUL termination with --stat' '
+ stat0_part=$(git diff --stat HEAD^ HEAD) &&
+ stat1_part=$(git diff --stat --root HEAD^) &&
+ printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
+ git log -z --stat --pretty="tformat:%s" >actual &&
+ test_cmp expected actual
+'
+
test_done