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

[PATCH 05/10] bisect: remove too much function nesting

From
Christian Couder <chriscool@tuxfamily.org>
Date
May 9, 2009, 15:55 UTC
Message-ID
<20090509155548.5387.95855.chriscool@tuxfamily.org>
In-Reply-To
<20090509154419.5324.96204.chriscool@tuxfamily.org>

This patch moves some function calls into "bisect_next_exit" so that functions are nesting less.

The call to "bisect_rev_setup" is moved from "bisect_common" into "bisect_next_exit" and the call to "read_bisect_refs" from "bisect_rev_setup" into "bisect_next_exit".

While at it, "rev_argv" is moved into "bisect_rev_setup".

This will make it easier and cleaner to implement checking merge bases.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 bisect.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/bisect.c b/bisect.c
index 8e34186..9e01b9e 100644
--- a/bisect.c
+++ b/bisect.c
@@ -26,8 +26,6 @@ struct argv_array {
 	int argv_alloc;
 };
 
-struct argv_array rev_argv;
-
 static const char *argv_diff_tree[] = {"diff-tree", "--pretty", NULL, NULL};
 static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
 static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
@@ -539,15 +537,13 @@ struct commit_list *filter_skipped(struct commit_list *list,
 
 static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
 {
+	struct argv_array rev_argv = { NULL, 0, 0 };
 	int i;
 
 	init_revisions(revs, prefix);
 	revs->abbrev = 0;
 	revs->commit_format = CMIT_FMT_UNSPECIFIED;
 
-	if (read_bisect_refs())
-		die("reading bisect refs failed");
-
 	/* rev_argv.argv[0] will be ignored by setup_revisions */
 	argv_array_push(&rev_argv, xstrdup("bisect_rev_setup"));
 	argv_array_push_sha1(&rev_argv, current_bad_sha1, "%s");
@@ -561,11 +557,8 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
 	revs->limited = 1;
 }
 
-static void bisect_common(struct rev_info *revs, const char *prefix,
-			  int *reaches, int *all)
+static void bisect_common(struct rev_info *revs, int *reaches, int *all)
 {
-	bisect_rev_setup(revs, prefix);
-
 	if (prepare_revision_walk(revs))
 		die("revision walk setup failed");
 	if (revs->tree_objects)
@@ -636,7 +629,12 @@ int bisect_next_exit(const char *prefix)
 	const unsigned char *bisect_rev;
 	char bisect_rev_hex[41];
 
-	bisect_common(&revs, prefix, &reaches, &all);
+	if (read_bisect_refs())
+		die("reading bisect refs failed");
+
+	bisect_rev_setup(&revs, prefix);
+
+	bisect_common(&revs, &reaches, &all);
 
 	revs.commits = filter_skipped(revs.commits, &tried, 0);
 
-- 
1.6.3.rc1.112.g17e25
Previous: Christian CouderNext: Christian Couder
Message 6 of 14 in “bisect: port git bisect merge base checking to C”
  1. 00/10 bisect: port git bisect merge base checking to CChristian Couder, May 9, 2009
  2. 01/10 bisect: use "sha1_array" to store skipped revisionsChristian Couder, May 9, 2009
  3. 02/10 bisect: implement "rev_argv_push" to fill an argv with revsChristian Couder, May 9, 2009
  4. 03/10 bisect: store good revisions in a "sha1_array"Christian Couder, May 9, 2009
  5. 04/10 bisect: use new "struct argv_array" to prepare argv for "setup_revisions"Christian Couder, May 9, 2009
  6. 05/10 bisect: remove too much function nestingChristian Couder, May 9, 2009
  7. 06/10 bisect: make skipped array functions more genericChristian Couder, May 9, 2009
  8. 07/10 bisect: automatically sort sha1_array if needed when looking it upChristian Couder, May 9, 2009
  9. Jakub NarebskiMay 9, 2009
  10. Christian CouderMay 10, 2009
  11. 08/10 bisect: implement the "check_merge_bases" functionChristian Couder, May 9, 2009
  12. 09/10 bisect: add "check_good_are_ancestors_of_bad" functionChristian Couder, May 9, 2009
  13. 10/10 bisect: make "git bisect" use new "--next-all" bisect-helper functionChristian Couder, May 9, 2009
  14. Junio C HamanoMay 11, 2009

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.