X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=git-bisect.sh;h=f8857747c4cc5cb3b958e925192e0040157ea911;hb=ea14e6c55427f50f78fe47187cd4edb9845943a1;hp=7a6521ec3c62b04fe6d4c3e80c418ccc02b4ec65;hpb=ada59fcd3230e661bc1110702a2fb4ef76371bc1;p=git.git diff --git a/git-bisect.sh b/git-bisect.sh index 7a6521ec3..f8857747c 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -26,6 +26,9 @@ OPTIONS_SPEC= . git-sh-setup 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" + sq() { @@PERL@@ -e ' for (@ARGV) { @@ -60,19 +63,22 @@ bisect_start() { # top-of-line master first! # head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) || - die "Bad HEAD - I need a symbolic ref" + head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) || + die "Bad HEAD - I need a HEAD" case "$head" in refs/heads/bisect) - if [ -s "$GIT_DIR/head-name" ]; then - branch=`cat "$GIT_DIR/head-name"` + if [ -s "$GIT_DIR/BISECT_START" ]; then + branch=`cat "$GIT_DIR/BISECT_START"` else branch=master fi git checkout $branch || exit ;; - refs/heads/*) + 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" - echo "${head#refs/heads/}" >"$GIT_DIR/head-name" + echo "${head#refs/heads/}" >"$GIT_DIR/BISECT_START" ;; *) die "Bad HEAD - strange symbolic ref" @@ -131,7 +137,7 @@ bisect_write() { *) die "Bad bisect_write argument: $state" ;; esac git update-ref "refs/bisect/$tag" "$rev" - echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG" test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } @@ -324,8 +330,23 @@ bisect_next() { bisect_visualize() { bisect_next_check fail + + if test $# = 0 + then + case "${DISPLAY+set}" in + '') set git log ;; + set) set gitk ;; + esac + else + case "$1" in + git*|tig) ;; + -*) set git log "$@" ;; + *) set git "$@" ;; + esac + fi + not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*") - eval gitk refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") + eval '"$@"' refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") } bisect_reset() { @@ -334,8 +355,8 @@ bisect_reset() { return } case "$#" in - 0) if [ -s "$GIT_DIR/head-name" ]; then - branch=`cat "$GIT_DIR/head-name"` + 0) if [ -s "$GIT_DIR/BISECT_START" ]; then + branch=`cat "$GIT_DIR/BISECT_START"` else branch=master fi ;; @@ -346,7 +367,9 @@ bisect_reset() { usage ;; esac if git checkout "$branch"; then + # Cleanup head-name if it got left by an old version of git-bisect rm -f "$GIT_DIR/head-name" + rm -f "$GIT_DIR/BISECT_START" bisect_clean_state fi } @@ -449,7 +472,7 @@ case "$#" in next) # Not sure we want "next" at the UI level anymore. bisect_next "$@" ;; - visualize) + visualize|view) bisect_visualize "$@" ;; reset) bisect_reset "$@" ;;