[PATCH 2/5] git-merge-base: follow 'prior' links to find merge bases
- From
Sam Vilain <sam.vilain@catalyst.net.nz>
- Date
- Apr 25, 2006, 04:31 UTC
- Message-ID
- <20060425043106.18382.48165.stgit@localhost.localdomain>
- In-Reply-To
- <20060425035421.18382.51677.stgit@localhost.localdomain>
From: Sam Vilain <sam.vilain@catalyst.net.nz>
It is possible that a good merge base may be found looking via "prior" links as well. We follow them where possible. ---
merge-base.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/merge-base.c b/merge-base.c index 07f5ab4..ed6d18c 100644 --- a/merge-base.c +++ b/merge-base.c @@ -207,6 +207,18 @@ static int merge_base(struct commit *rev p->object.flags |= flags; insert_by_date(p, &list); } + /* If the commit has a "prior" reference, add it */ + if (commit->prior) { + struct commit *prior; + prior = lookup_commit_reference_gently(commit->prior, 1); + if (prior) { + if ((prior->object.flags & flags) != flags) { + parse_commit(prior); + prior->object.flags |= flags; + insert_by_date(prior, &list); + } + } + } } if (!result)