Skip to content

Commit 3bb8cf8

Browse files
szedergitster
authored andcommitted
bisect: improve error msg of 'bisect reset' when original HEAD is deleted
'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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 412ff73 commit 3bb8cf8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

git-bisect.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ bisect_reset() {
316316
*)
317317
usage ;;
318318
esac
319-
git checkout "$branch" -- && bisect_clean_state
319+
if git checkout "$branch" -- ; then
320+
bisect_clean_state
321+
else
322+
die "Could not check out original HEAD '$branch'." \
323+
"Try 'git bisect reset <commit>'."
324+
fi
320325
}
321326

322327
bisect_clean_state() {

0 commit comments

Comments
 (0)