Skip to content

Commit f3a186f

Browse files
chriscoolgitster
authored andcommitted
bisect: improve error message when branch checkout fails
In "git-bisect.sh" the "git checkout" command is only used to change the current branch, but it is used like this: git checkout "$branch" which will output the following misleading error message when it fails: error: pathspec 'foo' did not match any file(s) known to git. This patch change the way we use "git checkout" like this: git checkout "$branch" -- so that we will get the following error message: fatal: invalid reference: foo which is better. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0da43a6 commit f3a186f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-bisect.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ bisect_start() {
7777
then
7878
# Reset to the rev from where we started.
7979
start_head=$(cat "$GIT_DIR/BISECT_START")
80-
git checkout "$start_head" || exit
80+
git checkout "$start_head" -- || exit
8181
else
8282
# Get rev from where we start.
8383
case "$head" in
@@ -370,7 +370,7 @@ bisect_checkout() {
370370
_msg="$2"
371371
echo "Bisecting: $_msg"
372372
mark_expected_rev "$_rev"
373-
git checkout -q "$_rev" || exit
373+
git checkout -q "$_rev" -- || exit
374374
git show-branch "$_rev"
375375
}
376376

@@ -549,7 +549,7 @@ bisect_reset() {
549549
*)
550550
usage ;;
551551
esac
552-
git checkout "$branch" && bisect_clean_state
552+
git checkout "$branch" -- && bisect_clean_state
553553
}
554554

555555
bisect_clean_state() {

0 commit comments

Comments
 (0)