@matheusbsbs / matheus-bagliano / commits / 6b87ce231d
Fork 0

bisect reset: Allow resetting to any commit, not just a branch

‘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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Anders Kaseorg committed Oct 13, 2009 at 17:02 UTC 6b87ce231d14b3804974fba27576f1f2ba77cfb0
2 files changed +21 -10
Documentation/git-bisect.txt
+17 -6
@@ -20,7 +20,7 @@ on the subcommand:
20 git bisect bad [<rev>]
21 git bisect good [<rev>...]
22 git bisect skip [(<rev>|<range>)...]
23 - git bisect reset [<branch>]
23 + git bisect reset [<commit>]
24 git bisect visualize
25 git bisect replay <logfile>
26 git bisect log
@@ -81,16 +81,27 @@ will have been left with the first bad kernel revision in "refs/bisect/bad".
81 Bisect reset
82 ~~~~~~~~~~~~
83
84 -To return to the original head after a bisect session, issue the
85 -following command:
84 +After a bisect session, to clean up the bisection state and return to
85 +the original HEAD, issue the following command:
86
87 ------------------------------------------------
88 $ git bisect reset
89 ------------------------------------------------
90
91 -This resets the tree to the original branch instead of being on the
92 -bisection commit ("git bisect start" will also do that, as it resets
93 -the bisection state).
91 +By default, this will return your tree to the commit that was checked
92 +out before `git bisect start`. (A new `git bisect start` will also do
93 +that, as it cleans up the old bisection state.)
94 +
95 +With an optional argument, you can return to a different commit
96 +instead:
97 +
98 +------------------------------------------------
99 +$ git bisect reset <commit>
100 +------------------------------------------------
101 +
102 +For example, `git bisect reset HEAD` will leave you on the current
103 +bisection commit and avoid switching commits at all, while `git bisect
104 +reset bisect/bad` will check out the first bad revision.
105
106 Bisect visualize
107 ~~~~~~~~~~~~~~~~
git-bisect.sh
+4 -4
@@ -13,8 +13,8 @@ git bisect skip [(<rev>|<range>)...]
13 mark <rev>... untestable revisions.
14 git bisect next
15 find next bisection to test and check it out.
16 -git bisect reset [<branch>]
17 - finish bisection search and go back to branch.
16 +git bisect reset [<commit>]
17 + finish bisection search and go back to commit.
18 git bisect visualize
19 show bisect status in gitk.
20 git bisect replay <logfile>
@@ -311,8 +311,8 @@ bisect_reset() {
311 }
312 case "$#" in
313 0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
314 - 1) git show-ref --verify --quiet -- "refs/heads/$1" ||
315 - die "$1 does not seem to be a valid branch"
314 + 1) git rev-parse --quiet --verify "$1^{commit}" > /dev/null ||
315 + die "'$1' is not a valid commit"
316 branch="$1" ;;
317 *)
318 usage ;;