Skip to content

Commit 43d1e41

Browse files
committed
Merge branch 'jk/maint-tformat-with-z'
"log -z --pretty=tformat:..." does not terminate each record with NUL and this is a beginning of an attempt to fix it. It still is not right but the patch does not make externally observable behaviour worse. By Jan Krüger (1) and Junio C Hamano (1) * jk/maint-tformat-with-z: log-tree: the previous one is still not quite right log-tree: use custom line terminator in line termination mode
2 parents cae0977 + fafd382 commit 43d1e41

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ void show_log(struct rev_info *opt)
682682
if (opt->use_terminator) {
683683
if (!opt->missing_newline)
684684
graph_show_padding(opt->graph);
685-
putchar('\n');
685+
putchar(opt->diffopt.line_termination);
686686
}
687687

688688
strbuf_release(&msgbuf);

t/t4205-log-pretty-formats.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,32 @@ test_expect_success 'alias loop' '
7171
test_must_fail git log --pretty=test-foo
7272
'
7373

74+
test_expect_success 'NUL separation' '
75+
printf "add bar\0initial" >expected &&
76+
git log -z --pretty="format:%s" >actual &&
77+
test_cmp expected actual
78+
'
79+
80+
test_expect_success 'NUL termination' '
81+
printf "add bar\0initial\0" >expected &&
82+
git log -z --pretty="tformat:%s" >actual &&
83+
test_cmp expected actual
84+
'
85+
86+
test_expect_success 'NUL separation with --stat' '
87+
stat0_part=$(git diff --stat HEAD^ HEAD) &&
88+
stat1_part=$(git diff --stat --root HEAD^) &&
89+
printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n" >expected &&
90+
git log -z --stat --pretty="format:%s" >actual &&
91+
test_cmp expected actual
92+
'
93+
94+
test_expect_failure 'NUL termination with --stat' '
95+
stat0_part=$(git diff --stat HEAD^ HEAD) &&
96+
stat1_part=$(git diff --stat --root HEAD^) &&
97+
printf "add bar\n$stat0_part\n\0initial\n$stat1_part\n\0" >expected &&
98+
git log -z --stat --pretty="tformat:%s" >actual &&
99+
test_cmp expected actual
100+
'
101+
74102
test_done

0 commit comments

Comments
 (0)