git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 05/12] bisect: add enum to represent bisect returning codes

From
Miriam Rubio <mirucam@gmail.com>
Date
Feb 17, 2020, 08:40 UTC
Message-ID
<20200217084039.78215-6-mirucam@gmail.com>
In-Reply-To
<20200217084039.78215-1-mirucam@gmail.com>

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>
---
 bisect.c |  2 +-
 bisect.h | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/bisect.c b/bisect.c
index 83cb5b3a98..e4573c7ba1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -945,7 +945,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
  * If no_checkout is non-zero, the bisection process does not
  * checkout the trial commit but instead simply updates BISECT_HEAD.
  */
-int bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
+enum bisect_error bisect_next_all(struct repository *r, const char *prefix, int no_checkout)
 {
 	struct rev_info revs;
 	struct commit_list *tried;
diff --git a/bisect.h b/bisect.h
index 4e69a11ea8..c921ead02c 100644
--- a/bisect.h
+++ b/bisect.h
@@ -31,7 +31,19 @@ struct rev_list_info {
 	const char *header_prefix;
 };
 
-int bisect_next_all(struct repository *r,
+/*
+ * enum bisect_error represents the following return codes:
+ * BISECT_OK: success code. Internally, it means that next
+ * commit has been found (and possibly checked out) and it
+ * should be tested.
+ * BISECT_FAILED error code: default error code.
+ */
+enum bisect_error {
+	BISECT_OK = 0,
+	BISECT_FAILED = -1
+};
+
+enum bisect_error bisect_next_all(struct repository *r,
 		    const char *prefix,
 		    int no_checkout);
 
-- 
2.25.0
Previous: Miriam RubioNext: Miriam Rubio
Message 5 of 14 in “Finish converting git bisect to C part 1”
  1. Miriam RubioFeb 17, 2020
  2. 01/12 bisect--helper: convert `vocab_*` char pointers to char arraysMiriam Rubio, Feb 17, 2020
  3. 03/12 bisect: use the standard 'if (!var)' way to check for 0Miriam Rubio, Feb 17, 2020
  4. 02/12 bisect--helper: change `retval` to `res`Miriam Rubio, Feb 17, 2020
  5. 05/12 bisect: add enum to represent bisect returning codesMiriam Rubio, Feb 17, 2020
  6. 04/12 bisect--helper: introduce new `decide_next()` functionMiriam Rubio, Feb 17, 2020
  7. 06/12 bisect--helper: return error codes from `cmd_bisect__helper()`Miriam Rubio, Feb 17, 2020
  8. 08/12 bisect: libify `bisect_checkout`Miriam Rubio, Feb 17, 2020
  9. 07/12 bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependentsMiriam Rubio, Feb 17, 2020
  10. 10/12 bisect: libify `check_good_are_ancestors_of_bad` and its dependentsMiriam Rubio, Feb 17, 2020
  11. 09/12 bisect: libify `check_merge_bases` and its dependentsMiriam Rubio, Feb 17, 2020
  12. 11/12 bisect: libify `handle_bad_merge_base` and its dependentsMiriam Rubio, Feb 17, 2020
  13. 12/12 bisect: libify `bisect_next_all`Miriam Rubio, Feb 17, 2020
  14. Junio C HamanoFeb 19, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.