Merge branch 'jk/delete-modechange-conflict'
[gitweb.git] / t / t6302-for-each-ref-filter.sh
index f596035b0b10abe0320f84e2ff22d1ee99beb529..fe4796cc9c8b91210f98af8703f1b58e32e757c3 100755 (executable)
@@ -167,4 +167,92 @@ 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_expect_success 'setup for version sort' '
+       test_commit foo1.3 &&
+       test_commit foo1.6 &&
+       test_commit foo1.10
+'
+
+test_expect_success 'version sort' '
+       git for-each-ref --sort=version:refname --format="%(refname:short)" refs/tags/ | grep "foo" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.3
+       foo1.6
+       foo1.10
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'version sort (shortened)' '
+       git for-each-ref --sort=v:refname --format="%(refname:short)" refs/tags/ | grep "foo" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.3
+       foo1.6
+       foo1.10
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'reverse version sort' '
+       git for-each-ref --sort=-version:refname --format="%(refname:short)" refs/tags/ | grep "foo" >actual &&
+       cat >expect <<-\EOF &&
+       foo1.10
+       foo1.6
+       foo1.3
+       EOF
+       test_cmp expect actual
+'
+
 test_done