l10n: sv.po: Update Swedish translation (3288t0f0u)
[gitweb.git] / t / t6302-for-each-ref-filter.sh
index d0ab09f4bd804730eb049ea982e5724653583f06..fc067ed6723bc0aaaddd2473e4d61f13087b9e15 100755 (executable)
@@ -93,6 +93,22 @@ test_expect_success 'filtering with --contains' '
        test_cmp expect actual
 '
 
+test_expect_success 'filtering with --no-contains' '
+       cat >expect <<-\EOF &&
+       refs/tags/one
+       EOF
+       git for-each-ref --format="%(refname)" --no-contains=two >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'filtering with --contains and --no-contains' '
+       cat >expect <<-\EOF &&
+       refs/tags/two
+       EOF
+       git for-each-ref --format="%(refname)" --contains=two --no-contains=three >actual &&
+       test_cmp expect actual
+'
+
 test_expect_success '%(color) must fail' '
        test_must_fail git for-each-ref --format="%(color)%(refname)"
 '
@@ -327,4 +343,102 @@ test_expect_success 'reverse version sort' '
        test_cmp expect actual
 '
 
+test_expect_success 'improper usage of %(if), %(then), %(else) and %(end) atoms' '
+       test_must_fail git for-each-ref --format="%(if)" &&
+       test_must_fail git for-each-ref --format="%(then) %(end)" &&
+       test_must_fail git for-each-ref --format="%(else) %(end)" &&
+       test_must_fail git for-each-ref --format="%(if) %(else) %(end)" &&
+       test_must_fail git for-each-ref --format="%(if) %(then) %(then) %(end)" &&
+       test_must_fail git for-each-ref --format="%(then) %(else) %(end)" &&
+       test_must_fail git for-each-ref --format="%(if) %(else) %(end)" &&
+       test_must_fail git for-each-ref --format="%(if) %(then) %(else)" &&
+       test_must_fail git for-each-ref --format="%(if) %(else) %(then) %(end)" &&
+       test_must_fail git for-each-ref --format="%(if) %(then) %(else) %(else) %(end)" &&
+       test_must_fail git for-each-ref --format="%(if) %(end)"
+'
+
+test_expect_success 'check %(if)...%(then)...%(end) atoms' '
+       git for-each-ref --format="%(refname)%(if)%(authorname)%(then) Author: %(authorname)%(end)" >actual &&
+       cat >expect <<-\EOF &&
+       refs/heads/master Author: A U Thor
+       refs/heads/side Author: A U Thor
+       refs/odd/spot Author: A U Thor
+       refs/tags/annotated-tag
+       refs/tags/doubly-annotated-tag
+       refs/tags/doubly-signed-tag
+       refs/tags/foo1.10 Author: A U Thor
+       refs/tags/foo1.3 Author: A U Thor
+       refs/tags/foo1.6 Author: A U Thor
+       refs/tags/four Author: A U Thor
+       refs/tags/one Author: A U Thor
+       refs/tags/signed-tag
+       refs/tags/three Author: A U Thor
+       refs/tags/two Author: A U Thor
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'check %(if)...%(then)...%(else)...%(end) atoms' '
+       git for-each-ref --format="%(if)%(authorname)%(then)%(authorname)%(else)No author%(end): %(refname)" >actual &&
+       cat >expect <<-\EOF &&
+       A U Thor: refs/heads/master
+       A U Thor: refs/heads/side
+       A U Thor: refs/odd/spot
+       No author: refs/tags/annotated-tag
+       No author: refs/tags/doubly-annotated-tag
+       No author: refs/tags/doubly-signed-tag
+       A U Thor: refs/tags/foo1.10
+       A U Thor: refs/tags/foo1.3
+       A U Thor: refs/tags/foo1.6
+       A U Thor: refs/tags/four
+       A U Thor: refs/tags/one
+       No author: refs/tags/signed-tag
+       A U Thor: refs/tags/three
+       A U Thor: refs/tags/two
+       EOF
+       test_cmp expect actual
+'
+test_expect_success 'ignore spaces in %(if) atom usage' '
+       git for-each-ref --format="%(refname:short): %(if)%(HEAD)%(then)Head ref%(else)Not Head ref%(end)" >actual &&
+       cat >expect <<-\EOF &&
+       master: Head ref
+       side: Not Head ref
+       odd/spot: Not Head ref
+       annotated-tag: Not Head ref
+       doubly-annotated-tag: Not Head ref
+       doubly-signed-tag: Not Head ref
+       foo1.10: Not Head ref
+       foo1.3: Not Head ref
+       foo1.6: Not Head ref
+       four: Not Head ref
+       one: Not Head ref
+       signed-tag: Not Head ref
+       three: Not Head ref
+       two: Not Head ref
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'check %(if:equals=<string>)' '
+       git for-each-ref --format="%(if:equals=master)%(refname:short)%(then)Found master%(else)Not master%(end)" refs/heads/ >actual &&
+       cat >expect <<-\EOF &&
+       Found master
+       Not master
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'check %(if:notequals=<string>)' '
+       git for-each-ref --format="%(if:notequals=master)%(refname:short)%(then)Not master%(else)Found master%(end)" refs/heads/ >actual &&
+       cat >expect <<-\EOF &&
+       Found master
+       Not master
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success '--merged is incompatible with --no-merged' '
+       test_must_fail git for-each-ref --merged HEAD --no-merged HEAD
+'
+
 test_done