]> git.ipfire.org Git - thirdparty/git.git/blob - t/t6030-bisect-porcelain.sh
config: do not leak excludes_file
[thirdparty/git.git] / t / t6030-bisect-porcelain.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Christian Couder
4 #
5 test_description='Tests git bisect functionality'
6
7 exec </dev/null
8
9 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
10 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11
12 . ./test-lib.sh
13
14 add_line_into_file()
15 {
16 _line=$1
17 _file=$2
18
19 if [ -f "$_file" ]; then
20 echo "$_line" >> $_file || return $?
21 MSG="Add <$_line> into <$_file>."
22 else
23 echo "$_line" > $_file || return $?
24 git add $_file || return $?
25 MSG="Create file <$_file> with <$_line> inside."
26 fi
27
28 test_tick
29 git commit --quiet -m "$MSG" $_file
30 }
31
32 HASH1=
33 HASH2=
34 HASH3=
35 HASH4=
36
37 test_bisect_usage () {
38 local code="$1" &&
39 shift &&
40 cat >expect &&
41 test_expect_code $code "$@" >out 2>actual &&
42 test_must_be_empty out &&
43 test_cmp expect actual
44 }
45
46 test_expect_success 'bisect usage' "
47 test_bisect_usage 1 git bisect reset extra1 extra2 <<-\EOF &&
48 error: 'git bisect reset' requires either no argument or a commit
49 EOF
50 test_bisect_usage 1 git bisect terms extra1 extra2 <<-\EOF &&
51 error: 'git bisect terms' requires 0 or 1 argument
52 EOF
53 test_bisect_usage 1 git bisect next extra1 <<-\EOF &&
54 error: 'git bisect next' requires 0 arguments
55 EOF
56 test_bisect_usage 1 git bisect log extra1 <<-\EOF &&
57 error: We are not bisecting.
58 EOF
59 test_bisect_usage 1 git bisect replay <<-\EOF &&
60 error: no logfile given
61 EOF
62 test_bisect_usage 1 git bisect run <<-\EOF
63 error: 'git bisect run' failed: no command provided.
64 EOF
65 "
66
67 test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' '
68 add_line_into_file "1: Hello World" hello &&
69 HASH1=$(git rev-parse --verify HEAD) &&
70 add_line_into_file "2: A new day for git" hello &&
71 HASH2=$(git rev-parse --verify HEAD) &&
72 add_line_into_file "3: Another new day for git" hello &&
73 HASH3=$(git rev-parse --verify HEAD) &&
74 add_line_into_file "4: Ciao for now" hello &&
75 HASH4=$(git rev-parse --verify HEAD)
76 '
77
78 test_expect_success 'bisect starts with only one bad' '
79 git bisect reset &&
80 git bisect start &&
81 git bisect bad $HASH4 &&
82 git bisect next
83 '
84
85 test_expect_success 'bisect does not start with only one good' '
86 git bisect reset &&
87 git bisect start &&
88 git bisect good $HASH1 &&
89 test_must_fail git bisect next
90 '
91
92 test_expect_success 'bisect start with one bad and good' '
93 git bisect reset &&
94 git bisect start &&
95 git bisect good $HASH1 &&
96 git bisect bad $HASH4 &&
97 git bisect next
98 '
99
100 test_expect_success 'bisect fails if given any junk instead of revs' '
101 git bisect reset &&
102 test_must_fail git bisect start foo $HASH1 -- &&
103 test_must_fail git bisect start $HASH4 $HASH1 bar -- &&
104 test -z "$(git for-each-ref "refs/bisect/*")" &&
105 test -z "$(ls .git/BISECT_* 2>/dev/null)" &&
106 git bisect start &&
107 test_must_fail git bisect good foo $HASH1 &&
108 test_must_fail git bisect good $HASH1 bar &&
109 test_must_fail git bisect bad frotz &&
110 test_must_fail git bisect bad $HASH3 $HASH4 &&
111 test_must_fail git bisect skip bar $HASH3 &&
112 test_must_fail git bisect skip $HASH1 foo &&
113 test -z "$(git for-each-ref "refs/bisect/*")" &&
114 git bisect good $HASH1 &&
115 git bisect bad $HASH4
116 '
117
118 test_expect_success 'bisect start without -- takes unknown arg as pathspec' '
119 git bisect reset &&
120 git bisect start foo bar &&
121 grep foo ".git/BISECT_NAMES" &&
122 grep bar ".git/BISECT_NAMES"
123 '
124
125 test_expect_success 'bisect reset: back in the main branch' '
126 git bisect reset &&
127 echo "* main" > branch.expect &&
128 git branch > branch.output &&
129 cmp branch.expect branch.output
130 '
131
132 test_expect_success 'bisect reset: back in another branch' '
133 git checkout -b other &&
134 git bisect start &&
135 git bisect good $HASH1 &&
136 git bisect bad $HASH3 &&
137 git bisect reset &&
138 echo " main" > branch.expect &&
139 echo "* other" >> branch.expect &&
140 git branch > branch.output &&
141 cmp branch.expect branch.output
142 '
143
144 test_expect_success 'bisect reset when not bisecting' '
145 git bisect reset &&
146 git branch > branch.output &&
147 cmp branch.expect branch.output
148 '
149
150 test_expect_success 'bisect reset removes packed refs' '
151 git bisect reset &&
152 git bisect start &&
153 git bisect good $HASH1 &&
154 git bisect bad $HASH3 &&
155 git pack-refs --all --prune &&
156 git bisect next &&
157 git bisect reset &&
158 test -z "$(git for-each-ref "refs/bisect/*")" &&
159 test -z "$(git for-each-ref "refs/heads/bisect")"
160 '
161
162 test_expect_success 'bisect reset removes bisect state after --no-checkout' '
163 git bisect reset &&
164 git bisect start --no-checkout &&
165 git bisect good $HASH1 &&
166 git bisect bad $HASH3 &&
167 git bisect next &&
168 git bisect reset &&
169 test -z "$(git for-each-ref "refs/bisect/*")" &&
170 test -z "$(git for-each-ref "refs/heads/bisect")" &&
171 test -z "$(git for-each-ref "BISECT_HEAD")"
172 '
173
174 test_expect_success 'bisect start: back in good branch' '
175 git branch > branch.output &&
176 grep "* other" branch.output > /dev/null &&
177 git bisect start $HASH4 $HASH1 -- &&
178 git bisect good &&
179 git bisect start $HASH4 $HASH1 -- &&
180 git bisect bad &&
181 git bisect reset &&
182 git branch > branch.output &&
183 grep "* other" branch.output > /dev/null
184 '
185
186 test_expect_success 'bisect start: no ".git/BISECT_START" created if junk rev' '
187 git bisect reset &&
188 test_must_fail git bisect start $HASH4 foo -- &&
189 git branch > branch.output &&
190 grep "* other" branch.output > /dev/null &&
191 test_path_is_missing .git/BISECT_START
192 '
193
194 test_expect_success 'bisect start: existing ".git/BISECT_START" not modified if junk rev' '
195 git bisect start $HASH4 $HASH1 -- &&
196 git bisect good &&
197 cp .git/BISECT_START saved &&
198 test_must_fail git bisect start $HASH4 foo -- &&
199 git branch > branch.output &&
200 test_i18ngrep "* (no branch, bisect started on other)" branch.output > /dev/null &&
201 test_cmp saved .git/BISECT_START
202 '
203 test_expect_success 'bisect start: no ".git/BISECT_START" if mistaken rev' '
204 git bisect start $HASH4 $HASH1 -- &&
205 git bisect good &&
206 test_must_fail git bisect start $HASH1 $HASH4 -- &&
207 git branch > branch.output &&
208 grep "* other" branch.output > /dev/null &&
209 test_path_is_missing .git/BISECT_START
210 '
211
212 test_expect_success 'bisect start: no ".git/BISECT_START" if checkout error' '
213 echo "temp stuff" > hello &&
214 test_must_fail git bisect start $HASH4 $HASH1 -- &&
215 git branch &&
216 git branch > branch.output &&
217 grep "* other" branch.output > /dev/null &&
218 test_path_is_missing .git/BISECT_START &&
219 test -z "$(git for-each-ref "refs/bisect/*")" &&
220 git checkout HEAD hello
221 '
222
223 # $HASH1 is good, $HASH4 is bad, we skip $HASH3
224 # but $HASH2 is bad,
225 # so we should find $HASH2 as the first bad commit
226 test_expect_success 'bisect skip: successful result' '
227 test_when_finished git bisect reset &&
228 git bisect reset &&
229 git bisect start $HASH4 $HASH1 &&
230 git bisect skip &&
231 git bisect bad > my_bisect_log.txt &&
232 grep "$HASH2 is the first bad commit" my_bisect_log.txt
233 '
234
235 # $HASH1 is good, $HASH4 is bad, we skip $HASH3 and $HASH2
236 # so we should not be able to tell the first bad commit
237 # among $HASH2, $HASH3 and $HASH4
238 test_expect_success 'bisect skip: cannot tell between 3 commits' '
239 test_when_finished git bisect reset &&
240 git bisect start $HASH4 $HASH1 &&
241 git bisect skip &&
242 test_expect_code 2 git bisect skip >my_bisect_log.txt &&
243 grep "first bad commit could be any of" my_bisect_log.txt &&
244 ! grep $HASH1 my_bisect_log.txt &&
245 grep $HASH2 my_bisect_log.txt &&
246 grep $HASH3 my_bisect_log.txt &&
247 grep $HASH4 my_bisect_log.txt
248 '
249
250 # $HASH1 is good, $HASH4 is bad, we skip $HASH3
251 # but $HASH2 is good,
252 # so we should not be able to tell the first bad commit
253 # among $HASH3 and $HASH4
254 test_expect_success 'bisect skip: cannot tell between 2 commits' '
255 test_when_finished git bisect reset &&
256 git bisect start $HASH4 $HASH1 &&
257 git bisect skip &&
258 test_expect_code 2 git bisect good >my_bisect_log.txt &&
259 grep "first bad commit could be any of" my_bisect_log.txt &&
260 ! grep $HASH1 my_bisect_log.txt &&
261 ! grep $HASH2 my_bisect_log.txt &&
262 grep $HASH3 my_bisect_log.txt &&
263 grep $HASH4 my_bisect_log.txt
264 '
265
266 # $HASH1 is good, $HASH4 is both skipped and bad, we skip $HASH3
267 # and $HASH2 is good,
268 # so we should not be able to tell the first bad commit
269 # among $HASH3 and $HASH4
270 test_expect_success 'bisect skip: with commit both bad and skipped' '
271 test_when_finished git bisect reset &&
272 git bisect start &&
273 git bisect skip &&
274 git bisect bad &&
275 git bisect good $HASH1 &&
276 git bisect skip &&
277 test_expect_code 2 git bisect good >my_bisect_log.txt &&
278 grep "first bad commit could be any of" my_bisect_log.txt &&
279 ! grep $HASH1 my_bisect_log.txt &&
280 ! grep $HASH2 my_bisect_log.txt &&
281 grep $HASH3 my_bisect_log.txt &&
282 grep $HASH4 my_bisect_log.txt
283 '
284
285 test_bisect_run_args () {
286 test_when_finished "rm -f run.sh actual" &&
287 >actual &&
288 cat >expect.args &&
289 cat <&6 >expect.out &&
290 cat <&7 >expect.err &&
291 write_script run.sh <<-\EOF &&
292 while test $# != 0
293 do
294 echo "<$1>" &&
295 shift
296 done >actual.args
297 EOF
298
299 test_when_finished "git bisect reset" &&
300 git bisect start &&
301 git bisect good $HASH1 &&
302 git bisect bad $HASH4 &&
303 git bisect run ./run.sh $@ >actual.out.raw 2>actual.err &&
304 # Prune just the log output
305 sed -n \
306 -e '/^Author:/d' \
307 -e '/^Date:/d' \
308 -e '/^$/d' \
309 -e '/^commit /d' \
310 -e '/^ /d' \
311 -e 'p' \
312 <actual.out.raw >actual.out &&
313 test_cmp expect.out actual.out &&
314 test_cmp expect.err actual.err &&
315 test_cmp expect.args actual.args
316 }
317
318 test_expect_success 'git bisect run: args, stdout and stderr with no arguments' "
319 test_bisect_run_args <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
320 EOF_ARGS
321 running './run.sh'
322 $HASH4 is the first bad commit
323 bisect found first bad commit
324 EOF_OUT
325 EOF_ERR
326 "
327
328 test_expect_success 'git bisect run: args, stdout and stderr: "--" argument' "
329 test_bisect_run_args -- <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
330 <-->
331 EOF_ARGS
332 running './run.sh' '--'
333 $HASH4 is the first bad commit
334 bisect found first bad commit
335 EOF_OUT
336 EOF_ERR
337 "
338
339 test_expect_success 'git bisect run: args, stdout and stderr: "--log foo --no-log bar" arguments' "
340 test_bisect_run_args --log foo --no-log bar <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
341 <--log>
342 <foo>
343 <--no-log>
344 <bar>
345 EOF_ARGS
346 running './run.sh' '--log' 'foo' '--no-log' 'bar'
347 $HASH4 is the first bad commit
348 bisect found first bad commit
349 EOF_OUT
350 EOF_ERR
351 "
352
353 test_expect_success 'git bisect run: args, stdout and stderr: "--bisect-start" argument' "
354 test_bisect_run_args --bisect-start <<-'EOF_ARGS' 6<<-EOF_OUT 7<<-'EOF_ERR'
355 <--bisect-start>
356 EOF_ARGS
357 running './run.sh' '--bisect-start'
358 $HASH4 is the first bad commit
359 bisect found first bad commit
360 EOF_OUT
361 EOF_ERR
362 "
363
364 test_expect_success 'git bisect run: negative exit code' "
365 write_script fail.sh <<-'EOF' &&
366 exit 255
367 EOF
368 cat <<-'EOF' >expect &&
369 bisect run failed: exit code -1 from './fail.sh' is < 0 or >= 128
370 EOF
371 test_when_finished 'git bisect reset' &&
372 git bisect start &&
373 git bisect good $HASH1 &&
374 git bisect bad $HASH4 &&
375 ! git bisect run ./fail.sh 2>err &&
376 sed -En 's/.*(bisect.*code) (-?[0-9]+) (from.*)/\1 -1 \3/p' err >actual &&
377 test_cmp expect actual
378 "
379
380 test_expect_success 'git bisect run: unable to verify on good' "
381 write_script fail.sh <<-'EOF' &&
382 head=\$(git rev-parse --verify HEAD)
383 good=\$(git rev-parse --verify $HASH1)
384 if test "\$head" = "\$good"
385 then
386 exit 255
387 else
388 exit 127
389 fi
390 EOF
391 cat <<-'EOF' >expect &&
392 unable to verify './fail.sh' on good revision
393 EOF
394 test_when_finished 'git bisect reset' &&
395 git bisect start &&
396 git bisect good $HASH1 &&
397 git bisect bad $HASH4 &&
398 ! git bisect run ./fail.sh 2>err &&
399 sed -n 's/.*\(unable to verify.*\)/\1/p' err >actual &&
400 test_cmp expect actual
401 "
402
403 # We want to automatically find the commit that
404 # added "Another" into hello.
405 test_expect_success '"git bisect run" simple case' '
406 write_script test_script.sh <<-\EOF &&
407 ! grep Another hello >/dev/null
408 EOF
409 git bisect start &&
410 git bisect good $HASH1 &&
411 git bisect bad $HASH4 &&
412 git bisect run ./test_script.sh >my_bisect_log.txt &&
413 grep "$HASH3 is the first bad commit" my_bisect_log.txt &&
414 git bisect reset
415 '
416
417 # We want to make sure no arguments has been eaten
418 test_expect_success '"git bisect run" simple case' '
419 git bisect start &&
420 git bisect good $HASH1 &&
421 git bisect bad $HASH4 &&
422 git bisect run printf "%s %s\n" reset --bisect-skip >my_bisect_log.txt &&
423 grep -e "reset --bisect-skip" my_bisect_log.txt &&
424 git bisect reset
425 '
426
427 # We want to automatically find the commit that
428 # added "Ciao" into hello.
429 test_expect_success '"git bisect run" with more complex "git bisect start"' '
430 write_script test_script.sh <<-\EOF &&
431 ! grep Ciao hello >/dev/null
432 EOF
433 git bisect start $HASH4 $HASH1 &&
434 git bisect run ./test_script.sh >my_bisect_log.txt &&
435 grep "$HASH4 is the first bad commit" my_bisect_log.txt &&
436 git bisect reset
437 '
438
439 test_expect_success 'bisect run accepts exit code 126 as bad' '
440 test_when_finished "git bisect reset" &&
441 write_script test_script.sh <<-\EOF &&
442 ! grep Another hello || exit 126 >/dev/null
443 EOF
444 git bisect start &&
445 git bisect good $HASH1 &&
446 git bisect bad $HASH4 &&
447 git bisect run ./test_script.sh >my_bisect_log.txt &&
448 grep "$HASH3 is the first bad commit" my_bisect_log.txt
449 '
450
451 test_expect_success POSIXPERM 'bisect run fails with non-executable test script' '
452 test_when_finished "git bisect reset" &&
453 >not-executable.sh &&
454 chmod -x not-executable.sh &&
455 git bisect start &&
456 git bisect good $HASH1 &&
457 git bisect bad $HASH4 &&
458 test_must_fail git bisect run ./not-executable.sh >my_bisect_log.txt &&
459 ! grep "is the first bad commit" my_bisect_log.txt
460 '
461
462 test_expect_success 'bisect run accepts exit code 127 as bad' '
463 test_when_finished "git bisect reset" &&
464 write_script test_script.sh <<-\EOF &&
465 ! grep Another hello || exit 127 >/dev/null
466 EOF
467 git bisect start &&
468 git bisect good $HASH1 &&
469 git bisect bad $HASH4 &&
470 git bisect run ./test_script.sh >my_bisect_log.txt &&
471 grep "$HASH3 is the first bad commit" my_bisect_log.txt
472 '
473
474 test_expect_success 'bisect run fails with missing test script' '
475 test_when_finished "git bisect reset" &&
476 rm -f does-not-exist.sh &&
477 git bisect start &&
478 git bisect good $HASH1 &&
479 git bisect bad $HASH4 &&
480 test_must_fail git bisect run ./does-not-exist.sh >my_bisect_log.txt &&
481 ! grep "is the first bad commit" my_bisect_log.txt
482 '
483
484 # $HASH1 is good, $HASH5 is bad, we skip $HASH3
485 # but $HASH4 is good,
486 # so we should find $HASH5 as the first bad commit
487 HASH5=
488 test_expect_success 'bisect skip: add line and then a new test' '
489 add_line_into_file "5: Another new line." hello &&
490 HASH5=$(git rev-parse --verify HEAD) &&
491 git bisect start $HASH5 $HASH1 &&
492 git bisect skip &&
493 git bisect good > my_bisect_log.txt &&
494 grep "$HASH5 is the first bad commit" my_bisect_log.txt &&
495 git bisect log > log_to_replay.txt &&
496 git bisect reset
497 '
498
499 test_expect_success 'bisect skip and bisect replay' '
500 git bisect replay log_to_replay.txt > my_bisect_log.txt &&
501 grep "$HASH5 is the first bad commit" my_bisect_log.txt &&
502 git bisect reset
503 '
504
505 HASH6=
506 test_expect_success 'bisect run & skip: cannot tell between 2' '
507 add_line_into_file "6: Yet a line." hello &&
508 HASH6=$(git rev-parse --verify HEAD) &&
509 write_script test_script.sh <<-\EOF &&
510 sed -ne \$p hello | grep Ciao >/dev/null && exit 125
511 ! grep line hello >/dev/null
512 EOF
513 git bisect start $HASH6 $HASH1 &&
514 test_expect_code 2 git bisect run ./test_script.sh >my_bisect_log.txt &&
515 grep "first bad commit could be any of" my_bisect_log.txt &&
516 ! grep $HASH3 my_bisect_log.txt &&
517 ! grep $HASH6 my_bisect_log.txt &&
518 grep $HASH4 my_bisect_log.txt &&
519 grep $HASH5 my_bisect_log.txt
520 '
521
522 HASH7=
523 test_expect_success 'bisect run & skip: find first bad' '
524 git bisect reset &&
525 add_line_into_file "7: Should be the last line." hello &&
526 HASH7=$(git rev-parse --verify HEAD) &&
527 write_script test_script.sh <<-\EOF &&
528 sed -ne \$p hello | grep Ciao >/dev/null && exit 125
529 sed -ne \$p hello | grep day >/dev/null && exit 125
530 ! grep Yet hello >/dev/null
531 EOF
532 git bisect start $HASH7 $HASH1 &&
533 git bisect run ./test_script.sh >my_bisect_log.txt &&
534 grep "$HASH6 is the first bad commit" my_bisect_log.txt
535 '
536
537 test_expect_success 'bisect skip only one range' '
538 git bisect reset &&
539 git bisect start $HASH7 $HASH1 &&
540 git bisect skip $HASH1..$HASH5 &&
541 test "$HASH6" = "$(git rev-parse --verify HEAD)" &&
542 test_must_fail git bisect bad > my_bisect_log.txt &&
543 grep "first bad commit could be any of" my_bisect_log.txt
544 '
545
546 test_expect_success 'bisect skip many ranges' '
547 git bisect start $HASH7 $HASH1 &&
548 test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
549 git bisect skip $HASH2 $HASH2.. ..$HASH5 &&
550 test "$HASH6" = "$(git rev-parse --verify HEAD)" &&
551 test_must_fail git bisect bad > my_bisect_log.txt &&
552 grep "first bad commit could be any of" my_bisect_log.txt
553 '
554
555 test_expect_success 'bisect starting with a detached HEAD' '
556 git bisect reset &&
557 git checkout main^ &&
558 HEAD=$(git rev-parse --verify HEAD) &&
559 git bisect start &&
560 test $HEAD = $(cat .git/BISECT_START) &&
561 git bisect reset &&
562 test $HEAD = $(git rev-parse --verify HEAD)
563 '
564
565 test_expect_success 'bisect errors out if bad and good are mistaken' '
566 git bisect reset &&
567 test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error &&
568 test_i18ngrep "mistook good and bad" rev_list_error &&
569 git bisect reset
570 '
571
572 test_expect_success 'bisect does not create a "bisect" branch' '
573 git bisect reset &&
574 git bisect start $HASH7 $HASH1 &&
575 git branch bisect &&
576 rev_hash4=$(git rev-parse --verify HEAD) &&
577 test "$rev_hash4" = "$HASH4" &&
578 git branch -D bisect &&
579 git bisect good &&
580 git branch bisect &&
581 rev_hash6=$(git rev-parse --verify HEAD) &&
582 test "$rev_hash6" = "$HASH6" &&
583 git bisect good > my_bisect_log.txt &&
584 grep "$HASH7 is the first bad commit" my_bisect_log.txt &&
585 git bisect reset &&
586 rev_hash6=$(git rev-parse --verify bisect) &&
587 test "$rev_hash6" = "$HASH6" &&
588 git branch -D bisect
589 '
590
591 # This creates a "side" branch to test "siblings" cases.
592 #
593 # H1-H2-H3-H4-H5-H6-H7 <--other
594 # \
595 # S5-S6-S7 <--side
596 #
597 test_expect_success 'side branch creation' '
598 git bisect reset &&
599 git checkout -b side $HASH4 &&
600 add_line_into_file "5(side): first line on a side branch" hello2 &&
601 SIDE_HASH5=$(git rev-parse --verify HEAD) &&
602 add_line_into_file "6(side): second line on a side branch" hello2 &&
603 SIDE_HASH6=$(git rev-parse --verify HEAD) &&
604 add_line_into_file "7(side): third line on a side branch" hello2 &&
605 SIDE_HASH7=$(git rev-parse --verify HEAD)
606 '
607
608 test_expect_success 'good merge base when good and bad are siblings' '
609 git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt &&
610 test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
611 grep $HASH4 my_bisect_log.txt &&
612 git bisect good > my_bisect_log.txt &&
613 ! grep "merge base must be tested" my_bisect_log.txt &&
614 grep $HASH6 my_bisect_log.txt &&
615 git bisect reset
616 '
617 test_expect_success 'skipped merge base when good and bad are siblings' '
618 git bisect start "$SIDE_HASH7" "$HASH7" > my_bisect_log.txt &&
619 test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
620 grep $HASH4 my_bisect_log.txt &&
621 git bisect skip > my_bisect_log.txt 2>&1 &&
622 grep "warning" my_bisect_log.txt &&
623 grep $SIDE_HASH6 my_bisect_log.txt &&
624 git bisect reset
625 '
626
627 test_expect_success 'bad merge base when good and bad are siblings' '
628 git bisect start "$HASH7" HEAD > my_bisect_log.txt &&
629 test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
630 grep $HASH4 my_bisect_log.txt &&
631 test_must_fail git bisect bad > my_bisect_log.txt 2>&1 &&
632 test_i18ngrep "merge base $HASH4 is bad" my_bisect_log.txt &&
633 test_i18ngrep "fixed between $HASH4 and \[$SIDE_HASH7\]" my_bisect_log.txt &&
634 git bisect reset
635 '
636
637 # This creates a few more commits (A and B) to test "siblings" cases
638 # when a good and a bad rev have many merge bases.
639 #
640 # We should have the following:
641 #
642 # H1-H2-H3-H4-H5-H6-H7
643 # \ \ \
644 # S5-A \
645 # \ \
646 # S6-S7----B
647 #
648 # And there A and B have 2 merge bases (S5 and H5) that should be
649 # reported by "git merge-base --all A B".
650 #
651 test_expect_success 'many merge bases creation' '
652 git checkout "$SIDE_HASH5" &&
653 git merge -m "merge HASH5 and SIDE_HASH5" "$HASH5" &&
654 A_HASH=$(git rev-parse --verify HEAD) &&
655 git checkout side &&
656 git merge -m "merge HASH7 and SIDE_HASH7" "$HASH7" &&
657 B_HASH=$(git rev-parse --verify HEAD) &&
658 git merge-base --all "$A_HASH" "$B_HASH" > merge_bases.txt &&
659 test_line_count = 2 merge_bases.txt &&
660 grep "$HASH5" merge_bases.txt &&
661 grep "$SIDE_HASH5" merge_bases.txt
662 '
663
664 # We want to automatically find the merge that
665 # added "line" into hello.
666 test_expect_success '"git bisect run --first-parent" simple case' '
667 git rev-list --first-parent $B_HASH ^$HASH4 >first_parent_chain.txt &&
668 write_script test_script.sh <<-\EOF &&
669 grep $(git rev-parse HEAD) first_parent_chain.txt || exit -1
670 ! grep line hello >/dev/null
671 EOF
672 git bisect start --first-parent &&
673 test_path_is_file ".git/BISECT_FIRST_PARENT" &&
674 git bisect good $HASH4 &&
675 git bisect bad $B_HASH &&
676 git bisect run ./test_script.sh >my_bisect_log.txt &&
677 grep "$B_HASH is the first bad commit" my_bisect_log.txt &&
678 git bisect reset &&
679 test_path_is_missing .git/BISECT_FIRST_PARENT
680 '
681
682 test_expect_success 'good merge bases when good and bad are siblings' '
683 git bisect start "$B_HASH" "$A_HASH" > my_bisect_log.txt &&
684 test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
685 git bisect good > my_bisect_log2.txt &&
686 test_i18ngrep "merge base must be tested" my_bisect_log2.txt &&
687 {
688 {
689 grep "$SIDE_HASH5" my_bisect_log.txt &&
690 grep "$HASH5" my_bisect_log2.txt
691 } || {
692 grep "$SIDE_HASH5" my_bisect_log2.txt &&
693 grep "$HASH5" my_bisect_log.txt
694 }
695 } &&
696 git bisect reset
697 '
698
699 test_expect_success 'optimized merge base checks' '
700 git bisect start "$HASH7" "$SIDE_HASH7" > my_bisect_log.txt &&
701 test_i18ngrep "merge base must be tested" my_bisect_log.txt &&
702 grep "$HASH4" my_bisect_log.txt &&
703 git bisect good > my_bisect_log2.txt &&
704 test -f ".git/BISECT_ANCESTORS_OK" &&
705 test "$HASH6" = $(git rev-parse --verify HEAD) &&
706 git bisect bad &&
707 git bisect good "$A_HASH" > my_bisect_log4.txt &&
708 test_i18ngrep "merge base must be tested" my_bisect_log4.txt &&
709 test_path_is_missing ".git/BISECT_ANCESTORS_OK"
710 '
711
712 # This creates another side branch called "parallel" with some files
713 # in some directories, to test bisecting with paths.
714 #
715 # We should have the following:
716 #
717 # P1-P2-P3-P4-P5-P6-P7
718 # / / /
719 # H1-H2-H3-H4-H5-H6-H7
720 # \ \ \
721 # S5-A \
722 # \ \
723 # S6-S7----B
724 #
725 test_expect_success '"parallel" side branch creation' '
726 git bisect reset &&
727 git checkout -b parallel $HASH1 &&
728 mkdir dir1 dir2 &&
729 add_line_into_file "1(para): line 1 on parallel branch" dir1/file1 &&
730 PARA_HASH1=$(git rev-parse --verify HEAD) &&
731 add_line_into_file "2(para): line 2 on parallel branch" dir2/file2 &&
732 PARA_HASH2=$(git rev-parse --verify HEAD) &&
733 add_line_into_file "3(para): line 3 on parallel branch" dir2/file3 &&
734 PARA_HASH3=$(git rev-parse --verify HEAD) &&
735 git merge -m "merge HASH4 and PARA_HASH3" "$HASH4" &&
736 PARA_HASH4=$(git rev-parse --verify HEAD) &&
737 add_line_into_file "5(para): add line on parallel branch" dir1/file1 &&
738 PARA_HASH5=$(git rev-parse --verify HEAD) &&
739 add_line_into_file "6(para): add line on parallel branch" dir2/file2 &&
740 PARA_HASH6=$(git rev-parse --verify HEAD) &&
741 git merge -m "merge HASH7 and PARA_HASH6" "$HASH7" &&
742 PARA_HASH7=$(git rev-parse --verify HEAD)
743 '
744
745 test_expect_success 'restricting bisection on one dir' '
746 git bisect reset &&
747 git bisect start HEAD $HASH1 -- dir1 &&
748 para1=$(git rev-parse --verify HEAD) &&
749 test "$para1" = "$PARA_HASH1" &&
750 git bisect bad > my_bisect_log.txt &&
751 grep "$PARA_HASH1 is the first bad commit" my_bisect_log.txt
752 '
753
754 test_expect_success 'restricting bisection on one dir and a file' '
755 git bisect reset &&
756 git bisect start HEAD $HASH1 -- dir1 hello &&
757 para4=$(git rev-parse --verify HEAD) &&
758 test "$para4" = "$PARA_HASH4" &&
759 git bisect bad &&
760 hash3=$(git rev-parse --verify HEAD) &&
761 test "$hash3" = "$HASH3" &&
762 git bisect good &&
763 hash4=$(git rev-parse --verify HEAD) &&
764 test "$hash4" = "$HASH4" &&
765 git bisect good &&
766 para1=$(git rev-parse --verify HEAD) &&
767 test "$para1" = "$PARA_HASH1" &&
768 git bisect good > my_bisect_log.txt &&
769 grep "$PARA_HASH4 is the first bad commit" my_bisect_log.txt
770 '
771
772 test_expect_success 'skipping away from skipped commit' '
773 git bisect start $PARA_HASH7 $HASH1 &&
774 para4=$(git rev-parse --verify HEAD) &&
775 test "$para4" = "$PARA_HASH4" &&
776 git bisect skip &&
777 hash7=$(git rev-parse --verify HEAD) &&
778 test "$hash7" = "$HASH7" &&
779 git bisect skip &&
780 para3=$(git rev-parse --verify HEAD) &&
781 test "$para3" = "$PARA_HASH3"
782 '
783
784 test_expect_success 'erroring out when using bad path arguments' '
785 test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt &&
786 test_i18ngrep "bad path arguments" error.txt
787 '
788
789 test_expect_success 'test bisection on bare repo - --no-checkout specified' '
790 git clone --bare . bare.nocheckout &&
791 (
792 cd bare.nocheckout &&
793 git bisect start --no-checkout &&
794 git bisect good $HASH1 &&
795 git bisect bad $HASH4 &&
796 git bisect run eval \
797 "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
798 >../nocheckout.log
799 ) &&
800 grep "$HASH3 is the first bad commit" nocheckout.log
801 '
802
803
804 test_expect_success 'test bisection on bare repo - --no-checkout defaulted' '
805 git clone --bare . bare.defaulted &&
806 (
807 cd bare.defaulted &&
808 git bisect start &&
809 git bisect good $HASH1 &&
810 git bisect bad $HASH4 &&
811 git bisect run eval \
812 "test \$(git rev-list BISECT_HEAD ^$HASH2 --max-count=1 | wc -l) = 0" \
813 >../defaulted.log
814 ) &&
815 grep "$HASH3 is the first bad commit" defaulted.log
816 '
817
818 #
819 # This creates a broken branch which cannot be checked out because
820 # the tree created has been deleted.
821 #
822 # H1-H2-H3-H4-H5-H6-H7 <--other
823 # \
824 # S5-S6'-S7'-S8'-S9 <--broken
825 #
826 # Commits marked with ' have a missing tree.
827 #
828 test_expect_success 'broken branch creation' '
829 git bisect reset &&
830 git checkout -b broken $HASH4 &&
831 git tag BROKEN_HASH4 $HASH4 &&
832 add_line_into_file "5(broken): first line on a broken branch" hello2 &&
833 git tag BROKEN_HASH5 &&
834 mkdir missing &&
835 :> missing/MISSING &&
836 git add missing/MISSING &&
837 git commit -m "6(broken): Added file that will be deleted" &&
838 git tag BROKEN_HASH6 &&
839 deleted=$(git rev-parse --verify HEAD:missing) &&
840 add_line_into_file "7(broken): second line on a broken branch" hello2 &&
841 git tag BROKEN_HASH7 &&
842 add_line_into_file "8(broken): third line on a broken branch" hello2 &&
843 git tag BROKEN_HASH8 &&
844 git rm missing/MISSING &&
845 git commit -m "9(broken): Remove missing file" &&
846 git tag BROKEN_HASH9 &&
847 rm .git/objects/$(test_oid_to_path $deleted)
848 '
849
850 echo "" > expected.ok
851 cat > expected.missing-tree.default <<EOF
852 fatal: unable to read tree $deleted
853 EOF
854
855 test_expect_success 'bisect fails if tree is broken on start commit' '
856 git bisect reset &&
857 test_must_fail git bisect start BROKEN_HASH7 BROKEN_HASH4 2>error.txt &&
858 test_cmp expected.missing-tree.default error.txt
859 '
860
861 test_expect_success 'bisect fails if tree is broken on trial commit' '
862 git bisect reset &&
863 test_must_fail git bisect start BROKEN_HASH9 BROKEN_HASH4 2>error.txt &&
864 git reset --hard broken &&
865 git checkout broken &&
866 test_cmp expected.missing-tree.default error.txt
867 '
868
869 check_same()
870 {
871 echo "Checking $1 is the same as $2" &&
872 test_cmp_rev "$1" "$2"
873 }
874
875 test_expect_success 'bisect: --no-checkout - start commit bad' '
876 git bisect reset &&
877 git bisect start BROKEN_HASH7 BROKEN_HASH4 --no-checkout &&
878 check_same BROKEN_HASH6 BISECT_HEAD &&
879 git bisect reset
880 '
881
882 test_expect_success 'bisect: --no-checkout - trial commit bad' '
883 git bisect reset &&
884 git bisect start broken BROKEN_HASH4 --no-checkout &&
885 check_same BROKEN_HASH6 BISECT_HEAD &&
886 git bisect reset
887 '
888
889 test_expect_success 'bisect: --no-checkout - target before breakage' '
890 git bisect reset &&
891 git bisect start broken BROKEN_HASH4 --no-checkout &&
892 check_same BROKEN_HASH6 BISECT_HEAD &&
893 git bisect bad BISECT_HEAD &&
894 check_same BROKEN_HASH5 BISECT_HEAD &&
895 git bisect bad BISECT_HEAD &&
896 check_same BROKEN_HASH5 bisect/bad &&
897 git bisect reset
898 '
899
900 test_expect_success 'bisect: --no-checkout - target in breakage' '
901 git bisect reset &&
902 git bisect start broken BROKEN_HASH4 --no-checkout &&
903 check_same BROKEN_HASH6 BISECT_HEAD &&
904 git bisect bad BISECT_HEAD &&
905 check_same BROKEN_HASH5 BISECT_HEAD &&
906 test_must_fail git bisect good BISECT_HEAD &&
907 check_same BROKEN_HASH6 bisect/bad &&
908 git bisect reset
909 '
910
911 test_expect_success 'bisect: --no-checkout - target after breakage' '
912 git bisect reset &&
913 git bisect start broken BROKEN_HASH4 --no-checkout &&
914 check_same BROKEN_HASH6 BISECT_HEAD &&
915 git bisect good BISECT_HEAD &&
916 check_same BROKEN_HASH8 BISECT_HEAD &&
917 test_must_fail git bisect good BISECT_HEAD &&
918 check_same BROKEN_HASH9 bisect/bad &&
919 git bisect reset
920 '
921
922 test_expect_success 'bisect: demonstrate identification of damage boundary' "
923 git bisect reset &&
924 git checkout broken &&
925 git bisect start broken main --no-checkout &&
926 test_must_fail git bisect run \"\$SHELL_PATH\" -c '
927 GOOD=\$(git for-each-ref \"--format=%(objectname)\" refs/bisect/good-*) &&
928 git rev-list --objects BISECT_HEAD --not \$GOOD >tmp.\$\$ &&
929 git pack-objects --stdout >/dev/null < tmp.\$\$
930 rc=\$?
931 rm -f tmp.\$\$
932 test \$rc = 0' &&
933 check_same BROKEN_HASH6 bisect/bad &&
934 git bisect reset
935 "
936
937 cat > expected.bisect-log <<EOF
938 # bad: [$HASH4] Add <4: Ciao for now> into <hello>.
939 # good: [$HASH2] Add <2: A new day for git> into <hello>.
940 git bisect start '$HASH4' '$HASH2'
941 # good: [$HASH3] Add <3: Another new day for git> into <hello>.
942 git bisect good $HASH3
943 # first bad commit: [$HASH4] Add <4: Ciao for now> into <hello>.
944 EOF
945
946 test_expect_success 'bisect log: successful result' '
947 git bisect reset &&
948 git bisect start $HASH4 $HASH2 &&
949 git bisect good &&
950 git bisect log >bisect-log.txt &&
951 test_cmp expected.bisect-log bisect-log.txt &&
952 git bisect reset
953 '
954
955 cat > expected.bisect-skip-log <<EOF
956 # bad: [$HASH4] Add <4: Ciao for now> into <hello>.
957 # good: [$HASH2] Add <2: A new day for git> into <hello>.
958 git bisect start '$HASH4' '$HASH2'
959 # skip: [$HASH3] Add <3: Another new day for git> into <hello>.
960 git bisect skip $HASH3
961 # only skipped commits left to test
962 # possible first bad commit: [$HASH4] Add <4: Ciao for now> into <hello>.
963 # possible first bad commit: [$HASH3] Add <3: Another new day for git> into <hello>.
964 EOF
965
966 test_expect_success 'bisect log: only skip commits left' '
967 git bisect reset &&
968 git bisect start $HASH4 $HASH2 &&
969 test_must_fail git bisect skip &&
970 git bisect log >bisect-skip-log.txt &&
971 test_cmp expected.bisect-skip-log bisect-skip-log.txt &&
972 git bisect reset
973 '
974
975 test_expect_success '"git bisect bad HEAD" behaves as "git bisect bad"' '
976 git checkout parallel &&
977 git bisect start HEAD $HASH1 &&
978 git bisect good HEAD &&
979 git bisect bad HEAD &&
980 test "$HASH6" = $(git rev-parse --verify HEAD) &&
981 git bisect reset
982 '
983
984 test_expect_success 'bisect starts with only one new' '
985 git bisect reset &&
986 git bisect start &&
987 git bisect new $HASH4 &&
988 git bisect next
989 '
990
991 test_expect_success 'bisect does not start with only one old' '
992 git bisect reset &&
993 git bisect start &&
994 git bisect old $HASH1 &&
995 test_must_fail git bisect next
996 '
997
998 test_expect_success 'bisect start with one new and old' '
999 git bisect reset &&
1000 git bisect start &&
1001 git bisect old $HASH1 &&
1002 git bisect new $HASH4 &&
1003 git bisect new &&
1004 git bisect new >bisect_result &&
1005 grep "$HASH2 is the first new commit" bisect_result &&
1006 git bisect log >log_to_replay.txt &&
1007 git bisect reset
1008 '
1009
1010 test_expect_success 'bisect replay with old and new' '
1011 git bisect replay log_to_replay.txt >bisect_result &&
1012 grep "$HASH2 is the first new commit" bisect_result &&
1013 git bisect reset
1014 '
1015
1016 test_expect_success 'bisect replay with CRLF log' '
1017 append_cr <log_to_replay.txt >log_to_replay_crlf.txt &&
1018 git bisect replay log_to_replay_crlf.txt >bisect_result_crlf &&
1019 grep "$HASH2 is the first new commit" bisect_result_crlf &&
1020 git bisect reset
1021 '
1022
1023 test_expect_success 'bisect cannot mix old/new and good/bad' '
1024 git bisect start &&
1025 git bisect bad $HASH4 &&
1026 test_must_fail git bisect old $HASH1
1027 '
1028
1029 test_expect_success 'bisect terms needs 0 or 1 argument' '
1030 git bisect reset &&
1031 test_must_fail git bisect terms only-one &&
1032 test_must_fail git bisect terms 1 2 &&
1033 test_must_fail git bisect terms 2>actual &&
1034 echo "error: no terms defined" >expected &&
1035 test_cmp expected actual
1036 '
1037
1038 test_expect_success 'bisect terms shows good/bad after start' '
1039 git bisect reset &&
1040 git bisect start HEAD $HASH1 &&
1041 git bisect terms --term-good >actual &&
1042 echo good >expected &&
1043 test_cmp expected actual &&
1044 git bisect terms --term-bad >actual &&
1045 echo bad >expected &&
1046 test_cmp expected actual
1047 '
1048
1049 test_expect_success 'bisect start with one term1 and term2' '
1050 git bisect reset &&
1051 git bisect start --term-old term2 --term-new term1 &&
1052 git bisect term2 $HASH1 &&
1053 git bisect term1 $HASH4 &&
1054 git bisect term1 &&
1055 git bisect term1 >bisect_result &&
1056 grep "$HASH2 is the first term1 commit" bisect_result &&
1057 git bisect log >log_to_replay.txt &&
1058 git bisect reset
1059 '
1060
1061 test_expect_success 'bogus command does not start bisect' '
1062 git bisect reset &&
1063 test_must_fail git bisect --bisect-terms 1 2 2>out &&
1064 ! grep "You need to start" out &&
1065 test_must_fail git bisect --bisect-terms 2>out &&
1066 ! grep "You need to start" out &&
1067 grep "git bisect.*visualize" out &&
1068 git bisect reset
1069 '
1070
1071 test_expect_success 'bisect replay with term1 and term2' '
1072 git bisect replay log_to_replay.txt >bisect_result &&
1073 grep "$HASH2 is the first term1 commit" bisect_result &&
1074 git bisect reset
1075 '
1076
1077 test_expect_success 'bisect start term1 term2' '
1078 git bisect reset &&
1079 git bisect start --term-new term1 --term-old term2 $HASH4 $HASH1 &&
1080 git bisect term1 &&
1081 git bisect term1 >bisect_result &&
1082 grep "$HASH2 is the first term1 commit" bisect_result &&
1083 git bisect log >log_to_replay.txt &&
1084 git bisect reset
1085 '
1086
1087 test_expect_success 'bisect cannot mix terms' '
1088 git bisect reset &&
1089 git bisect start --term-good term1 --term-bad term2 $HASH4 $HASH1 &&
1090 test_must_fail git bisect a &&
1091 test_must_fail git bisect b &&
1092 test_must_fail git bisect bad &&
1093 test_must_fail git bisect good &&
1094 test_must_fail git bisect new &&
1095 test_must_fail git bisect old
1096 '
1097
1098 test_expect_success 'bisect terms rejects invalid terms' '
1099 git bisect reset &&
1100 test_must_fail git bisect start --term-good &&
1101 test_must_fail git bisect start --term-good invalid..term &&
1102 test_must_fail git bisect start --term-bad &&
1103 test_must_fail git bisect terms --term-bad invalid..term &&
1104 test_must_fail git bisect terms --term-good bad &&
1105 test_must_fail git bisect terms --term-good old &&
1106 test_must_fail git bisect terms --term-good skip &&
1107 test_must_fail git bisect terms --term-good reset &&
1108 test_path_is_missing .git/BISECT_TERMS
1109 '
1110
1111 test_expect_success 'bisect start --term-* does store terms' '
1112 git bisect reset &&
1113 git bisect start --term-bad=one --term-good=two &&
1114 git bisect terms >actual &&
1115 cat <<-EOF >expected &&
1116 Your current terms are two for the old state
1117 and one for the new state.
1118 EOF
1119 test_cmp expected actual &&
1120 git bisect terms --term-bad >actual &&
1121 echo one >expected &&
1122 test_cmp expected actual &&
1123 git bisect terms --term-good >actual &&
1124 echo two >expected &&
1125 test_cmp expected actual
1126 '
1127
1128 test_expect_success 'bisect start takes options and revs in any order' '
1129 git bisect reset &&
1130 git bisect start --term-good one $HASH4 \
1131 --term-good two --term-bad bad-term \
1132 $HASH1 --term-good three -- &&
1133 (git bisect terms --term-bad && git bisect terms --term-good) >actual &&
1134 printf "%s\n%s\n" bad-term three >expected &&
1135 test_cmp expected actual
1136 '
1137
1138 # Bisect is started with --term-new and --term-old arguments,
1139 # then skip. The HEAD should be changed.
1140 test_expect_success 'bisect skip works with --term*' '
1141 git bisect reset &&
1142 git bisect start --term-new=fixed --term-old=unfixed HEAD $HASH1 &&
1143 hash_skipped_from=$(git rev-parse --verify HEAD) &&
1144 git bisect skip &&
1145 hash_skipped_to=$(git rev-parse --verify HEAD) &&
1146 test "$hash_skipped_from" != "$hash_skipped_to"
1147 '
1148
1149 test_expect_success 'git bisect reset cleans bisection state properly' '
1150 git bisect reset &&
1151 git bisect start &&
1152 git bisect good $HASH1 &&
1153 git bisect bad $HASH4 &&
1154 git bisect reset &&
1155 test -z "$(git for-each-ref "refs/bisect/*")" &&
1156 test_path_is_missing ".git/BISECT_EXPECTED_REV" &&
1157 test_path_is_missing ".git/BISECT_ANCESTORS_OK" &&
1158 test_path_is_missing ".git/BISECT_LOG" &&
1159 test_path_is_missing ".git/BISECT_RUN" &&
1160 test_path_is_missing ".git/BISECT_TERMS" &&
1161 test_path_is_missing ".git/BISECT_HEAD" &&
1162 test_path_is_missing ".git/BISECT_START"
1163 '
1164
1165 test_expect_success 'bisect handles annotated tags' '
1166 test_commit commit-one &&
1167 git tag -m foo tag-one &&
1168 test_commit commit-two &&
1169 git tag -m foo tag-two &&
1170 git bisect start &&
1171 git bisect good tag-one &&
1172 git bisect bad tag-two >output &&
1173 bad=$(git rev-parse --verify tag-two^{commit}) &&
1174 grep "$bad is the first bad commit" output
1175 '
1176
1177 test_expect_success 'bisect run fails with exit code equals or greater than 128' '
1178 write_script test_script.sh <<-\EOF &&
1179 exit 128
1180 EOF
1181 test_must_fail git bisect run ./test_script.sh &&
1182 write_script test_script.sh <<-\EOF &&
1183 exit 255
1184 EOF
1185 test_must_fail git bisect run ./test_script.sh
1186 '
1187
1188 test_expect_success 'bisect visualize with a filename with dash and space' '
1189 echo "My test line" >>"./-hello 2" &&
1190 git add -- "./-hello 2" &&
1191 git commit --quiet -m "Add test line" -- "./-hello 2" &&
1192 git bisect visualize -p -- "-hello 2"
1193 '
1194
1195 test_expect_success 'bisect state output with multiple good commits' '
1196 git bisect reset &&
1197 git bisect start >output &&
1198 grep "waiting for both good and bad commits" output &&
1199 git bisect log >output &&
1200 grep "waiting for both good and bad commits" output &&
1201 git bisect good "$HASH1" >output &&
1202 grep "waiting for bad commit, 1 good commit known" output &&
1203 git bisect log >output &&
1204 grep "waiting for bad commit, 1 good commit known" output &&
1205 git bisect good "$HASH2" >output &&
1206 grep "waiting for bad commit, 2 good commits known" output &&
1207 git bisect log >output &&
1208 grep "waiting for bad commit, 2 good commits known" output
1209 '
1210
1211 test_expect_success 'bisect state output with bad commit' '
1212 git bisect reset &&
1213 git bisect start >output &&
1214 grep "waiting for both good and bad commits" output &&
1215 git bisect log >output &&
1216 grep "waiting for both good and bad commits" output &&
1217 git bisect bad "$HASH4" >output &&
1218 grep -F "waiting for good commit(s), bad commit known" output &&
1219 git bisect log >output &&
1220 grep -F "waiting for good commit(s), bad commit known" output
1221 '
1222
1223 test_expect_success 'verify correct error message' '
1224 git bisect reset &&
1225 git bisect start $HASH4 $HASH1 &&
1226 write_script test_script.sh <<-\EOF &&
1227 rm .git/BISECT*
1228 EOF
1229 test_must_fail git bisect run ./test_script.sh 2>error &&
1230 grep "git bisect good.*exited with error code" error
1231 '
1232
1233 test_done