branch.c: use 'ref-filter' APIs
[gitweb.git] / t / t6302-for-each-ref-filter.sh
index bab1f283b49284e18ad45800fe216d05b43af1ba..fe4796cc9c8b91210f98af8703f1b58e32e757c3 100755 (executable)
@@ -219,4 +219,40 @@ 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