Skip to content

Commit

Permalink
bisect: error out when passing bad path parameters
Browse files Browse the repository at this point in the history
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 <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
chriscool authored and gitster committed Mar 1, 2010
1 parent 003c6ab commit 8f69f72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bisect.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,12 @@ int bisect_next_all(const char *prefix)
exit(1);
}

if (!all) {
fprintf(stderr, "No testable commit found.\n"
"Maybe you started with bad path parameters?\n");
exit(4);
}

bisect_rev = revs.commits->item->object.sha1;
memcpy(bisect_rev_hex, sha1_to_hex(bisect_rev), 41);

Expand Down
5 changes: 5 additions & 0 deletions t/t6030-bisect-porcelain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,11 @@ test_expect_success 'skipping away from skipped commit' '
test "$para3" = "$PARA_HASH3"
'

test_expect_success 'erroring out when using bad path parameters' '
test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt &&
grep "bad path parameters" error.txt
'

#
#
test_done

0 comments on commit 8f69f72

Please sign in to comment.