git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] bisect: improve error msg of 'bisect reset' when original HEAD is deleted

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Oct 10, 2010, 21:48 UTC
Message-ID
<1286747338-8521-2-git-send-email-szeder@ira.uka.de>
In-Reply-To
<1286747338-8521-1-git-send-email-szeder@ira.uka.de>

'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>
---
 git-bisect.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index 3a4bf81..68fcff6 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -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() {
-- 
1.7.3.1.148.g2fffa
Previous: SZEDER GáborNext: SZEDER Gábor
Message 2 of 8 in “bisect: improve error message of 'bisect log' while not bisecting”
  1. 1/3 bisect: improve error message of 'bisect log' while not bisectingSZEDER Gábor, Oct 10, 2010
  2. 2/3 bisect: improve error msg of 'bisect reset' when original HEAD is deletedSZEDER Gábor, Oct 10, 2010
  3. 3/3 bisect: check for mandatory argument of 'bisect replay'SZEDER Gábor, Oct 10, 2010
  4. Christian CouderOct 12, 2010
  5. Christian CouderOct 12, 2010
  6. Junio C HamanoOct 13, 2010
  7. Christian CouderOct 14, 2010
  8. Ævar Arnfjörð BjarmasonOct 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.