ref-filter: add support for %(contents:lines=X)
[gitweb.git] / t / t6302-for-each-ref-filter.sh
index f596035b0b10abe0320f84e2ff22d1ee99beb529..bab1f283b49284e18ad45800fe216d05b43af1ba 100755 (executable)
@@ -167,4 +167,56 @@ test_expect_success 'nested alignment with quote formatting' "
        test_cmp expect actual
 "
 
+test_expect_success 'check `%(contents:lines=1)`' '
+       cat >expect <<-\EOF &&
+       master |three
+       side |four
+       odd/spot |three
+       double-tag |Annonated doubly
+       four |four
+       one |one
+       signed-tag |A signed tag message
+       three |three
+       two |two
+       EOF
+       git for-each-ref --format="%(refname:short) |%(contents:lines=1)" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check `%(contents:lines=0)`' '
+       cat >expect <<-\EOF &&
+       master |
+       side |
+       odd/spot |
+       double-tag |
+       four |
+       one |
+       signed-tag |
+       three |
+       two |
+       EOF
+       git for-each-ref --format="%(refname:short) |%(contents:lines=0)" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'check `%(contents:lines=99999)`' '
+       cat >expect <<-\EOF &&
+       master |three
+       side |four
+       odd/spot |three
+       double-tag |Annonated doubly
+       four |four
+       one |one
+       signed-tag |A signed tag message
+       three |three
+       two |two
+       EOF
+       git for-each-ref --format="%(refname:short) |%(contents:lines=99999)" >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success '`%(contents:lines=-1)` should fail' '
+       test_must_fail git for-each-ref --format="%(refname:short) |%(contents:lines=-1)"
+'
+
 test_done