bisect: add enum to represent bisect returning codes
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. Create an enum called `bisect_error` with the bisecting return codes to use in `bisect.c` libification process. Change bisect_next_all() to make it return this enum. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Miriam Rubio <mirucam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Miriam Rubio committed
Feb 17, 2020 at 09:40 UTC
680e8a01e57cd383048bf4e7d9668ce715d6d649
2 files changed
+14
-2
bisect.c
+1
-1
@@ -945,7 +945,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
945
* If no_checkout is non-zero, the bisection process does not
946
* checkout the trial commit but instead simply updates BISECT_HEAD.
947
*/
948
-int bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
948
+enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
949
{
950
struct rev_info revs;
951
struct commit_list *tried;
bisect.h
+13
-1
@@ -31,7 +31,19 @@ struct rev_list_info {
31
const char *header_prefix;
32
};
33
34
-int bisect_next_all(struct repository *r,
34
+/*
35
+ * enum bisect_error represents the following return codes:
36
+ * BISECT_OK: success code. Internally, it means that next
37
+ * commit has been found (and possibly checked out) and it
38
+ * should be tested.
39
+ * BISECT_FAILED error code: default error code.
40
+ */
41
+enum bisect_error {
42
+ BISECT_OK = 0,
43
+ BISECT_FAILED = -1
44
+};
45
+
46
+enum bisect_error bisect_next_all(struct repository *r,
47
const char *prefix,
48
int no_checkout);
49