3 test_description='branch --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 --contains=side' '
50 git branch --contains=side >actual &&
54 test_cmp expect actual
58 test_expect_success 'branch --contains with pattern implies --list' '
60 git branch --contains=master master >actual &&
64 test_cmp expect actual
68 test_expect_success 'side: branch --merged' '
70 git branch --merged >actual &&
75 test_cmp expect actual
79 test_expect_success 'branch --merged with pattern implies --list' '
81 git branch --merged=side master >actual &&
85 test_cmp expect actual
89 test_expect_success 'side: branch --no-merged' '
91 git branch --no-merged >actual &&
93 test_cmp expect actual
97 test_expect_success 'master: branch --merged' '
99 git checkout master &&
100 git branch --merged >actual &&
104 test_cmp expect actual
108 test_expect_success 'master: branch --no-merged' '
110 git branch --no-merged >actual &&
114 test_cmp expect actual
118 test_expect_success 'branch --no-merged with pattern implies --list' '
120 git branch --no-merged=master master >actual &&
122 test_cmp expect actual
126 test_expect_success 'implicit --list conflicts with modification options' '
128 test_must_fail git branch --contains=master -d &&
129 test_must_fail git branch --contains=master -m foo
133 test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
134 test_must_fail git branch --contains master^{tree} &&
135 blob=$(git hash-object -w --stdin <<-\EOF
139 test_must_fail git branch --contains $blob
142 # We want to set up a case where the walk for the tracking info
143 # of one branch crosses the tip of another branch (and make sure
144 # that the latter walk does not mess up our flag to see if it was
147 # Here "topic" tracks "master" with one extra commit, and "zzz" points to the
148 # same tip as master The name "zzz" must come alphabetically after "topic"
149 # as we process them in that order.
150 test_expect_success 'branch --merged with --verbose' '
151 git branch --track topic master &&
152 git branch zzz topic &&
153 git checkout topic &&
155 git branch --merged topic >actual &&
156 cat >expect <<-\EOF &&
161 test_cmp expect actual &&
162 git branch --verbose --merged topic >actual &&
163 cat >expect <<-\EOF &&
164 master c77a0a9 second on master
165 * topic 2c939f4 [ahead 1] foo
166 zzz c77a0a9 second on master
168 test_i18ncmp expect actual