2 . git-sh-setup || dir
"Not a git archive"
5 echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]
6 git bisect start reset bisect state and start bisection.
7 git bisect bad [<rev>] mark <rev> a known-bad revision.
8 git bisect good [<rev>...] mark <rev>... known-good revisions.
9 git bisect next find next bisection to test and check it out.
10 git bisect reset [<branch>] finish bisection search and go back to branch.
11 git bisect visualize show bisect status in gitk.'
16 test -d "$GIT_DIR/refs/bisect" ||
{
17 echo >&2 'You need to start by "git bisect start"'
20 echo >&2 -n 'Do you want me to do it for you [Y/n]? '
34 case "$#" in 0) ;; *) usage
;; esac
36 # Verify HEAD. If we were bisecting before this, reset to the
37 # top-of-line master first!
39 head=$
(readlink
$GIT_DIR/HEAD
) || die
"Bad HEAD - I need a symlink"
42 git checkout master ||
exit
47 die
"Bad HEAD - strange symlink"
52 # Get rid of any old bisect state
54 rm -f "$GIT_DIR/refs/heads/bisect"
55 rm -rf "$GIT_DIR/refs/bisect/"
56 mkdir
"$GIT_DIR/refs/bisect"
63 rev=$
(git-rev-parse
--verify HEAD
) ;;
65 rev=$
(git-rev-parse
--verify "$1") ;;
69 echo "$rev" > "$GIT_DIR/refs/bisect/bad"
76 0) revs
=$
(git-rev-parse
--verify HEAD
) ||
exit ;;
77 *) revs
=$
(git-rev-parse
--revs-only --no-flags "$@") &&
78 test '' != "$revs" || die
"Bad rev input: $@" ;;
82 rev=$
(git-rev-parse
--verify "$rev") ||
exit
83 echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
90 test -f "$GIT_DIR/refs/bisect/bad" &&
91 case "$(cd "$GIT_DIR" && echo refs/bisect/good-*)" in
92 refs
/bisect
/good-\
*) ;;
98 echo >&2 'You need to give me at least one good and one bad revisions.'
106 bisect_next_check
&& bisect_next
110 case "$#" in 0) ;; *) usage
;; esac
112 bisect_next_check fail
113 bad
=$
(git-rev-parse
--verify refs
/bisect
/bad
) &&
114 good
=$
(git-rev-parse
--sq --revs-only --not \
115 $
(cd "$GIT_DIR" && ls refs
/bisect
/good-
*)) &&
116 rev=$
(eval "git-rev-list --bisect $good $bad") ||
exit
117 if [ -z "$rev" ]; then
118 echo "$bad was both good and bad"
121 if [ "$rev" = "$bad" ]; then
122 echo "$rev is first bad commit"
123 git-diff-tree
--pretty $rev
126 nr
=$
(eval "git-rev-list $rev $good" |
wc -l) ||
exit
127 echo "Bisecting: $nr revisions left to test after this"
128 echo "$rev" > "$GIT_DIR/refs/heads/new-bisect"
129 git checkout new-bisect ||
exit
130 mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" &&
131 ln -sf refs
/heads
/bisect
"$GIT_DIR/HEAD"
135 bisect_next_check fail
136 gitk bisect
/bad
--not `cd "$GIT_DIR/refs" && echo bisect/good-*`
142 1) test -f "$GIT_DIR/refs/heads/$1" ||
{
143 echo >&2 "$1 does not seem to be a valid branch"
150 git checkout
"$branch" &&
151 rm -fr "$GIT_DIR/refs/bisect"
152 rm -f "$GIT_DIR/refs/reads/bisect"
169 # Not sure we want "next" at the UI level anymore.
172 bisect_visualize
"$@" ;;