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

[PATCH] Add command `git bisect state` that checks if the current bisection process has reached the first bad commit.

From
Mattias Andrée <maandree@operamail.com>
Date
Aug 15, 2013, 22:35 UTC
Message-ID
<1376606112-1712-1-git-send-email-maandree@operamail.com>
This can be used for automated bisection without a check script.
Signed-off-by: Mattias Andrée <maandree@operamail.com>
---
 Documentation/git-bisect.txt | 13 +++++++++++++
 git-bisect.sh                | 11 ++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index f986c5c..ca8c09d 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -25,6 +25,7 @@ on the subcommand:
  git bisect visualize
  git bisect replay <logfile>
  git bisect log
+ git bisect state
  git bisect run <cmd>...
 
 This command uses 'git rev-list --bisect' to help drive the
@@ -104,6 +105,18 @@ For example, `git bisect reset HEAD` will leave you on the current
 bisection commit and avoid switching commits at all, while `git bisect
 reset bisect/bad` will check out the first bad revision.
 
+Bisect state
+~~~~~~~~~~~~~~~~
+
+To see the bisection process has finnished, issue the following command:
+
+------------
+$ git bisect state
+------------
+
+Exit successfully (i.e., with return code 0), if and only if the current
+bisection has reached the first bad or possible first bad commit.
+
 Bisect visualize
 ~~~~~~~~~~~~~~~~
 
diff --git a/git-bisect.sh b/git-bisect.sh
index 9f064b6..6ddda34 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
+USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run|state]'
 LONG_USAGE='git bisect help
 	print this long help message.
 git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
@@ -23,6 +23,8 @@ git bisect log
 	show bisect log.
 git bisect run <cmd>...
 	use <cmd>... to automatically bisect.
+git bisect state
+	check if the bisection is complete.
 
 Please use "git help bisect" to get the full man page.'
 
@@ -491,6 +493,11 @@ bisect_log () {
 	cat "$GIT_DIR/BISECT_LOG"
 }
 
+bisect_complete_state () {
+	cat "$GIT_DIR/BISECT_LOG" | tail -n 1 | grep -E '^# (possible |)first bad commit:' > /dev/null
+	exit $?
+}
+
 case "$#" in
 0)
 	usage ;;
@@ -519,6 +526,8 @@ case "$#" in
 		bisect_log ;;
 	run)
 		bisect_run "$@" ;;
+	state)
+		bisect_complete_state ;;
 	*)
 		usage ;;
 	esac
-- 
1.8.3.4
Next: Eric Sunshine
Message 1 of 4 in “Add command `git bisect state` that checks if the current bisection process has reached the first bad commit.”
  1. Add command `git bisect state` that checks if the current bisection process has reached the first bad commit.Mattias Andrée, Aug 15, 2013
  2. Eric SunshineAug 16, 2013
  3. Mattias AndréeAug 16, 2013
  4. Junio C HamanoAug 18, 2013

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.