public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH v2] revision: add --maximal-only option
Date: Thu, 22 Jan 2026 17:15:55 -0500	[thread overview]
Message-ID: <7daff220-f93a-463a-b586-dd876b51edae@gmail.com> (raw)
In-Reply-To: <xmqqikctl3vj.fsf@gitster.g>

On 1/22/2026 4:44 PM, Junio C Hamano wrote:
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>>     My motivation for this feature is very similar to the bundle URI
>>     application. I can get around it by creating a tool that uses git
>>     rev-list --parents and then uses a hashset to collect the parent list
>>     and filter out any commits that ever appear as parents. It would be more
>>     efficient to use Git's native revision-walking feature.
> 
> How does this relate to "git merge-base --independent", or do they
> compute completely different things?

This is the same idea, where among the merge bases, the ones that are
"maximal" to that set are the --independent ones. 
 
The documentation for --independent even uses similar language here:

  In other words, among the commits given, list those which cannot
  be reached from any other.

Unfortunately, it also says "print a minimal subset" which in some
sense is correct by "it cannot be made smaller without losing
information" but we actually choose the maximal set there, not a
minimal set.

The merge-base --independent calculation is basically asking for
the maximal set among commits in the intersection of two (or more)
commit histories. One trick the merge-base calculation does is
that it first looks for the --boundary commits, and then reduces
from within that set. This avoid walking further into the history
than necessary.

You are presenting interesting overlaps of terminology and needs.
One thing that is different about 'git rev-list --maximal-only' with
a list of starting commits is that it wants the maximal set from
the _union_ of the histories, instead of the _intersection_ like
'git merge-base --independent' does.

There is potential for a performance improvement if we converted
the search to be like a merge-base algorithm and checked the
priority queue to see if all elements have the CHILD_VISITED flag.
I think the cost here is that we would need more new logic and
would lose some expressiveness of 'git rev-list'.

For example, one of the applications I mentioned will require a
range request including negative refs, such as

  git rev-list --maximal-only --stdin <<-\EOF
  refs/heads/branch1
  refs/heads/branch2
  ^refs/heads/main
  ^refs/heads/release
  EOF

And this would likely return the tips of the two branches, but
also will detect if one already reaches the other or if one of
'main' or 'release' reaches one or both of them, excluding it
from the maximal set.

Thanks,
-Stolee

  reply	other threads:[~2026-01-22 22:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18  2:34 [PATCH] revision: add --maximal option Derrick Stolee via GitGitGadget
2026-01-18  9:05 ` Johannes Sixt
2026-01-18 18:27   ` Derrick Stolee
2026-01-19 11:15     ` Johannes Sixt
2026-01-19 16:44       ` Derrick Stolee
2026-01-19 19:05         ` Johannes Sixt
2026-01-20  0:22       ` Junio C Hamano
2026-01-22 15:08         ` Derrick Stolee
2026-01-22 16:05 ` [PATCH v2] revision: add --maximal-only option Derrick Stolee via GitGitGadget
2026-01-22 21:44   ` Junio C Hamano
2026-01-22 22:15     ` Derrick Stolee [this message]
2026-01-22 23:11       ` Junio C Hamano
2026-01-23  6:38       ` Johannes Sixt
2026-01-23 15:58         ` Junio C Hamano
2026-01-23 16:55           ` Derrick Stolee
2026-01-23 18:08             ` Junio C Hamano
2026-01-28 14:28               ` Derrick Stolee
2026-01-29  0:14                 ` Junio C Hamano
2026-01-29 14:57                   ` Derrick Stolee

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=7daff220-f93a-463a-b586-dd876b51edae@gmail.com \
    --to=stolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    /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