Skip to content

Commit 680e8a0

Browse files
mirucamgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Miriam Rubio <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bfacfce commit 680e8a0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
945945
* If no_checkout is non-zero, the bisection process does not
946946
* checkout the trial commit but instead simply updates BISECT_HEAD.
947947
*/
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)
949949
{
950950
struct rev_info revs;
951951
struct commit_list *tried;

bisect.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,19 @@ struct rev_list_info {
3131
const char *header_prefix;
3232
};
3333

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,
3547
const char *prefix,
3648
int no_checkout);
3749

0 commit comments

Comments
 (0)