From: Junio C Hamano <gitster@pobox.com>
To: "Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Derrick Stolee <stolee@gmail.com>,
Kristofer Karlsson <krka@spotify.com>
Subject: Re: [PATCH 2/2] commit-reach: guard !FIND_ALL early exit with generation ordering check
Date: Wed, 08 Jul 2026 10:24:33 -0700 [thread overview]
Message-ID: <xmqqjyr5v1gu.fsf@gitster.g> (raw)
In-Reply-To: <ba3f2bb6e8463eb2f101ebf5c7d8d83d353731a2.1782739162.git.gitgitgadget@gmail.com> (Kristofer Karlsson via GitGitGadget's message of "Mon, 29 Jun 2026 13:19:21 +0000")
"Kristofer Karlsson via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Kristofer Karlsson <krka@spotify.com>
>
> When paint_down_to_common() falls back to commit-date ordering (for
> v1 commit graphs without corrected commit dates), the !FIND_ALL early
> exit incorrectly fires. The exit assumes the queue is generation-
> ordered, so the first RESULT commit found must be the shallowest.
> With date ordering this is not guaranteed: a closer merge base with
> a lower committer date (clock skew) may still be in the queue behind
> deeper commits.
Excellent description of a good observation.
> Add a gen_ordered flag that is cleared when the date fallback fires,
> and require it for the early exit.
The solution is simple and straight-forward.
The flag is initialized to true but we drop it when generation order
is not in effect, and the early exit requires the flag to be still
true.
> Update the test from the previous commit to test_expect_success.
>
> Signed-off-by: Kristofer Karlsson <krka@spotify.com>
> ---
Let's mark it for 'next'. Thanks.
> commit-reach.c | 10 +++++++---
> t/t6600-test-reach.sh | 2 +-
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/commit-reach.c b/commit-reach.c
> index 5df471a313..708798a39b 100644
> --- a/commit-reach.c
> +++ b/commit-reach.c
> @@ -108,11 +108,14 @@ static int paint_down_to_common(struct repository *r,
> { 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.pq.compare = compare_commits_by_commit_date;
> + gen_ordered = 0;
> + }
>
> one->object.flags |= PARENT1;
> if (!n) {
> @@ -147,11 +150,12 @@ static int paint_down_to_common(struct repository *r,
> commit->object.flags |= RESULT;
> tail = commit_list_append(commit, tail);
> /*
> - * The queue is generation-ordered; no
> - * remaining common ancestor can be a
> + * When the queue is generation-ordered,
> + * no remaining common ancestor can be a
> * descendant of this one.
> */
> if (!(mb_flags & MERGE_BASE_FIND_ALL) &&
> + gen_ordered &&
> generation < GENERATION_NUMBER_INFINITY)
> break;
> }
> diff --git a/t/t6600-test-reach.sh b/t/t6600-test-reach.sh
> index 1090104220..0ff41381ff 100755
> --- a/t/t6600-test-reach.sh
> +++ b/t/t6600-test-reach.sh
> @@ -1003,7 +1003,7 @@ test_expect_success 'merge-base without --all is one of --all results' '
> grep -F -f single all
> '
>
> -test_expect_failure 'merge-base without --all, clock skew, v1 commit-graph' '
> +test_expect_success 'merge-base without --all, clock skew, v1 commit-graph' '
> git rev-parse skew-M2 >expect &&
> merge_base_all_modes skew-P1 skew-P2
> '
next prev parent reply other threads:[~2026-07-08 17:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 13:19 [PATCH 0/2] commit-reach: fix !FIND_ALL early exit with v1 commit graph Kristofer Karlsson via GitGitGadget
2026-06-29 13:19 ` [PATCH 1/2] t6600: add test for merge-base early exit with clock skew Kristofer Karlsson via GitGitGadget
2026-06-29 13:19 ` [PATCH 2/2] commit-reach: guard !FIND_ALL early exit with generation ordering check Kristofer Karlsson via GitGitGadget
2026-07-08 17:24 ` Junio C Hamano [this message]
2026-06-29 17:50 ` [PATCH 0/2] commit-reach: fix !FIND_ALL early exit with v1 commit graph Junio C Hamano
2026-06-29 18:27 ` Kristofer Karlsson
2026-06-29 18:52 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqjyr5v1gu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=krka@spotify.com \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox