summaryrefslogtreecommitdiff
path: root/builtin/bisect--helper.c
diff options
context:
space:
mode:
authorPranit Bauva <pranit.bauva@gmail.com>2020-02-17 08:40:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-19 17:37:14 (GMT)
commit45b6370812cb9bc50212d50f071c8ae5dd851698 (patch)
tree42c80045e6a4bd009b75d51d219fc4e4010d67de /builtin/bisect--helper.c
parentcdd4dc2d6a3e420178100efc780a987495a1a3bd (diff)
downloadgit-45b6370812cb9bc50212d50f071c8ae5dd851698.zip
git-45b6370812cb9bc50212d50f071c8ae5dd851698.tar.gz
git-45b6370812cb9bc50212d50f071c8ae5dd851698.tar.bz2
bisect: libify `check_good_are_ancestors_of_bad` and its dependents
Since we want to get rid of git-bisect.sh, it would be necessary to convert those exit() calls to return statements so that errors can be reported. Emulate try catch in C by converting `exit(<positive-value>)` to `return <negative-value>`. Follow POSIX conventions to return <negative-value> to indicate error. Code that turns BISECT_INTERNAL_SUCCESS_MERGE_BASE (-11) to BISECT_OK (0) from `check_good_are_ancestors_of_bad()` has been moved to `cmd_bisect__helper()`. Update all callers to handle the error returns. 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: Miriam Rubio <mirucam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/bisect--helper.c')
-rw-r--r--builtin/bisect--helper.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index e6bd4d6..c1c40b5 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -666,7 +666,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
switch (cmdmode) {
case NEXT_ALL:
- return bisect_next_all(the_repository, prefix, no_checkout);
+ res = bisect_next_all(the_repository, prefix, no_checkout);
+ break;
case WRITE_TERMS:
if (argc != 2)
return error(_("--write-terms requires two arguments"));
@@ -713,5 +714,13 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
return error("BUG: unknown subcommand '%d'", cmdmode);
}
free_terms(&terms);
+
+ /*
+ * Handle early success
+ * From check_merge_bases > check_good_are_ancestors_of_bad > bisect_next_all
+ */
+ if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE)
+ res = BISECT_OK;
+
return abs(res);
}