872
*
873
* If that's not the case, we need to check the merge bases.
874
* If a merge base must be tested by the user, its source code will be
875
- * checked out to be tested by the user and we will exit.
875
+ * checked out to be tested by the user and we will return.
876
*/
877
-static void check_good_are_ancestors_of_bad(struct repository *r,
877
+
878
+static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
879
const char *prefix,
880
int no_checkout)
881
{
881
- char *filename = git_pathdup("BISECT_ANCESTORS_OK");
882
+ char *filename;
883
struct stat st;
884
int fd, rev_nr;
885
enum bisect_error res = BISECT_OK;
886
struct commit **rev;
887
888
if (!current_bad_oid)
888
- die(_("a %s revision is needed"), term_bad);
889
+ return error(_("a %s revision is needed"), term_bad);
890
+
891
+ filename = git_pathdup("BISECT_ANCESTORS_OK");
892
893
/* Check if file BISECT_ANCESTORS_OK exists. */
894
if (!stat(filename, &st) && S_ISREG(st.st_mode))
904
if (check_ancestors(r, rev_nr, rev, prefix))
905
res = check_merge_bases(rev_nr, rev, no_checkout);
906
free(rev);
904
- if (res)
905
- exit(res == BISECT_INTERNAL_SUCCESS_MERGE_BASE ? BISECT_OK : -res);
907
907
- /* Create file BISECT_ANCESTORS_OK. */
908
- fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
909
- if (fd < 0)
910
- warning_errno(_("could not create file '%s'"),
911
- filename);
912
- else
913
- close(fd);
908
+ if (!res) {
909
+ /* Create file BISECT_ANCESTORS_OK. */
910
+ fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY, 0600);
911
+ if (fd < 0)
912
+ /*
913
+ * BISECT_ANCESTORS_OK file is not absolutely necessary,
914
+ * the bisection process will continue at the next
915
+ * bisection step.
916
+ * So, just signal with a warning that something
917
+ * might be wrong.
918
+ */
919
+ warning_errno(_("could not create file '%s'"),
920
+ filename);
921
+ else
922
+ close(fd);
923
+ }
924
done:
925
free(filename);
926
+ return res;
927
}
928
929
/*
995
if (read_bisect_refs())
996
die(_("reading bisect refs failed"));
997
987
- check_good_are_ancestors_of_bad(r, prefix, no_checkout);
998
+ res = check_good_are_ancestors_of_bad(r, prefix, no_checkout);
999
+ if (res)
1000
+ return res;
1001
1002
bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1);
1003
revs.limited = 1;