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

[PATCH 06/10] bisect: make skipped array functions more generic

From
Christian Couder <chriscool@tuxfamily.org>
Date
May 9, 2009, 15:55 UTC
Message-ID
<20090509155548.5387.88589.chriscool@tuxfamily.org>
In-Reply-To
<20090509154419.5324.96204.chriscool@tuxfamily.org>
So they can be used on the good array too.

This is done by renaming many functions and some variables to remove "skip" in the name, and by adding a "struct sha1_array *array" argument where needed.

While at it, make the second argument to "lookup_sha1_array" const. It becomes "const unsigned char *sha1".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 bisect.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/bisect.c b/bisect.c
index 9e01b9e..77edeca 100644
--- a/bisect.c
+++ b/bisect.c
@@ -479,27 +479,26 @@ void read_bisect_paths(struct argv_array *array)
 	fclose(fp);
 }
 
-static int skipcmp(const void *a, const void *b)
+static int array_cmp(const void *a, const void *b)
 {
 	return hashcmp(a, b);
 }
 
-static void prepare_skipped(void)
+static void sort_sha1_array(struct sha1_array *array)
 {
-	qsort(skipped_revs.sha1, skipped_revs.sha1_nr,
-	      sizeof(*skipped_revs.sha1), skipcmp);
+	qsort(array->sha1, array->sha1_nr, sizeof(*array->sha1), array_cmp);
 }
 
-static const unsigned char *skipped_sha1_access(size_t index, void *table)
+static const unsigned char *sha1_access(size_t index, void *table)
 {
-	unsigned char (*skipped)[20] = table;
-	return skipped[index];
+	unsigned char (*array)[20] = table;
+	return array[index];
 }
 
-static int lookup_skipped(unsigned char *sha1)
+static int lookup_sha1_array(struct sha1_array *array,
+			     const unsigned char *sha1)
 {
-	return sha1_pos(sha1, skipped_revs.sha1, skipped_revs.sha1_nr,
-			skipped_sha1_access);
+	return sha1_pos(sha1, array->sha1, array->sha1_nr, sha1_access);
 }
 
 struct commit_list *filter_skipped(struct commit_list *list,
@@ -513,12 +512,13 @@ struct commit_list *filter_skipped(struct commit_list *list,
 	if (!skipped_revs.sha1_nr)
 		return list;
 
-	prepare_skipped();
+	sort_sha1_array(&skipped_revs);
 
 	while (list) {
 		struct commit_list *next = list->next;
 		list->next = NULL;
-		if (0 <= lookup_skipped(list->item->object.sha1)) {
+		if (0 <= lookup_sha1_array(&skipped_revs,
+					   list->item->object.sha1)) {
 			/* Move current to tried list */
 			*tried = list;
 			tried = &list->next;
-- 
1.6.3.rc1.112.g17e25
Previous: Christian CouderNext: Christian Couder
Message 7 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.