log-tree: use custom line terminator in line termination mode
authorJan Krüger <jk@jk.gs>
Mon, 30 Apr 2012 20:28:25 +0000 (22:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 May 2012 16:56:37 +0000 (09:56 -0700)
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>
log-tree.c
t/t4205-log-pretty-formats.sh

index e9457019d5ac7aff1e185e195f37b851732f6210..f4e2ba369f8a43ca9a19ace6e8b820735fab9c6f 100644 (file)
@@ -513,7 +513,7 @@ void show_log(struct rev_info *opt)
        if (opt->use_terminator) {
                if (!opt->missing_newline)
                        graph_show_padding(opt->graph);
-               putchar('\n');
+               putchar(opt->diffopt.line_termination);
        }
 
        strbuf_release(&msgbuf);
index 2ae9faa8b37821db6e7c28ae3d98e53cb25264b1..f00e446820779e231f320bc756f044464871e601 100755 (executable)
@@ -71,4 +71,16 @@ test_expect_success 'alias loop' '
        test_must_fail git log --pretty=test-foo
 '
 
+test_expect_success 'NUL separation' '
+       printf "add bar\0initial" >expected &&
+       git log -z --pretty="format:%s" >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'NUL termination' '
+       printf "add bar\0initial\0" >expected &&
+       git log -z --pretty="tformat:%s" >actual &&
+       test_cmp expected actual
+'
+
 test_done