From 0871984d304c9201b85897743eae583cd165106d Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 9 May 2009 17:55:47 +0200 Subject: [PATCH] bisect: make "git bisect" use new "--next-all" bisect-helper function This patch replace the "--next-exit" option of "git bisect--helper" with a "--next-all" option that does merge base checking using the "check_good_are_ancestors_of_bad" function implemented in "bisect.c" in a former patch. The new "--next-all" option is then used in "git-bisect.sh" instead of the "--next-exit" option, and all the shell functions in "git-bisect.sh" that are now unused are removed. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- bisect.c | 4 +- bisect.h | 2 +- builtin-bisect--helper.c | 14 +++--- git-bisect.sh | 127 +---------------------------------------------- 4 files changed, 13 insertions(+), 134 deletions(-) diff --git a/bisect.c b/bisect.c index 09102daba8..f57b62cddd 100644 --- a/bisect.c +++ b/bisect.c @@ -830,7 +830,7 @@ static void check_good_are_ancestors_of_bad(const char *prefix) * the bisection process finished successfully. * In this case the calling shell script should exit 0. */ -int bisect_next_exit(const char *prefix) +int bisect_next_all(const char *prefix) { struct rev_info revs; struct commit_list *tried; @@ -841,6 +841,8 @@ int bisect_next_exit(const char *prefix) if (read_bisect_refs()) die("reading bisect refs failed"); + check_good_are_ancestors_of_bad(prefix); + bisect_rev_setup(&revs, prefix); bisect_common(&revs, &reaches, &all); diff --git a/bisect.h b/bisect.h index 0b5d122a7b..fb744fdb79 100644 --- a/bisect.h +++ b/bisect.h @@ -27,7 +27,7 @@ struct rev_list_info { extern int show_bisect_vars(struct rev_list_info *info, int reaches, int all); -extern int bisect_next_exit(const char *prefix); +extern int bisect_next_all(const char *prefix); extern int estimate_bisect_steps(int all); diff --git a/builtin-bisect--helper.c b/builtin-bisect--helper.c index aca7018d83..cb3e155116 100644 --- a/builtin-bisect--helper.c +++ b/builtin-bisect--helper.c @@ -4,24 +4,24 @@ #include "bisect.h" static const char * const git_bisect_helper_usage[] = { - "git bisect--helper --next-exit", + "git bisect--helper --next-all", NULL }; int cmd_bisect__helper(int argc, const char **argv, const char *prefix) { - int next_exit = 0; + int next_all = 0; struct option options[] = { - OPT_BOOLEAN(0, "next-exit", &next_exit, - "output bisect result and exit instuctions"), + OPT_BOOLEAN(0, "next-all", &next_all, + "perform 'git bisect next'"), OPT_END() }; argc = parse_options(argc, argv, options, git_bisect_helper_usage, 0); - if (!next_exit) + if (!next_all) usage_with_options(git_bisect_helper_usage, options); - /* next-exit */ - return bisect_next_exit(prefix); + /* next-all */ + return bisect_next_all(prefix); } diff --git a/git-bisect.sh b/git-bisect.sh index 786b7b9110..8969553658 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -167,10 +167,6 @@ is_expected_rev() { test "$1" = $(cat "$GIT_DIR/BISECT_EXPECTED_REV") } -mark_expected_rev() { - echo "$1" > "$GIT_DIR/BISECT_EXPECTED_REV" -} - check_expected_revs() { for _rev in "$@"; do if ! is_expected_rev "$_rev"; then @@ -269,132 +265,13 @@ bisect_auto_next() { bisect_next_check && bisect_next || : } -bisect_checkout() { - _rev="$1" - _msg="$2" - echo "Bisecting: $_msg" - mark_expected_rev "$_rev" - git checkout -q "$_rev" -- || exit - git show-branch "$_rev" -} - -is_among() { - _rev="$1" - _list="$2" - case "$_list" in *$_rev*) return 0 ;; esac - return 1 -} - -handle_bad_merge_base() { - _badmb="$1" - _good="$2" - if is_expected_rev "$_badmb"; then - cat >&2 <&2 <&2 < "$GIT_DIR/BISECT_ANCESTORS_OK" - - return 0 -} - bisect_next() { case "$#" in 0) ;; *) usage ;; esac bisect_autostart bisect_next_check good - # Get bad, good and skipped revs - bad=$(git rev-parse --verify refs/bisect/bad) && - good=$(git for-each-ref --format='^%(objectname)' \ - "refs/bisect/good-*" | tr '\012' ' ') && - skip=$(git for-each-ref --format='%(objectname)' \ - "refs/bisect/skip-*" | tr '\012' ' ') || exit - - # Maybe some merge bases must be tested first - check_good_are_ancestors_of_bad "$bad" "$good" "$skip" - # Return now if a checkout has already been done - test "$?" -eq "1" && return - - # Perform bisection computation, display and checkout - git bisect--helper --next-exit + # Perform all bisection computation, display and checkout + git bisect--helper --next-all res=$? # Check if we should exit because bisection is finished -- 2.11.4.GIT