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

[PATCH 2/3] Make has_commit non-static

From
Jake Goulding <goulding@vivisimo.com>
Date
Jan 23, 2009, 00:48 UTC
Message-ID
<497913E4.6050806@vivisimo.com>
In-Reply-To
<1232671630-19683-1-git-send-email-goulding@vivisimo.com>

Moving has_commit from branch to a common location in preparation for using it in tag.

Signed-off-by: Jake Goulding <goulding@vivisimo.com>
---
 builtin-branch.c |   15 ---------------
 commit.c         |   15 +++++++++++++++
 commit.h         |    1 +
 3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/builtin-branch.c b/builtin-branch.c
index 82d6fb2..bb42911 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -193,21 +193,6 @@ struct ref_list {
 	int kinds;
 };

-static int has_commit(struct commit *commit, struct commit_list
*with_commit)
-{
-	if (!with_commit)
-		return 1;
-	while (with_commit) {
-		struct commit *other;
-
-		other = with_commit->item;
-		with_commit = with_commit->next;
-		if (in_merge_bases(other, &commit, 1))
-			return 1;
-	}
-	return 0;
-}
-
 static int append_ref(const char *refname, const unsigned char *sha1,
int flags, void *cb_data)
 {
 	struct ref_list *ref_list = (struct ref_list*)(cb_data);
diff --git a/commit.c b/commit.c
index c99db16..5ccb338 100644
--- a/commit.c
+++ b/commit.c
@@ -705,6 +705,21 @@ struct commit_list *get_merge_bases(struct commit
*one, struct commit *two,
 	return get_merge_bases_many(one, 1, &two, cleanup);
 }

+int has_commit(struct commit *commit, struct commit_list *with_commit)
+{
+	if (!with_commit)
+		return 1;
+	while (with_commit) {
+		struct commit *other;
+
+		other = with_commit->item;
+		with_commit = with_commit->next;
+		if (in_merge_bases(other, &commit, 1))
+			return 1;
+	}
+	return 0;
+}
+
 int in_merge_bases(struct commit *commit, struct commit **reference,
int num)
 {
 	struct commit_list *bases, *b;
diff --git a/commit.h b/commit.h
index 3a7b06a..1b8444f 100644
--- a/commit.h
+++ b/commit.h
@@ -133,6 +133,7 @@ extern int is_repository_shallow(void);
 extern struct commit_list *get_shallow_commits(struct object_array *heads,
 		int depth, int shallow_flag, int not_shallow_flag);

+int has_commit(struct commit *, struct commit_list *);
 int in_merge_bases(struct commit *, struct commit **, int);

 extern int interactive_add(int argc, const char **argv, const char
*prefix);
-- 
1.6.0.4
Next: Junio C Hamano
Message 1 of 5 in “Make has_commit non-static”
  1. 2/3 Make has_commit non-staticJake Goulding, Jan 23, 2009
  2. Junio C HamanoJan 23, 2009
  3. Jake GouldingJan 23, 2009
  4. 3/3 Add --contains flag to git tagJake Goulding, Jan 23, 2009
  5. Junio C HamanoJan 23, 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.