3 test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'
7 test_expect_success setup '
12 git commit -m initial &&
17 git commit -a -m "second on master" &&
22 git commit -a -m "second on side" &&
28 test_expect_success 'branch --contains=master' '
30 git branch --contains=master >actual &&
32 echo " master" && echo "* side"
34 test_cmp expect actual
38 test_expect_success 'branch --contains master' '
40 git branch --contains master >actual &&
42 echo " master" && echo "* side"
44 test_cmp expect actual
48 test_expect_success 'branch --no-contains=master' '
50 git branch --no-contains=master >actual &&
52 test_cmp expect actual
56 test_expect_success 'branch --no-contains master' '
58 git branch --no-contains master >actual &&
60 test_cmp expect actual
64 test_expect_success 'branch --contains=side' '
66 git branch --contains=side >actual &&
70 test_cmp expect actual
74 test_expect_success 'branch --no-contains=side' '
76 git branch --no-contains=side >actual &&
80 test_cmp expect actual
84 test_expect_success 'branch --contains with pattern implies --list' '
86 git branch --contains=master master >actual &&
90 test_cmp expect actual
94 test_expect_success 'branch --no-contains with pattern implies --list' '
96 git branch --no-contains=master master >actual &&
98 test_cmp expect actual
102 test_expect_success 'side: branch --merged' '
104 git branch --merged >actual &&
109 test_cmp expect actual
113 test_expect_success 'branch --merged with pattern implies --list' '
115 git branch --merged=side master >actual &&
119 test_cmp expect actual
123 test_expect_success 'side: branch --no-merged' '
125 git branch --no-merged >actual &&
127 test_cmp expect actual
131 test_expect_success 'master: branch --merged' '
133 git checkout master &&
134 git branch --merged >actual &&
138 test_cmp expect actual
142 test_expect_success 'master: branch --no-merged' '
144 git branch --no-merged >actual &&
148 test_cmp expect actual
152 test_expect_success 'branch --no-merged with pattern implies --list' '
154 git branch --no-merged=master master >actual &&
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
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
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 &&
192 git branch --merged topic >actual &&
193 cat >expect <<-\EOF &&
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 &&
215 test_cmp expect actual