diff options
author | Christian Couder <chriscool@tuxfamily.org> | 2008-05-23 01:28:57 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-05-22 22:45:03 -0700 |
commit | 634f246444e6a1675e351f31362e6a375dc44f70 (patch) | |
tree | 92602cb65cc9113cbf7f23b00c1b7c7038ffabc5 /git-bisect.sh | |
parent | ba963de859e76a63d447345eeb3e134116d02433 (diff) | |
download | git-634f246444e6a1675e351f31362e6a375dc44f70.tar.gz git-634f246444e6a1675e351f31362e6a375dc44f70.tar.xz |
bisect: use a detached HEAD to bisect
When "git bisect" was first written, it was not possible to
checkout a detached HEAD. The detached feature appeared latter.
That's why before this patch the "git bisect" process used a
"bisect" branch to checkout new revisions to be tested (and also
a "new-bisect" one to check if the checkouts could work).
This patch makes "git bisect" checkout revisions to be tested on
a detached HEAD. This simplifies the code a bit.
The tests to check that "git bisect" does not start if a
"bisect" or a "new-bisect" branch exists are removed as they
are not relevant any more.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-bisect.sh')
-rwxr-xr-x | git-bisect.sh | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/git-bisect.sh b/git-bisect.sh index 57168b0ae..4bcbaceb8 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -63,40 +63,40 @@ bisect_autostart() { bisect_start() { # - # Verify HEAD. If we were bisecting before this, reset to the - # top-of-line master first! + # Verify HEAD. # head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) || head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) || die "Bad HEAD - I need a HEAD" + # - # Check that we either already have BISECT_START, or that the - # branches bisect, new-bisect don't exist, to not override them. + # Check if we are bisecting. # - test -s "$GIT_DIR/BISECT_START" || - if git show-ref --verify -q refs/heads/bisect || - git show-ref --verify -q refs/heads/new-bisect; then - die 'The branches "bisect" and "new-bisect" must not exist.' - fi start_head='' - case "$head" in - refs/heads/bisect) + if test -s "$GIT_DIR/BISECT_START" + then + # Reset to the rev from where we started. start_head=$(cat "$GIT_DIR/BISECT_START") git checkout "$start_head" || exit - ;; - refs/heads/*|$_x40) - # This error message should only be triggered by cogito usage, - # and cogito users should understand it relates to cg-seek. - [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree" - start_head="${head#refs/heads/}" - ;; - *) - die "Bad HEAD - strange symbolic ref" - ;; - esac + else + # Get rev from where we start. + case "$head" in + refs/heads/*|$_x40) + # This error message should only be triggered by + # cogito usage, and cogito users should understand + # it relates to cg-seek. + [ -s "$GIT_DIR/head-name" ] && + die "won't bisect on seeked tree" + start_head="${head#refs/heads/}" + ;; + *) + die "Bad HEAD - strange symbolic ref" + ;; + esac + fi # - # Get rid of any old bisect state + # Get rid of any old bisect state. # bisect_clean_state @@ -118,7 +118,7 @@ bisect_start() { break ;; *) - rev=$(git rev-parse --verify "$arg^{commit}" 2>/dev/null) || { + rev=$(git rev-parse -q --verify "$arg^{commit}") || { test $has_double_dash -eq 1 && die "'$arg' does not appear to be a valid revision" break @@ -366,9 +366,7 @@ bisect_next() { exit_if_skipped_commits "$bisect_rev" echo "Bisecting: $bisect_nr revisions left to test after this" - git branch -D new-bisect 2> /dev/null - git checkout -q -b new-bisect "$bisect_rev" || exit - git branch -M new-bisect bisect + git checkout -q "$bisect_rev" || exit git show-branch "$bisect_rev" } @@ -415,7 +413,7 @@ bisect_reset() { bisect_clean_state() { # There may be some refs packed during bisection. - git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* refs/heads/bisect | + git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* | while read ref hash do git update-ref -d $ref $hash |