Code

git-remote-mediawiki: trivial fixes
[git.git] / git-bisect.sh
index 1f3c46da83b61b3b8a7fce5084206d32596604f0..e0ca3fb853083d0ebdfe11e5eb3fead4723248ad 100755 (executable)
@@ -29,7 +29,6 @@ Please use "git help bisect" to get the full man page.'
 OPTIONS_SPEC=
 . git-sh-setup
 . git-sh-i18n
-require_work_tree
 
 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
@@ -79,7 +78,12 @@ bisect_start() {
        orig_args=$(git rev-parse --sq-quote "$@")
        bad_seen=0
        eval=''
-       mode=''
+       if test "z$(git rev-parse --is-bare-repository)" != zfalse
+       then
+               mode=--no-checkout
+       else
+               mode=''
+       fi
        while [ $# -gt 0 ]; do
                arg="$1"
                case "$arg" in
@@ -94,9 +98,9 @@ bisect_start() {
                        die "$(eval_gettext "unrecognised option: '\$arg'")" ;;
                *)
                        rev=$(git rev-parse -q --verify "$arg^{commit}") || {
-                           test $has_double_dash -eq 1 &&
-                       die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
-                           break
+                               test $has_double_dash -eq 1 &&
+                               die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
+                               break
                        }
                        case $bad_seen in
                        0) state='bad' ; bad_seen=1 ;;
@@ -125,7 +129,7 @@ bisect_start() {
                start_head=$(cat "$GIT_DIR/BISECT_START")
                if test "z$mode" != "z--no-checkout"
                then
-                   git checkout "$start_head" --
+                       git checkout "$start_head" --
                fi
        else
                # Get rev from where we start.
@@ -332,7 +336,7 @@ bisect_visualize() {
        if test $# = 0
        then
                if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
-                  type gitk >/dev/null 2>&1
+                       type gitk >/dev/null 2>&1
                then
                        set gitk
                else
@@ -364,13 +368,11 @@ bisect_reset() {
        *)
                usage ;;
        esac
-       if ! test -f "$GIT_DIR/BISECT_HEAD"
+
+       if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout "$branch" --
        then
-               if ! git checkout "$branch" --
-               then
-                       die "$(eval_gettext "Could not check out original HEAD '\$branch'.
+               die "$(eval_gettext "Could not check out original HEAD '\$branch'.
 Try 'git bisect reset <commit>'.")"
-               fi
        fi
        bisect_clean_state
 }