RelNotes: minor typo fixes in 2.15.1 draft
[gitweb.git] / t / t6300-for-each-ref.sh
index edc1bd8eabd6df02e49646930ee5eb56bf1b77f9..3aa534933e08f85ea1c215e5ef6cc6c7f4a7cd31 100755 (executable)
@@ -426,8 +426,7 @@ test_expect_success 'set up color tests' '
 '
 
 test_expect_success TTY '%(color) shows color with a tty' '
-       test_terminal env TERM=vt100 \
-               git for-each-ref --format="$color_format" >actual.raw &&
+       test_terminal git for-each-ref --format="$color_format" >actual.raw &&
        test_decode_color <actual.raw >actual &&
        test_cmp expected.color actual
 '
@@ -437,12 +436,17 @@ test_expect_success '%(color) does not show color without tty' '
        test_cmp expected.bare actual
 '
 
-test_expect_success 'color.ui=always can override tty check' '
-       git -c color.ui=always for-each-ref --format="$color_format" >actual.raw &&
+test_expect_success '--color can override tty check' '
+       git for-each-ref --color --format="$color_format" >actual.raw &&
        test_decode_color <actual.raw >actual &&
        test_cmp expected.color actual
 '
 
+test_expect_success 'color.ui=always does not override tty check' '
+       git -c color.ui=always for-each-ref --format="$color_format" >actual &&
+       test_cmp expected.bare actual
+'
+
 cat >expected <<\EOF
 heads/master
 tags/master
@@ -606,18 +610,104 @@ test_expect_success 'do not dereference NULL upon %(HEAD) on unborn branch' '
 cat >trailers <<EOF
 Reviewed-by: A U Thor <author@example.com>
 Signed-off-by: A U Thor <author@example.com>
+[ v2 updated patch description ]
+Acked-by: A U Thor
+  <author@example.com>
 EOF
 
-test_expect_success 'basic atom: head contents:trailers' '
+unfold () {
+       perl -0pe 's/\n\s+/ /g'
+}
+
+test_expect_success 'set up trailers for next test' '
        echo "Some contents" > two &&
        git add two &&
-       git commit -F - <<-EOF &&
+       git commit -F - <<-EOF
        trailers: this commit message has trailers
 
        Some message contents
 
        $(cat trailers)
        EOF
+'
+
+test_expect_success '%(trailers:unfold) unfolds trailers' '
+       git for-each-ref --format="%(trailers:unfold)" refs/heads/master >actual &&
+       {
+               unfold <trailers
+               echo
+       } >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '%(trailers:only) shows only "key: value" trailers' '
+       git for-each-ref --format="%(trailers:only)" refs/heads/master >actual &&
+       {
+               grep -v patch.description <trailers &&
+               echo
+       } >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '%(trailers:only) and %(trailers:unfold) work together' '
+       git for-each-ref --format="%(trailers:only,unfold)" refs/heads/master >actual &&
+       git for-each-ref --format="%(trailers:unfold,only)" refs/heads/master >reverse &&
+       test_cmp actual reverse &&
+       {
+               grep -v patch.description <trailers | unfold &&
+               echo
+       } >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '%(contents:trailers:unfold) unfolds trailers' '
+       git for-each-ref --format="%(contents:trailers:unfold)" refs/heads/master >actual &&
+       {
+               unfold <trailers
+               echo
+       } >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '%(contents:trailers:only) shows only "key: value" trailers' '
+       git for-each-ref --format="%(contents:trailers:only)" refs/heads/master >actual &&
+       {
+               grep -v patch.description <trailers &&
+               echo
+       } >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '%(contents:trailers:only) and %(contents:trailers:unfold) work together' '
+       git for-each-ref --format="%(contents:trailers:only,unfold)" refs/heads/master >actual &&
+       git for-each-ref --format="%(contents:trailers:unfold,only)" refs/heads/master >reverse &&
+       test_cmp actual reverse &&
+       {
+               grep -v patch.description <trailers | unfold &&
+               echo
+       } >expect &&
+       test_cmp expect actual
+'
+
+test_expect_success '%(trailers) rejects unknown trailers arguments' '
+       # error message cannot be checked under i18n
+       cat >expect <<-EOF &&
+       fatal: unknown %(trailers) argument: unsupported
+       EOF
+       test_must_fail git for-each-ref --format="%(trailers:unsupported)" 2>actual &&
+       test_i18ncmp expect actual
+'
+
+test_expect_success '%(contents:trailers) rejects unknown trailers arguments' '
+       # error message cannot be checked under i18n
+       cat >expect <<-EOF &&
+       fatal: unknown %(trailers) argument: unsupported
+       EOF
+       test_must_fail git for-each-ref --format="%(contents:trailers:unsupported)" 2>actual &&
+       test_i18ncmp expect actual
+'
+
+test_expect_success 'basic atom: head contents:trailers' '
        git for-each-ref --format="%(contents:trailers)" refs/heads/master >actual &&
        sanitize_pgp <actual >actual.clean &&
        # git for-each-ref ends with a blank line