3 USAGE
='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]'
4 LONG_USAGE
='git bisect help
5 print this long help message.
6 git bisect start [--term-{old,good}=<term> --term-{new,bad}=<term>]
7 [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
8 reset bisect state and start bisection.
9 git bisect (bad|new) [<rev>]
10 mark <rev> a known-bad revision/
11 a revision after change in a given property.
12 git bisect (good|old) [<rev>...]
13 mark <rev>... known-good revisions/
14 revisions before change in a given property.
15 git bisect terms [--term-good | --term-bad]
16 show the terms used for old and new commits (default: bad, good)
17 git bisect skip [(<rev>|<range>)...]
18 mark <rev>... untestable revisions.
20 find next bisection to test and check it out.
21 git bisect reset [<commit>]
22 finish bisection search and go back to commit.
23 git bisect (visualize|view)
24 show bisect status in gitk.
25 git bisect replay <logfile>
29 git bisect run <cmd>...
30 use <cmd>... to automatically bisect.
32 Please use "git help bisect" to get the full man page.'
37 _x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
38 _x40
="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
44 if git rev-parse
--verify -q BISECT_HEAD
> /dev
/null
53 test -s "$GIT_DIR/BISECT_START" ||
{
54 gettextln
"You need to start by \"git bisect start\"" >&2
57 # TRANSLATORS: Make sure to include [Y] and [n] in your
58 # translation. The program will only accept English input
60 gettext "Do you want me to do it for you [Y/n]? " >&2
74 git bisect--helper
--bisect-start $@ ||
exit
78 # In case of mistaken revs or checkout error, or signals received,
79 # "bisect_auto_next" below may exit or misbehave.
80 # We have to trap this to be able to clean up using
81 # "bisect_clean_state".
83 trap 'git bisect--helper --bisect-clean-state' 0
84 trap 'exit 255' 1 2 3 15
87 # Check if we can proceed to the next bisect state.
101 revs
=$
(git rev-list
"$arg") || die
"$(eval_gettext "Bad
rev input
: \
$arg")" ;;
103 revs
=$
(git rev-parse
--sq-quote "$arg") ;;
107 eval bisect_state
'skip' $all
113 git bisect--helper
--check-and-set-terms $state $TERM_GOOD $TERM_BAD ||
exit
117 die
"Please call 'bisect_state' with at least one argument." ;;
118 1,"$TERM_BAD"|
1,"$TERM_GOOD"|
1,skip
)
119 bisected_head
=$
(bisect_head
)
120 rev=$
(git rev-parse
--verify "$bisected_head") ||
121 die
"$(eval_gettext "Bad
rev input
: \
$bisected_head")"
122 git bisect--helper
--bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" ||
exit
123 git bisect--helper
--check-expected-revs "$rev" ;;
124 2,"$TERM_BAD"|
*,"$TERM_GOOD"|
*,skip
)
129 sha
=$
(git rev-parse
--verify "$rev^{commit}") ||
130 die
"$(eval_gettext "Bad
rev input
: \
$rev")"
131 hash_list
="$hash_list $sha"
133 for rev in $hash_list
135 git bisect--helper
--bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" ||
exit
137 git bisect--helper
--check-expected-revs $hash_list ;;
139 die
"$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.
")" ;;
147 git bisect--helper
--bisect-next-check $TERM_GOOD $TERM_BAD && bisect_next ||
:
151 case "$#" in 0) ;; *) usage
;; esac
153 git bisect--helper
--bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD||
exit
155 # Perform all bisection computation, display and checkout
156 git bisect--helper
--next-all $
(git rev-parse
--verify -q BISECT_HEAD
> /dev
/null
&& echo --no-checkout)
159 # Check if we should exit because bisection is finished
162 bad_rev
=$
(git show-ref
--hash --verify refs
/bisect
/$TERM_BAD)
163 bad_commit
=$
(git show-branch
$bad_rev)
164 echo "# first $TERM_BAD commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
168 echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG"
169 good_revs
=$
(git for-each-ref
--format="%(objectname)" "refs/bisect/$TERM_GOOD-*")
170 for skipped
in $
(git rev-list refs
/bisect
/$TERM_BAD --not $good_revs)
172 skipped_commit
=$
(git show-branch
$skipped)
173 echo "# possible first $TERM_BAD commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG"
178 # Check for an error in the bisection process
179 test $res -ne 0 && exit $res
185 git bisect--helper
--bisect-next-check $TERM_GOOD $TERM_BAD fail ||
exit
189 if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
190 type gitk
>/dev
/null
2>&1
199 -*) set git log
"$@" ;;
204 eval '"$@"' --bisect -- $
(cat "$GIT_DIR/BISECT_NAMES")
209 test "$#" -eq 1 || die
"$(gettext "No logfile given
")"
210 test -r "$file" || die
"$(eval_gettext "cannot
read \
$file for replaying
")"
211 git bisect--helper
--bisect-reset ||
exit
212 oIFS
="$IFS" IFS
="$IFS$(printf '\015')"
213 while read git bisect
command rev tail
215 test "$git $bisect" = "git bisect" ||
test "$git" = "git-bisect" ||
continue
216 if test "$git" = "git-bisect"
222 git bisect--helper
--check-and-set-terms "$command" "$TERM_GOOD" "$TERM_BAD" ||
exit
226 cmd
="bisect_start $rev $tail"
228 "$TERM_GOOD"|
"$TERM_BAD"|skip
)
229 git bisect--helper
--bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" ||
exit;;
231 git bisect--helper
--bisect-terms $rev ||
exit;;
233 die
"$(gettext "?? what are you talking about?
")" ;;
241 git bisect--helper
--bisect-next-check $TERM_GOOD $TERM_BAD fail ||
exit
243 test -n "$*" || die
"$(gettext "bisect run failed
: no
command provided.
")"
248 eval_gettextln
"running \$command"
252 # Check for really bad run error.
253 if [ $res -lt 0 -o $res -ge 128 ]
255 eval_gettextln
"bisect run failed:
256 exit code \$res from '\$command' is < 0 or >= 128" >&2
260 # Find current state depending on run success or failure.
261 # A special exit code of 125 means cannot test.
272 # We have to use a subshell because "bisect_state" can exit.
273 ( bisect_state
$state >"$GIT_DIR/BISECT_RUN" )
276 cat "$GIT_DIR/BISECT_RUN"
278 if sane_grep
"first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \
281 gettextln
"bisect run cannot continue any more" >&2
287 eval_gettextln
"bisect run failed:
288 'bisect_state \$state' exited with error code \$res" >&2
292 if sane_grep
"is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev
/null
294 gettextln
"bisect run success"
302 test -s "$GIT_DIR/BISECT_LOG" || die
"$(gettext "We are not bisecting.
")"
303 cat "$GIT_DIR/BISECT_LOG"
307 if test -s "$GIT_DIR/BISECT_TERMS"
312 } <"$GIT_DIR/BISECT_TERMS"
328 bad|good|new|old|
"$TERM_BAD"|
"$TERM_GOOD")
329 bisect_state
"$cmd" "$@" ;;
333 # Not sure we want "next" at the UI level anymore.
336 bisect_visualize
"$@" ;;
338 git bisect--helper
--bisect-reset "$@" ;;
340 bisect_replay
"$@" ;;
346 git bisect--helper
--bisect-terms "$@" ||
exit;;