Skip to content

Commit 3e06530

Browse files
jastgitster
authored andcommitted
log-tree: use custom line terminator in line termination mode
When using a custom format in line termination mode (as opposed to line separation mode), the configured line terminator is not used, so things like "git log --pretty=tformat:%H -z" do not work properly. Make it use the line terminator the user ordered. Signed-off-by: Jan Krüger <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f174a25 commit 3e06530

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ void show_log(struct rev_info *opt)
513513
if (opt->use_terminator) {
514514
if (!opt->missing_newline)
515515
graph_show_padding(opt->graph);
516-
putchar('\n');
516+
putchar(opt->diffopt.line_termination);
517517
}
518518

519519
strbuf_release(&msgbuf);

t/t4205-log-pretty-formats.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,16 @@ 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+
7486
test_done

0 commit comments

Comments
 (0)