t/Makefile: introduce TEST_SHELL_PATH
[alt-git.git] / t / t3201-branch-contains.sh
blob0ef1b6fdcc420d6fac2cbe0abd5f1ec6ebec90c6
1 #!/bin/sh
3 test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'
5 . ./test-lib.sh
7 test_expect_success setup '
9 >file &&
10 git add file &&
11 test_tick &&
12 git commit -m initial &&
13 git branch side &&
15 echo 1 >file &&
16 test_tick &&
17 git commit -a -m "second on master" &&
19 git checkout side &&
20 echo 1 >file &&
21 test_tick &&
22 git commit -a -m "second on side" &&
24 git merge master
28 test_expect_success 'branch --contains=master' '
30 git branch --contains=master >actual &&
32 echo " master" && echo "* side"
33 } >expect &&
34 test_cmp expect actual
38 test_expect_success 'branch --contains master' '
40 git branch --contains master >actual &&
42 echo " master" && echo "* side"
43 } >expect &&
44 test_cmp expect actual
48 test_expect_success 'branch --no-contains=master' '
50 git branch --no-contains=master >actual &&
51 >expect &&
52 test_cmp expect actual
56 test_expect_success 'branch --no-contains master' '
58 git branch --no-contains master >actual &&
59 >expect &&
60 test_cmp expect actual
64 test_expect_success 'branch --contains=side' '
66 git branch --contains=side >actual &&
68 echo "* side"
69 } >expect &&
70 test_cmp expect actual
74 test_expect_success 'branch --no-contains=side' '
76 git branch --no-contains=side >actual &&
78 echo " master"
79 } >expect &&
80 test_cmp expect actual
84 test_expect_success 'branch --contains with pattern implies --list' '
86 git branch --contains=master master >actual &&
88 echo " master"
89 } >expect &&
90 test_cmp expect actual
94 test_expect_success 'branch --no-contains with pattern implies --list' '
96 git branch --no-contains=master master >actual &&
97 >expect &&
98 test_cmp expect actual
102 test_expect_success 'side: branch --merged' '
104 git branch --merged >actual &&
106 echo " master" &&
107 echo "* side"
108 } >expect &&
109 test_cmp expect actual
113 test_expect_success 'branch --merged with pattern implies --list' '
115 git branch --merged=side master >actual &&
117 echo " master"
118 } >expect &&
119 test_cmp expect actual
123 test_expect_success 'side: branch --no-merged' '
125 git branch --no-merged >actual &&
126 >expect &&
127 test_cmp expect actual
131 test_expect_success 'master: branch --merged' '
133 git checkout master &&
134 git branch --merged >actual &&
136 echo "* master"
137 } >expect &&
138 test_cmp expect actual
142 test_expect_success 'master: branch --no-merged' '
144 git branch --no-merged >actual &&
146 echo " side"
147 } >expect &&
148 test_cmp expect actual
152 test_expect_success 'branch --no-merged with pattern implies --list' '
154 git branch --no-merged=master master >actual &&
155 >expect &&
156 test_cmp expect actual
160 test_expect_success 'implicit --list conflicts with modification options' '
162 test_must_fail git branch --contains=master -d &&
163 test_must_fail git branch --contains=master -m foo &&
164 test_must_fail git branch --no-contains=master -d &&
165 test_must_fail git branch --no-contains=master -m foo
169 test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
170 test_must_fail git branch --contains master^{tree} &&
171 blob=$(git hash-object -w --stdin <<-\EOF
172 Some blob
174 ) &&
175 test_must_fail git branch --contains $blob &&
176 test_must_fail git branch --no-contains $blob
179 # We want to set up a case where the walk for the tracking info
180 # of one branch crosses the tip of another branch (and make sure
181 # that the latter walk does not mess up our flag to see if it was
182 # merged).
184 # Here "topic" tracks "master" with one extra commit, and "zzz" points to the
185 # same tip as master The name "zzz" must come alphabetically after "topic"
186 # as we process them in that order.
187 test_expect_success 'branch --merged with --verbose' '
188 git branch --track topic master &&
189 git branch zzz topic &&
190 git checkout topic &&
191 test_commit foo &&
192 git branch --merged topic >actual &&
193 cat >expect <<-\EOF &&
194 master
195 * topic
198 test_cmp expect actual &&
199 git branch --verbose --merged topic >actual &&
200 cat >expect <<-\EOF &&
201 master c77a0a9 second on master
202 * topic 2c939f4 [ahead 1] foo
203 zzz c77a0a9 second on master
205 test_i18ncmp expect actual
208 test_expect_success 'branch --contains combined with --no-contains' '
209 git branch --contains zzz --no-contains topic >actual &&
210 cat >expect <<-\EOF &&
211 master
212 side
215 test_cmp expect actual
219 test_done