]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'kk/commit-reach-find-all-fix' into jch
authorJunio C Hamano <gitster@pobox.com>
Tue, 30 Jun 2026 19:59:15 +0000 (12:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Jun 2026 19:59:15 +0000 (12:59 -0700)
The early-exit optimization in paint_down_to_common() has been gated
on the queue being generation-ordered. This fixes a bug where git
merge-base (without --all) could return incorrect results on
repositories with v1 commit graphs and clock skew.

* kk/commit-reach-find-all-fix:
  commit-reach: guard !FIND_ALL early exit with generation ordering check
  t6600: add test for merge-base early exit with clock skew

1  2 
commit-reach.c
t/t6600-test-reach.sh

diff --cc commit-reach.c
index 5df471a313cf6be855b61fd9c06d2499e97bc7af,ee4b7b692508cf34eb7d89eb6d9960c53b4e42ad..708798a39b2d8ec26dca69c3897edc1017e8468e
@@@ -104,15 -57,16 +104,18 @@@ static int paint_down_to_common(struct 
                                enum merge_base_flags mb_flags,
                                struct commit_list **result)
  {
 -      struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
 +      struct nonstale_queue queue = {
 +              { compare_commits_by_gen_then_commit_date }
 +      };
        int i;
+       int gen_ordered = 1;
        timestamp_t last_gen = GENERATION_NUMBER_INFINITY;
        struct commit_list **tail = result;
  
-       if (!min_generation && !corrected_commit_dates_enabled(r))
+       if (!min_generation && !corrected_commit_dates_enabled(r)) {
 -              queue.compare = compare_commits_by_commit_date;
 +              queue.pq.compare = compare_commits_by_commit_date;
+               gen_ordered = 0;
+       }
  
        one->object.flags |= PARENT1;
        if (!n) {
Simple merge