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

[RFC PATCH 2/4] commit-list: add a function to check if a commit is in a list

From
Alban Gruin <alban.gruin@gmail.com>
Date
Mar 1, 2019, 17:50 UTC
Message-ID
<20190301175024.17337-3-alban.gruin@gmail.com>
In-Reply-To
<20190301175024.17337-1-alban.gruin@gmail.com>

To avoid naming some commits, name_rev() will need to check if a commit is part of a commit list.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
 commit.c | 12 ++++++++++++
 commit.h |  1 +
 2 files changed, 13 insertions(+)
diff --git a/commit.c b/commit.c
index a5333c7ac6..fcb3e9245f 100644
--- a/commit.c
+++ b/commit.c
@@ -524,6 +524,18 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list *
 	return new_list;
 }
 
+int commit_list_contains(const struct commit_list *l, struct commit *commit)
+{
+	const struct commit_list *item;
+
+	for (item = l; item != NULL; item = item->next) {
+		if (oideq(&item->item->object.oid, &commit->object.oid))
+			return 1;
+	}
+
+	return 0;
+}
+
 unsigned commit_list_count(const struct commit_list *l)
 {
 	unsigned c = 0;
diff --git a/commit.h b/commit.h
index 42728c2906..c9df613b0e 100644
--- a/commit.h
+++ b/commit.h
@@ -165,6 +165,7 @@ struct commit_list *commit_list_insert(struct commit *item,
 					struct commit_list **list);
 struct commit_list **commit_list_append(struct commit *commit,
 					struct commit_list **next);
+int commit_list_contains(const struct commit_list *l, struct commit *commit);
 unsigned commit_list_count(const struct commit_list *l);
 struct commit_list *commit_list_insert_by_date(struct commit *item,
 				    struct commit_list **list);
-- 
2.20.1
Previous: Jeff KingNext: Alban Gruin
Message 10 of 18 in “name-rev: improve memory usage”
  1. 0/4 name-rev: improve memory usageAlban Gruin, Mar 1, 2019
  2. 1/4 name-rev: improve name_rev() memory usageAlban Gruin, Mar 1, 2019
  3. Eric SunshineMar 1, 2019
  4. Jeff KingMar 1, 2019
  5. Johannes SchindelinMar 2, 2019
  6. 3/4 name-rev: check if a commit should be named before naming itAlban Gruin, Mar 1, 2019
  7. Eric SunshineMar 1, 2019
  8. Alban GruinMar 1, 2019
  9. Jeff KingMar 1, 2019
  10. 2/4 commit-list: add a function to check if a commit is in a listAlban Gruin, Mar 1, 2019
  11. 4/4 name-rev: avoid naming from a ref if it’s not a descendant of any commitAlban Gruin, Mar 1, 2019
  12. Eric SunshineMar 1, 2019
  13. Christian CouderMar 3, 2019
  14. Christian CouderMar 3, 2019
  15. Alban GruinMar 3, 2019
  16. Jeff KingMar 1, 2019
  17. Alban GruinMar 1, 2019
  18. Jeff KingMar 1, 2019

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.