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

[PATCH v2 2/3] bisect: when skipping, choose a commit away from a skipped commit

From
Christian Couder <chriscool@tuxfamily.org>
Date
Jun 5, 2009, 04:10 UTC
Message-ID
<20090605041044.8885.92104.chriscool@tuxfamily.org>
In-Reply-To
<20090605040238.8885.92790.chriscool@tuxfamily.org>

To do that a new function "apply_skip_ratio" is added and another function "managed_skipped" is created to wrap both "filter_skipped" and the previous one.

In "managed_skipped" we detect when we should choose a commit away from a skipped one and then we automatically choose a skip ratio to pass to "apply_skip_ratio".

The ratio is choosen so that it alternates between 1/5, 2/5 and 3/5.

In "apply_skip_ratio", we ignore a given ratio of all the commits that could be tested.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 bisect.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)
diff --git a/bisect.c b/bisect.c
index 02497f7..3ad9887 100644
--- a/bisect.c
+++ b/bisect.c
@@ -571,6 +571,57 @@ struct commit_list *filter_skipped(struct commit_list *list,
 	return filtered;
 }
 
+static struct commit_list *apply_skip_ratio(struct commit_list *list,
+					    int count,
+					    int skip_num, int skip_denom)
+{
+	int index, i;
+	struct commit_list *cur, *previous;
+
+	cur = list;
+	previous = NULL;
+	index = count * skip_num / skip_denom;
+
+	for (i = 0; cur; cur = cur->next, i++) {
+		if (i == index) {
+			if (hashcmp(cur->item->object.sha1, current_bad_sha1))
+				return cur;
+			if (previous)
+				return previous;
+			return list;
+		}
+		previous = cur;
+	}
+
+	return list;
+}
+
+static struct commit_list *managed_skipped(struct commit_list *list,
+					   struct commit_list **tried)
+{
+	int count, skipped_first;
+	int skip_num, skip_denom;
+
+	*tried = NULL;
+
+	if (!skipped_revs.sha1_nr)
+		return list;
+
+	if (!skip_num)
+		return filter_skipped(list, tried, 0, NULL, NULL);
+
+	list = filter_skipped(list, tried, 0, &count, &skipped_first);
+
+	if (!skipped_first)
+		return list;
+
+	/* Use alternatively 1/5, 2/5 and 3/5 as skip ratio. */
+	skip_num = count % 3 + 1;
+	skip_denom = 5;
+
+	return apply_skip_ratio(list, count, skip_num, skip_denom);
+}
+
 static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
 			     const char *bad_format, const char *good_format,
 			     int read_paths)
@@ -883,7 +934,7 @@ int bisect_next_all(const char *prefix)
 
 	revs.commits = find_bisection(revs.commits, &reaches, &all,
 				       !!skipped_revs.sha1_nr);
-	revs.commits = filter_skipped(revs.commits, &tried, 0, NULL, NULL);
+	revs.commits = managed_skipped(revs.commits, &tried);
 
 	if (!revs.commits) {
 		/*
-- 
1.6.3.GIT
Previous: Christian CouderNext: Junio C Hamano
Message 5 of 9 in “automatically skip away from broken commits”
  1. 0/3 automatically skip away from broken commitsChristian Couder, Jun 5, 2009
  2. 1/3 bisect: add parameters to "filter_skipped"Christian Couder, Jun 5, 2009
  3. Junio C HamanoJun 5, 2009
  4. Christian CouderJun 6, 2009
  5. 2/3 bisect: when skipping, choose a commit away from a skipped commitChristian Couder, Jun 5, 2009
  6. Junio C HamanoJun 5, 2009
  7. Christian CouderJun 6, 2009
  8. Junio C HamanoJun 6, 2009
  9. 3/3 t6030: test skipping away from an already skipped commitChristian Couder, Jun 5, 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.