Skip to content

Commit ba5bb81

Browse files
rscharfegitster
authored andcommitted
bisect: document run behavior with exit codes 126 and 127
Shells report non-executable and missing commands with exit codes 126 and 127, respectively. For historical reasons "git bisect run" interprets them as indicating a bad commit, though. Document the current behavior by adding basic tests that cover these cases. Reported-by: Ramkumar Ramachandra <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8efa2ac commit ba5bb81

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

t/t6030-bisect-porcelain.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,51 @@ test_expect_success '"git bisect run" with more complex "git bisect start"' '
278278
git bisect reset
279279
'
280280

281+
test_expect_success 'bisect run accepts exit code 126 as bad' '
282+
test_when_finished "git bisect reset" &&
283+
write_script test_script.sh <<-\EOF &&
284+
! grep Another hello || exit 126 >/dev/null
285+
EOF
286+
git bisect start &&
287+
git bisect good $HASH1 &&
288+
git bisect bad $HASH4 &&
289+
git bisect run ./test_script.sh >my_bisect_log.txt &&
290+
grep "$HASH3 is the first bad commit" my_bisect_log.txt
291+
'
292+
293+
test_expect_failure POSIXPERM 'bisect run fails with non-executable test script' '
294+
test_when_finished "git bisect reset" &&
295+
>not-executable.sh &&
296+
chmod -x not-executable.sh &&
297+
git bisect start &&
298+
git bisect good $HASH1 &&
299+
git bisect bad $HASH4 &&
300+
test_must_fail git bisect run ./not-executable.sh >my_bisect_log.txt &&
301+
! grep "is the first bad commit" my_bisect_log.txt
302+
'
303+
304+
test_expect_success 'bisect run accepts exit code 127 as bad' '
305+
test_when_finished "git bisect reset" &&
306+
write_script test_script.sh <<-\EOF &&
307+
! grep Another hello || exit 127 >/dev/null
308+
EOF
309+
git bisect start &&
310+
git bisect good $HASH1 &&
311+
git bisect bad $HASH4 &&
312+
git bisect run ./test_script.sh >my_bisect_log.txt &&
313+
grep "$HASH3 is the first bad commit" my_bisect_log.txt
314+
'
315+
316+
test_expect_failure 'bisect run fails with missing test script' '
317+
test_when_finished "git bisect reset" &&
318+
rm -f does-not-exist.sh &&
319+
git bisect start &&
320+
git bisect good $HASH1 &&
321+
git bisect bad $HASH4 &&
322+
test_must_fail git bisect run ./does-not-exist.sh >my_bisect_log.txt &&
323+
! grep "is the first bad commit" my_bisect_log.txt
324+
'
325+
281326
# $HASH1 is good, $HASH5 is bad, we skip $HASH3
282327
# but $HASH4 is good,
283328
# so we should find $HASH5 as the first bad commit

0 commit comments

Comments
 (0)