]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6302-for-each-ref-filter.sh
ref-filter: introduce match_atom_name()
[thirdparty/git.git] / t / t6302-for-each-ref-filter.sh
CommitLineData
af83bafa
KN
1#!/bin/sh
2
3test_description='test for-each-refs usage of ref-filter APIs'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-gpg.sh
7
8if ! test_have_prereq GPG
9then
10 skip_all="skipping for-each-ref tests, GPG not available"
11 test_done
12fi
13
14test_expect_success 'setup some history and refs' '
15 test_commit one &&
16 test_commit two &&
17 test_commit three &&
18 git checkout -b side &&
19 test_commit four &&
20 git tag -s -m "A signed tag message" signed-tag &&
21 git tag -s -m "Annonated doubly" double-tag signed-tag &&
22 git checkout master &&
23 git update-ref refs/odd/spot master
24'
25
d325406e
KN
26test_expect_success 'filtering with --points-at' '
27 cat >expect <<-\EOF &&
28 refs/heads/master
29 refs/odd/spot
30 refs/tags/three
31 EOF
32 git for-each-ref --format="%(refname)" --points-at=master >actual &&
33 test_cmp expect actual
34'
35
36test_expect_success 'check signed tags with --points-at' '
37 sed -e "s/Z$//" >expect <<-\EOF &&
38 refs/heads/side Z
39 refs/tags/four Z
40 refs/tags/signed-tag four
41 EOF
42 git for-each-ref --format="%(refname) %(*subject)" --points-at=side >actual &&
43 test_cmp expect actual
44'
45
7c328348
KN
46test_expect_success 'filtering with --merged' '
47 cat >expect <<-\EOF &&
48 refs/heads/master
49 refs/odd/spot
50 refs/tags/one
51 refs/tags/three
52 refs/tags/two
53 EOF
54 git for-each-ref --format="%(refname)" --merged=master >actual &&
55 test_cmp expect actual
56'
57
58test_expect_success 'filtering with --no-merged' '
59 cat >expect <<-\EOF &&
60 refs/heads/side
61 refs/tags/double-tag
62 refs/tags/four
63 refs/tags/signed-tag
64 EOF
65 git for-each-ref --format="%(refname)" --no-merged=master >actual &&
66 test_cmp expect actual
67'
68
4a71109a
KN
69test_expect_success 'filtering with --contains' '
70 cat >expect <<-\EOF &&
71 refs/heads/master
72 refs/heads/side
73 refs/odd/spot
74 refs/tags/double-tag
75 refs/tags/four
76 refs/tags/signed-tag
77 refs/tags/three
78 refs/tags/two
79 EOF
80 git for-each-ref --format="%(refname)" --contains=two >actual &&
81 test_cmp expect actual
82'
83
40a7551d
KN
84test_expect_success '%(color) must fail' '
85 test_must_fail git for-each-ref --format="%(color)%(refname)"
86'
87
af83bafa 88test_done