Skip to content

Commit 8f69f72

Browse files
chriscoolgitster
authored andcommitted
bisect: error out when passing bad path parameters
As reported by Mark Lodato, "git bisect", when it was started with path parameters that match no commit was kind of working without taking account of path parameters and was reporting something like: Bisecting: -1 revisions left to test after this (roughly 0 steps) It is more correct and safer to just error out in this case, before displaying the revisions left, so this patch does just that. Note that this bug is very old, it exists at least since v1.5.5. And it is possible to detect that case earlier in the bisect algorithm, but it is not clear that it would be an improvement to error out earlier, on the contrary it may change the behavior of "git rev-list --bisect-all" for example, which is currently correct. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 003c6ab commit 8f69f72

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

bisect.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,12 @@ int bisect_next_all(const char *prefix)
986986
exit(1);
987987
}
988988

989+
if (!all) {
990+
fprintf(stderr, "No testable commit found.\n"
991+
"Maybe you started with bad path parameters?\n");
992+
exit(4);
993+
}
994+
989995
bisect_rev = revs.commits->item->object.sha1;
990996
memcpy(bisect_rev_hex, sha1_to_hex(bisect_rev), 41);
991997

t/t6030-bisect-porcelain.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,11 @@ test_expect_success 'skipping away from skipped commit' '
567567
test "$para3" = "$PARA_HASH3"
568568
'
569569

570+
test_expect_success 'erroring out when using bad path parameters' '
571+
test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt &&
572+
grep "bad path parameters" error.txt
573+
'
574+
570575
#
571576
#
572577
test_done

0 commit comments

Comments
 (0)