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

[PATCH v2] bisect reset: Allow resetting to any commit, not just a branch

From
Anders Kaseorg <andersk@mit.edu>
Date
Oct 13, 2009, 15:22 UTC
Message-ID
<alpine.DEB.2.00.0910131116300.5105@dr-wily.mit.edu>
In-Reply-To
<7vaazw6uyi.fsf@alter.siamese.dyndns.org>

‘git bisect reset’ accepts an optional argument specifying a branch to check out after cleaning up the bisection state. This lets you specify an arbitrary commit.

In particular, this provides a way to clean the bisection state without moving HEAD: ‘git bisect reset HEAD’. This may be useful if you are not interested in the state before you began a bisect, especially if checking out the old commit would be expensive and invalidate most of your compiled tree.

Clarify the ‘git bisect reset’ documentation to explain this optional argument, which was previously mentioned only in the usage message.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
 Documentation/git-bisect.txt |   23 +++++++++++++++++------
 git-bisect.sh                |    7 +++----
 2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 63e7a42..d2ffae0 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -20,7 +20,7 @@ on the subcommand:
  git bisect bad [<rev>]
  git bisect good [<rev>...]
  git bisect skip [(<rev>|<range>)...]
- git bisect reset [<branch>]
+ git bisect reset [<commit>]
  git bisect visualize
  git bisect replay <logfile>
  git bisect log
@@ -81,16 +81,27 @@ will have been left with the first bad kernel revision in "refs/bisect/bad".
 Bisect reset
 ~~~~~~~~~~~~
 
-To return to the original head after a bisect session, issue the
-following command:
+After a bisect session, to clean up the bisection state and return to
+the original HEAD, issue the following command:
 
 ------------------------------------------------
 $ git bisect reset
 ------------------------------------------------
 
-This resets the tree to the original branch instead of being on the
-bisection commit ("git bisect start" will also do that, as it resets
-the bisection state).
+By default, this will return your tree to the commit that was checked
+out before `git bisect start`.  (A new `git bisect start` will also do
+that, as it cleans up the old bisection state.)
+
+With an optional argument, you can return to a different commit
+instead:
+
+------------------------------------------------
+$ git bisect reset <commit>
+------------------------------------------------
+
+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 visualize
 ~~~~~~~~~~~~~~~~
diff --git a/git-bisect.sh b/git-bisect.sh
index 6f6f039..0c56c26 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -13,8 +13,8 @@ git bisect skip [(<rev>|<range>)...]
         mark <rev>... untestable revisions.
 git bisect next
         find next bisection to test and check it out.
-git bisect reset [<branch>]
-        finish bisection search and go back to branch.
+git bisect reset [<commit>]
+        finish bisection search and go back to commit.
 git bisect visualize
         show bisect status in gitk.
 git bisect replay <logfile>
@@ -311,8 +311,7 @@ bisect_reset() {
 	}
 	case "$#" in
 	0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
-	1) git show-ref --verify --quiet -- "refs/heads/$1" ||
-	       die "$1 does not seem to be a valid branch"
+	1) git rev-parse --verify "$1^{commit}" || exit
 	   branch="$1" ;;
 	*)
 	    usage ;;
-- 
1.6.5
Previous: Anders KaseorgNext: Christian Couder
Message 8 of 18 in “bisect reset: Allow resetting to any commit, not just a branch”
  1. bisect reset: Allow resetting to any commit, not just a branchAnders Kaseorg, Oct 12, 2009
  2. Junio C HamanoOct 12, 2009
  3. Anders KaseorgOct 12, 2009
  4. Junio C HamanoOct 12, 2009
  5. Johannes SixtOct 13, 2009
  6. Junio C HamanoOct 13, 2009
  7. Anders KaseorgOct 13, 2009
  8. bisect reset: Allow resetting to any commit, not just a branchAnders Kaseorg, Oct 13, 2009
  9. Christian CouderOct 13, 2009
  10. Anders KaseorgOct 13, 2009
  11. Christian CouderOct 13, 2009
  12. bisect reset: Allow resetting to any commit, not just a branchAnders Kaseorg, Oct 13, 2009
  13. Junio C HamanoOct 14, 2009
  14. Johannes SixtOct 13, 2009
  15. Junio C HamanoOct 13, 2009
  16. Johannes SixtOct 13, 2009
  17. Junio C HamanoOct 13, 2009
  18. Anders KaseorgOct 13, 2009

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.