l10n: bg.po: Updated Bulgarian translation (5211t)
[git/debian.git] / t / t3201-branch-contains.sh
blob349a810cee11df36dda3c8ed4bbca3df58040001
1 #!/bin/sh
3 test_description='branch --contains <commit>, --no-contains <commit> --merged, and --no-merged'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 test_expect_success setup '
12 >file &&
13 git add file &&
14 test_tick &&
15 git commit -m initial &&
16 git branch -M main &&
17 git branch side &&
19 echo 1 >file &&
20 test_tick &&
21 git commit -a -m "second on main" &&
23 git checkout side &&
24 echo 1 >file &&
25 test_tick &&
26 git commit -a -m "second on side" &&
28 git merge main
32 test_expect_success 'branch --contains=main' '
34 git branch --contains=main >actual &&
36 echo " main" && echo "* side"
37 } >expect &&
38 test_cmp expect actual
42 test_expect_success 'branch --contains main' '
44 git branch --contains main >actual &&
46 echo " main" && echo "* side"
47 } >expect &&
48 test_cmp expect actual
52 test_expect_success 'branch --no-contains=main' '
54 git branch --no-contains=main >actual &&
55 test_must_be_empty actual
59 test_expect_success 'branch --no-contains main' '
61 git branch --no-contains main >actual &&
62 test_must_be_empty actual
66 test_expect_success 'branch --contains=side' '
68 git branch --contains=side >actual &&
70 echo "* side"
71 } >expect &&
72 test_cmp expect actual
76 test_expect_success 'branch --no-contains=side' '
78 git branch --no-contains=side >actual &&
80 echo " main"
81 } >expect &&
82 test_cmp expect actual
86 test_expect_success 'branch --contains with pattern implies --list' '
88 git branch --contains=main main >actual &&
90 echo " main"
91 } >expect &&
92 test_cmp expect actual
96 test_expect_success 'branch --no-contains with pattern implies --list' '
98 git branch --no-contains=main main >actual &&
99 test_must_be_empty actual
103 test_expect_success 'side: branch --merged' '
105 git branch --merged >actual &&
107 echo " main" &&
108 echo "* side"
109 } >expect &&
110 test_cmp expect actual
114 test_expect_success 'branch --merged with pattern implies --list' '
116 git branch --merged=side main >actual &&
118 echo " main"
119 } >expect &&
120 test_cmp expect actual
124 test_expect_success 'side: branch --no-merged' '
126 git branch --no-merged >actual &&
127 test_must_be_empty actual
131 test_expect_success 'main: branch --merged' '
133 git checkout main &&
134 git branch --merged >actual &&
136 echo "* main"
137 } >expect &&
138 test_cmp expect actual
142 test_expect_success 'main: 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=main main >actual &&
155 test_must_be_empty actual
159 test_expect_success 'implicit --list conflicts with modification options' '
161 test_must_fail git branch --contains=main -d &&
162 test_must_fail git branch --contains=main -m foo &&
163 test_must_fail git branch --no-contains=main -d &&
164 test_must_fail git branch --no-contains=main -m foo
168 test_expect_success 'Assert that --contains only works on commits, not trees & blobs' '
169 test_must_fail git branch --contains main^{tree} &&
170 blob=$(git hash-object -w --stdin <<-\EOF
171 Some blob
173 ) &&
174 test_must_fail git branch --contains $blob &&
175 test_must_fail git branch --no-contains $blob
178 test_expect_success 'multiple branch --contains' '
179 git checkout -b side2 main &&
180 >feature &&
181 git add feature &&
182 git commit -m "add feature" &&
183 git checkout -b next main &&
184 git merge side &&
185 git branch --contains side --contains side2 >actual &&
186 cat >expect <<-\EOF &&
187 * next
188 side
189 side2
191 test_cmp expect actual
194 test_expect_success 'multiple branch --merged' '
195 git branch --merged next --merged main >actual &&
196 cat >expect <<-\EOF &&
197 main
198 * next
199 side
201 test_cmp expect actual
204 test_expect_success 'multiple branch --no-contains' '
205 git branch --no-contains side --no-contains side2 >actual &&
206 cat >expect <<-\EOF &&
207 main
209 test_cmp expect actual
212 test_expect_success 'multiple branch --no-merged' '
213 git branch --no-merged next --no-merged main >actual &&
214 cat >expect <<-\EOF &&
215 side2
217 test_cmp expect actual
220 test_expect_success 'branch --contains combined with --no-contains' '
221 git checkout -b seen main &&
222 git merge side &&
223 git merge side2 &&
224 git branch --contains side --no-contains side2 >actual &&
225 cat >expect <<-\EOF &&
226 next
227 side
229 test_cmp expect actual
232 test_expect_success 'branch --merged combined with --no-merged' '
233 git branch --merged seen --no-merged next >actual &&
234 cat >expect <<-\EOF &&
235 * seen
236 side2
238 test_cmp expect actual
241 # We want to set up a case where the walk for the tracking info
242 # of one branch crosses the tip of another branch (and make sure
243 # that the latter walk does not mess up our flag to see if it was
244 # merged).
246 # Here "topic" tracks "main" with one extra commit, and "zzz" points to the
247 # same tip as main The name "zzz" must come alphabetically after "topic"
248 # as we process them in that order.
249 test_expect_success 'branch --merged with --verbose' '
250 git branch --track topic main &&
251 git branch zzz topic &&
252 git checkout topic &&
253 test_commit foo &&
254 git branch --merged topic >actual &&
255 cat >expect <<-\EOF &&
256 main
257 * topic
260 test_cmp expect actual &&
261 git branch --verbose --merged topic >actual &&
262 cat >expect <<-EOF &&
263 main $(git rev-parse --short main) second on main
264 * topic $(git rev-parse --short topic ) [ahead 1] foo
265 zzz $(git rev-parse --short zzz ) second on main
267 test_cmp expect actual
270 test_done