summaryrefslogtreecommitdiff
path: root/git-bisect.sh
diff options
context:
space:
mode:
authorPranit Bauva <pranit.bauva@gmail.com>2019-01-02 15:38:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-02 18:23:02 (GMT)
commit129a6cf344c4b352433f5a24de02a62783f6c6df (patch)
treee24821ed51fd52a71ed5a21d699761b5915ff3f8 /git-bisect.sh
parent4fbdbd5bfff874330115f8d7556cf7c9f7f138c9 (diff)
downloadgit-129a6cf344c4b352433f5a24de02a62783f6c6df.zip
git-129a6cf344c4b352433f5a24de02a62783f6c6df.tar.gz
git-129a6cf344c4b352433f5a24de02a62783f6c6df.tar.bz2
bisect--helper: `bisect_next_check` shell function in C
Reimplement `bisect_next_check` shell function in C and add `bisect-next-check` subcommand to `git bisect--helper` to call it from git-bisect.sh . `bisect_voc` shell function is no longer useful now and is replaced by using a char *[] of "new|bad" and "good|old" values. Using `--bisect-next-check` is a temporary measure to port shell function to C so as to use the existing test suite. As more functions are ported, this subcommand will be retired but its implementation will be called by some other methods. Helped-by: Stephan Beyer <s-beyer@gmx.net> Mentored-by: Lars Schneider <larsxschneider@gmail.com> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-bisect.sh')
-rwxr-xr-xgit-bisect.sh60
1 files changed, 4 insertions, 56 deletions
diff --git a/git-bisect.sh b/git-bisect.sh
index 9e993a8..5ef3e25 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -271,59 +271,14 @@ bisect_state() {
bisect_auto_next
}
-bisect_next_check() {
- missing_good= missing_bad=
- git show-ref -q --verify refs/bisect/$TERM_BAD || missing_bad=t
- test -n "$(git for-each-ref "refs/bisect/$TERM_GOOD-*")" || missing_good=t
-
- case "$missing_good,$missing_bad,$1" in
- ,,*)
- : have both $TERM_GOOD and $TERM_BAD - ok
- ;;
- *,)
- # do not have both but not asked to fail - just report.
- false
- ;;
- t,,"$TERM_GOOD")
- # have bad (or new) but not good (or old). we could bisect although
- # this is less optimum.
- eval_gettextln "Warning: bisecting only with a \$TERM_BAD commit." >&2
- if test -t 0
- then
- # TRANSLATORS: Make sure to include [Y] and [n] in your
- # translation. The program will only accept English input
- # at this point.
- gettext "Are you sure [Y/n]? " >&2
- read yesno
- case "$yesno" in [Nn]*) exit 1 ;; esac
- fi
- : bisect without $TERM_GOOD...
- ;;
- *)
- bad_syn=$(bisect_voc bad)
- good_syn=$(bisect_voc good)
- if test -s "$GIT_DIR/BISECT_START"
- then
-
- eval_gettextln "You need to give me at least one \$bad_syn and one \$good_syn revision.
-(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
- else
- eval_gettextln "You need to start by \"git bisect start\".
-You then need to give me at least one \$good_syn and one \$bad_syn revision.
-(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
- fi
- exit 1 ;;
- esac
-}
-
bisect_auto_next() {
- bisect_next_check && bisect_next || :
+ git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD && bisect_next || :
}
bisect_next() {
case "$#" in 0) ;; *) usage ;; esac
bisect_autostart
- bisect_next_check $TERM_GOOD
+ git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD $TERM_GOOD|| exit
# Perform all bisection computation, display and checkout
git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
@@ -355,7 +310,7 @@ bisect_next() {
}
bisect_visualize() {
- bisect_next_check fail
+ git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
if test $# = 0
then
@@ -409,7 +364,7 @@ bisect_replay () {
}
bisect_run () {
- bisect_next_check fail
+ git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
test -n "$*" || die "$(gettext "bisect run failed: no command provided.")"
@@ -484,13 +439,6 @@ get_terms () {
fi
}
-bisect_voc () {
- case "$1" in
- bad) echo "bad|new" ;;
- good) echo "good|old" ;;
- esac
-}
-
bisect_terms () {
get_terms
if ! test -s "$GIT_DIR/BISECT_TERMS"