]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'kk/commit-reach-find-all-fix'
authorJunio C Hamano <gitster@pobox.com>
Sun, 19 Jul 2026 17:42:16 +0000 (10:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 19 Jul 2026 17:42:16 +0000 (10:42 -0700)
The early-exit optimization in 'paint_down_to_common()' has been
gated on the queue being generation-ordered, fixing 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 3898d09dec4e8559fa6948fa3ae6ea683ce69f82,ee4b7b692508cf34eb7d89eb6d9960c53b4e42ad..d7221fe389c04627e1331ab226bc0d125eedfa96
@@@ -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