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

[PATCH 03/10] bisect: store good revisions in a "sha1_array"

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

This will make it easier to use good revisions for checking merge bases later.

To simplify the code, a new "sha1_array_push" function is also introduced.

And while at it we move the earlier part of the code to fill the argv that is passed to "setup_revisions", so that all this code is now completely after "read_bisect_refs".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 bisect.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/bisect.c b/bisect.c
index f99637d..7976cbf 100644
--- a/bisect.c
+++ b/bisect.c
@@ -15,6 +15,7 @@ struct sha1_array {
 	int sha1_alloc;
 };
 
+static struct sha1_array good_revs;
 static struct sha1_array skipped_revs;
 
 static const char **rev_argv;
@@ -418,18 +419,22 @@ static void rev_argv_push(const unsigned char *sha1, const char *format)
 	rev_argv[rev_argv_nr++] = strbuf_detach(&buf, NULL);
 }
 
+static void sha1_array_push(struct sha1_array *array,
+			    const unsigned char *sha1)
+{
+	ALLOC_GROW(array->sha1, array->sha1_nr + 1, array->sha1_alloc);
+	hashcpy(array->sha1[array->sha1_nr++], sha1);
+}
+
 static int register_ref(const char *refname, const unsigned char *sha1,
 			int flags, void *cb_data)
 {
 	if (!strcmp(refname, "bad")) {
 		current_bad_sha1 = sha1;
-		rev_argv_push(sha1, "%s");
 	} else if (!prefixcmp(refname, "good-")) {
-		rev_argv_push(sha1, "^%s");
+		sha1_array_push(&good_revs, sha1);
 	} else if (!prefixcmp(refname, "skip-")) {
-		ALLOC_GROW(skipped_revs.sha1, skipped_revs.sha1_nr + 1,
-			   skipped_revs.sha1_alloc);
-		hashcpy(skipped_revs.sha1[skipped_revs.sha1_nr++], sha1);
+		sha1_array_push(&skipped_revs, sha1);
 	}
 
 	return 0;
@@ -524,16 +529,23 @@ struct commit_list *filter_skipped(struct commit_list *list,
 
 static void bisect_rev_setup(struct rev_info *revs, const char *prefix)
 {
+	int i;
+
 	init_revisions(revs, prefix);
 	revs->abbrev = 0;
 	revs->commit_format = CMIT_FMT_UNSPECIFIED;
 
+	if (read_bisect_refs())
+		die("reading bisect refs failed");
+
 	/* argv[0] will be ignored by setup_revisions */
 	ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
 	rev_argv[rev_argv_nr++] = xstrdup("bisect_rev_setup");
 
-	if (read_bisect_refs())
-		die("reading bisect refs failed");
+	rev_argv_push(current_bad_sha1, "%s");
+
+	for (i = 0; i < good_revs.sha1_nr; i++)
+		rev_argv_push(good_revs.sha1[i], "^%s");
 
 	ALLOC_GROW(rev_argv, rev_argv_nr + 1, rev_argv_alloc);
 	rev_argv[rev_argv_nr++] = xstrdup("--");
-- 
1.6.3.rc1.112.g17e25
Previous: Christian CouderNext: Christian Couder
Message 4 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.