diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-08-27 14:46:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-08-27 18:36:39 -0700 |
commit | a20efee9cfcf9c68bb01d0aa82ffc7903d88bab4 (patch) | |
tree | e329f429d9abd42f015099a072efedcfd385ec46 /commit.c | |
parent | d0f1ea6003d97e63110fa7d50bb07f546a909b6e (diff) | |
download | git-a20efee9cfcf9c68bb01d0aa82ffc7903d88bab4.tar.gz |
in_merge_bases(): support only one "other" commit
In early days of its life, I planned to make it possible to compute
"is a commit contained in all of these other commits?" with this
function, but it turned out that no caller needed it.
Just make it take two commit objects and add a comment to say what
these two functions do.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -754,6 +754,9 @@ struct commit_list *get_merge_bases(struct commit *one, struct commit *two, return get_merge_bases_many(one, 1, &two, cleanup); } +/* + * Is "commit" a decendant of one of the elements on the "with_commit" list? + */ int is_descendant_of(struct commit *commit, struct commit_list *with_commit) { if (!with_commit) @@ -763,21 +766,21 @@ int is_descendant_of(struct commit *commit, struct commit_list *with_commit) other = with_commit->item; with_commit = with_commit->next; - if (in_merge_bases(other, &commit, 1)) + if (in_merge_bases(other, commit)) return 1; } return 0; } -int in_merge_bases(struct commit *commit, struct commit **reference, int num) +/* + * Is "commit" an ancestor of (i.e. reachable from) the "reference"? + */ +int in_merge_bases(struct commit *commit, struct commit *reference) { struct commit_list *bases, *b; int ret = 0; - if (num == 1) - bases = get_merge_bases(commit, *reference, 1); - else - die("not yet"); + bases = get_merge_bases(commit, reference, 1); for (b = bases; b; b = b->next) { if (!hashcmp(commit->object.sha1, b->item->object.sha1)) { ret = 1; |