pretty: add support for separator option in %(trailers)
[gitweb.git] / t / t4205-log-pretty-formats.sh
index 1ad68347815286c1980626610fb16bd95005ce37..99f50fa401cbddc7df508d55b3f876728b97047f 100755 (executable)
@@ -679,6 +679,42 @@ test_expect_success '%(trailers:key=foo,valueonly) shows only value' '
        test_cmp expect actual
 '
 
+test_expect_success 'pretty format %(trailers:separator) changes separator' '
+       git log --no-walk --pretty=format:"X%(trailers:separator=%x00,unfold)X" >actual &&
+       printf "XSigned-off-by: A U Thor <author@example.com>\0Acked-by: A U Thor <author@example.com>\0[ v2 updated patch description ]\0Signed-off-by: A U Thor <author@example.com>X" >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success 'pretty format %(trailers) combining separator/key/valueonly' '
+       git commit --allow-empty -F - <<-\EOF &&
+       Important fix
+
+       The fix is explained here
+
+       Closes: #1234
+       EOF
+
+       git commit --allow-empty -F - <<-\EOF &&
+       Another fix
+
+       The fix is explained here
+
+       Closes: #567
+       Closes: #890
+       EOF
+
+       git commit --allow-empty -F - <<-\EOF &&
+       Does not close any tickets
+       EOF
+
+       git log --pretty="%s% (trailers:separator=%x2c%x20,key=Closes,valueonly)" HEAD~3.. >actual &&
+       test_write_lines \
+               "Does not close any tickets" \
+               "Another fix #567, #890" \
+               "Important fix #1234" >expect &&
+       test_cmp expect actual
+'
+
 test_expect_success 'trailer parsing not fooled by --- line' '
        git commit --allow-empty -F - <<-\EOF &&
        this is the subject