Merge branch 'sg/subtree-signed-commits' into pu
[git] / t / tcontains.sh
1 #!/bin/sh
2
3 test_description='Test "contains" argument behavior'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup ' '
8         git init . &&
9         echo "this is a test" >file &&
10         git add -A &&
11         git commit -am "tag test" &&
12         git tag "v1.0" &&
13         git tag "v1.1"
14 '
15
16 test_expect_success 'tag --contains <existent_tag>' '
17         git tag --contains "v1.0" >actual &&
18         grep "v1.0" actual &&
19         grep "v1.1" actual
20 '
21
22 test_expect_success 'tag --contains <inexistent_tag>' '
23         test_must_fail git tag --contains "notag" 2>actual &&
24         test_i18ngrep "error" actual
25 '
26
27 test_expect_success 'tag --no-contains <existent_tag>' '
28         git tag --no-contains "v1.1" >actual &&
29         test_line_count = 0 actual
30 '
31
32 test_expect_success 'tag --no-contains <inexistent_tag>' '
33         test_must_fail git tag --no-contains "notag" 2>actual &&
34         test_i18ngrep "error" actual
35 '
36
37 test_expect_success 'tag usage error' '
38         test_must_fail git tag --noopt 2>actual &&
39         test_i18ngrep "usage" actual
40 '
41
42 test_expect_success 'branch --contains <existent_commit>' '
43         git branch --contains "master" >actual &&
44         test_i18ngrep "master" actual
45 '
46
47 test_expect_success 'branch --contains <inexistent_commit>' '
48         test_must_fail git branch --no-contains "nocommit" 2>actual &&
49         test_i18ngrep "error" actual
50 '
51
52 test_expect_success 'branch --no-contains <existent_commit>' '
53         git branch --no-contains "master" >actual &&
54         test_line_count = 0 actual
55 '
56
57 test_expect_success 'branch --no-contains <inexistent_commit>' '
58         test_must_fail git branch --no-contains "nocommit" 2>actual &&
59         test_i18ngrep "error" actual
60 '
61
62 test_expect_success 'branch usage error' '
63         test_must_fail git branch --noopt 2>actual &&
64         test_i18ngrep "usage" actual
65 '
66
67 test_expect_success 'for-each-ref --contains <existent_object>' '
68         git for-each-ref --contains "master" >actual &&
69         test_line_count = 3 actual
70 '
71
72 test_expect_success 'for-each-ref --contains <inexistent_object>' '
73         test_must_fail git for-each-ref --no-contains "noobject" 2>actual &&
74         test_i18ngrep "error" actual
75 '
76
77 test_expect_success 'for-each-ref --no-contains <existent_object>' '
78         git for-each-ref --no-contains "master" >actual &&
79         test_line_count = 0 actual
80 '
81
82 test_expect_success 'for-each-ref --no-contains <inexistent_object>' '
83         test_must_fail git for-each-ref --no-contains "noobject" 2>actual &&
84         test_i18ngrep "error" actual
85 '
86
87 test_expect_success 'for-each-ref usage error' '
88         test_must_fail git for-each-ref --noopt 2>actual &&
89         test_i18ngrep "usage" actual
90 '
91
92 test_done