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 <jk@jk.gs> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jan Krüger committed
Apr 30, 2012 at 22:28 UTC
3e065308cab1ac0855bf19be8881def74bfcf7fc
2 files changed
+13
-1
log-tree.c
+1
-1
@@ -513,7 +513,7 @@ void show_log(struct rev_info *opt)
513
if (opt->use_terminator) {
514
if (!opt->missing_newline)
515
graph_show_padding(opt->graph);
516
- putchar('\n');
516
+ putchar(opt->diffopt.line_termination);
517
}
518
519
strbuf_release(&msgbuf);
t/t4205-log-pretty-formats.sh
+12
@@ -71,4 +71,16 @@ test_expect_success 'alias loop' '
71
test_must_fail git log --pretty=test-foo
72
'
73
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_done