summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJake Goulding <goulding@vivisimo.com>2009-01-26 09:13:24 -0500
committerJunio C Hamano <gitster@pobox.com>2009-01-28 11:33:03 -0800
commit7fcdb36e29f9a5e779bc9e44cd69f8f69fac9426 (patch)
tree0174c7c8187f04c75aa936211ca73ff44346881e /commit.c
parent269defdf30a4beb48f230e36f20d00ee40348ab6 (diff)
downloadgit-7fcdb36e29f9a5e779bc9e44cd69f8f69fac9426.tar.gz
Make has_commit() non-static
Move has_commit() from branch to a common location, in preparation for using it in "git-tag". Rename it to is_descendant_of() to make it more unique and descriptive. Signed-off-by: Jake Goulding <goulding@vivisimo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index c99db162a4..aa3b35b6a8 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 is_descendant_of(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;