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 <r@artagnon.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jan 18, 2022 at 13:46 UTC
ba5bb8152c463c9e59600e03913e99144b9673cc
1 file changed
+45
t/t6030-bisect-porcelain.sh
+45
@@ -278,6 +278,51 @@ test_expect_success '"git bisect run" with more complex "git bisect start"' '
278
git bisect reset
279
'
280
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
+
326
# $HASH1 is good, $HASH5 is bad, we skip $HASH3
327
# but $HASH4 is good,
328
# so we should find $HASH5 as the first bad commit