Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
in_merge_bases(): use paint_down_to_common()
author
Junio C Hamano
<gitster@pobox.com>
Thu, 30 Aug 2012 22:04:13 +0000
(15:04 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 31 Aug 2012 00:25:57 +0000
(17:25 -0700)
With paint_down_to_common(), we can tell if "commit" is reachable
from "reference" by simply looking at its object flag, instead of
iterating over the merge bases.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
da1f515
)
diff --git
a/commit.c
b/commit.c
index 0058fa5b4365d290ccdb0ed64f6a23eb6f195527..d39a9e96937d1d6f7e2932fe12729c25896b2977 100644
(file)
--- a/
commit.c
+++ b/
commit.c
@@
-786,20
+786,17
@@
int is_descendant_of(struct commit *commit, struct commit_list *with_commit)
*/
int in_merge_bases(struct commit *commit, struct commit *reference)
{
*/
int in_merge_bases(struct commit *commit, struct commit *reference)
{
- struct commit_list *bases
, *b
;
+ struct commit_list *bases;
int ret = 0;
int ret = 0;
- bases = merge_bases_many(commit, 1, &reference);
+ if (parse_commit(commit) || parse_commit(reference))
+ return ret;
+
+ bases = paint_down_to_common(commit, 1, &reference);
+ if (commit->object.flags & PARENT2)
+ ret = 1;
clear_commit_marks(commit, all_flags);
clear_commit_marks(reference, all_flags);
clear_commit_marks(commit, all_flags);
clear_commit_marks(reference, all_flags);
-
- for (b = bases; b; b = b->next) {
- if (!hashcmp(commit->object.sha1, b->item->object.sha1)) {
- ret = 1;
- break;
- }
- }
-
free_commit_list(bases);
return ret;
}
free_commit_list(bases);
return ret;
}