Skip to content

Commit b0f9e9e

Browse files
trastgitster
authored andcommitted
in_merge_bases(): omit unnecessary redundant common ancestor reduction
The function get_merge_bases() needs to postprocess the result from merge_bases_many() in order to make sure none of the commit is a true ancestor of another commit, which is expensive. However, when checking if a commit is an ancestor of another commit, we only need to see if the commit is a common ancestor between the two, and do not have to care if other common ancestors merge_bases_many() finds are true merge bases or an ancestor of another merge base. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6571225 commit b0f9e9e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

commit.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,10 @@ int in_merge_bases(struct commit *commit, struct commit *reference)
780780
struct commit_list *bases, *b;
781781
int ret = 0;
782782

783-
bases = get_merge_bases(commit, reference, 1);
783+
bases = merge_bases_many(commit, 1, &reference);
784+
clear_commit_marks(commit, all_flags);
785+
clear_commit_marks(reference, all_flags);
786+
784787
for (b = bases; b; b = b->next) {
785788
if (!hashcmp(commit->object.sha1, b->item->object.sha1)) {
786789
ret = 1;

0 commit comments

Comments
 (0)