Skip to content

Commit

Permalink
bisect: improve error msg of 'bisect reset' when original HEAD is del…
Browse files Browse the repository at this point in the history
…eted

'git bisect reset' (without the optional <commit> argument) returns to
the original HEAD from where the bisection was started.  However,
when, for whatever reason, the user deleted the original HEAD before
invoking 'git bisect reset', then all he gets is an error message from
'git checkout':

  fatal: invalid reference: somebranch

Let's try to be more helpful with an error message better describing
what went wrong and a suggestion about how to resolve the situation:

  Could not check out original HEAD 'somebranch'. Try 'git bisect reset <commit>'.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
SZEDER Gábor authored and Junio C Hamano committed Oct 13, 2010
1 parent 412ff73 commit 3bb8cf8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git-bisect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,12 @@ bisect_reset() {
*)
usage ;;
esac
git checkout "$branch" -- && bisect_clean_state
if git checkout "$branch" -- ; then
bisect_clean_state
else
die "Could not check out original HEAD '$branch'." \
"Try 'git bisect reset <commit>'."
fi
}

bisect_clean_state() {
Expand Down

0 comments on commit 3bb8cf8

Please sign in to comment.