+2
-1
index 9b50b4660e..a87011c6cd 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
static int show_merge_base(struct commit **rev, size_t rev_nr, int show_all)
{
+ enum merge_base_flags flags = show_all ? MERGE_BASE_FIND_ALL : 0;
struct commit_list *result = NULL, *r;
if (repo_get_merge_bases_many_dirty(the_repository, rev[0],
rev_nr - 1, rev + 1,
- 0, &result) < 0) {
+ flags, &result) < 0) {
commit_list_free(result);
return -1;
}
+15
-4
index 766ba1156a..5a52be90a6 100644
--- a/commit-reach.c
+++ b/commit-reach.c
if (!(commit->object.flags & RESULT)) {
commit->object.flags |= RESULT;
tail = commit_list_append(commit, tail);
+ /*
+ * The queue is generation-ordered; no
+ * remaining common ancestor can be a
+ * descendant of this one.
+ */
+ if (!(mb_flags & MERGE_BASE_FIND_ALL) &&
+ generation < GENERATION_NUMBER_INFINITY)
+ break;
}
/* Mark parents of a found merge stale */
flags |= STALE;
min_generation = curr_generation;
}
if (paint_down_to_common(r, array[i], filled,
- work, min_generation, 0, &common)) {
+ work, min_generation,
+ MERGE_BASE_FIND_ALL, &common)) {
clear_commit_marks(array[i], all_flags);
clear_commit_marks_many(filled, work, all_flags);
commit_list_free(common);
struct commit **twos,
struct commit_list **result)
{
- return get_merge_bases_many_0(r, one, n, twos, 1, 0, result);
+ return get_merge_bases_many_0(r, one, n, twos, 1,
+ MERGE_BASE_FIND_ALL, result);
}
int repo_get_merge_bases_many_dirty(struct repository *r,
struct commit *two,
struct commit_list **result)
{
- return get_merge_bases_many_0(r, one, 1, &two, 1, 0, result);
+ return get_merge_bases_many_0(r, one, 1, &two, 1,
+ MERGE_BASE_FIND_ALL, result);
}
/*
struct commit_list *bases = NULL;
int ret = 0, i;
timestamp_t generation, max_generation = GENERATION_NUMBER_ZERO;
- enum merge_base_flags mb_flags = 0;
+ enum merge_base_flags mb_flags = MERGE_BASE_FIND_ALL;
if (ignore_missing_commits)
mb_flags |= MERGE_BASE_IGNORE_MISSING_COMMITS;
+6
-1
index a3f2cd80eb..3f3a563d8a 100644
--- a/commit-reach.h
+++ b/commit-reach.h
struct commit_list **result);
enum merge_base_flags {
MERGE_BASE_IGNORE_MISSING_COMMITS = (1 << 0),
+ MERGE_BASE_FIND_ALL = (1 << 1),
};
-/* To be used only when object flags after this call no longer matter */
+/*
+ * To be used only when object flags after this call no longer matter.
+ * Without MERGE_BASE_FIND_ALL and with generation numbers available,
+ * returns after finding the first merge-base, skipping the STALE drain.
+ */
int repo_get_merge_bases_many_dirty(struct repository *r,
struct commit *one, size_t n,
struct commit **twos,