Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Azuama Odinaka Maximus <azuama69@gmail.com>
Cc: git@vger.kernel.org,  tangajoris@gmail.com,
	pushkarkumarsingh1970@gmail.com,  christian.couder@gmail.com
Subject: Re: [PATCH v4] rev-list: handle arguments in early option scan
Date: Fri, 06 Nov 2026 10:18:59 -0800	[thread overview]
Message-ID: <xmqqa4nlkelo.fsf@gitster.g> (raw)
In-Reply-To: <CAPki72HBWEP8t9mu1zuKBA33SU1Oj-4bL4SQTqrn0G-H0P+g=g@mail.gmail.com> (Azuama Odinaka Maximus's message of "Fri, 6 Nov 2026 14:25:56 +0100")

Azuama Odinaka Maximus <azuama69@gmail.com> writes:

> I've investigated the relevant parsing paths further:
>
> 1. Revision options are handled by handle_revision_opt() in
> revision.c. It already determines argument consumption through helpers
> such as parse_long_opt(), which returns whether an option uses an
> attached or separate argument. However, the function also applies the
> option's effects to struct rev_info, so calling it again purely to
> determine argument consumption would be unsafe.

Correct.  There is no dry-run mode for this.

> 2. Revision pseudo-options are handled separately by
> handle_revision_pseudo_opt().

Yes, this is called from various code paths.  No dry-run, either.

> 3. Diff-merge options are handled by diff_merges_parse_opts() in diff-merges.c.
>
> 4. Diff options are defined through add_diff_options() in diff.c,
> which provides an existing struct option table. This includes options
> such as --src-prefix and --dst-prefix.

Correct.  I do not think there is any dry-run to any of these.

I am not sure if the above is exhausitve, though.  I didn't check.

> This suggests that the early scan needs to obtain argument-consumption
> information from the same option definitions or recognition logic used
> by normal parsing, rather than maintaining another list of option
> names.

It is what the NEEDSWORK comment boils down to, I think.  I do not
see how the above survey helps with that conclusion, though.

> One direction I'm considering is separating option recognition and
> argument consumption from option application, so that the early scan
> and normal parser can share the recognition logic without executing
> parsing side effects twice.
>
> I have not settled on the implementation yet, particularly how best to
> accommodate the hand-written revision and diff-merge parsers alongside
> the diff option table.
>
> Would you consider this a reasonable direction? Or do you see an
> existing Git parser interface or abstraction that would be preferable
> to extend for this purpose?

All of the above assumes that we want to keep a separate "early
scan", but I wonder if that is really a good direction to go.  If
you can clearly identify the problem the "early scan" wanted to
solve, and can come up with a way to solve that problem without
scanning the list of arguments twice (i.e., not involving an "early
scan" at all), would that give you a cleaner implementation?

If the default of an option (is it '.fetch_if_missing' alone, or are
there many other settings involved?) needs to depend on other
options, perhaps fixing it is simpler if the presence of an explicit
option that sets '.fetch_if_missing' is recorded in a separate
member of the struct, and then at the very end after all the command
line options have been seen, take these other options and the
explicit option setting for it into account to synthesize the
result?  If '.fetch_if_missing' was explicitly set from what the
user said from the command line, there is no need to look at any
other options, and if not, then the settings left by parsing other
options that the misdesigned "early scan" pays attention to can be
consulted to decide what the desirable value should be.

Just thinking out loud.  It seems that this started at df11e19648
(rev-list: support termination at promisor objects, 2017-12-08), and
then other needs may have been piled on top, but going back to that
original commit may be a good place to start understanding and
reevaluating if the "early scan" was the best approach to solve
whatever problem it was trying to solve.

> Thanks again for the guidance.
>
> On Fri, 6 Nov 2026 at 01:36, Junio C Hamano <gitster@pobox.com> wrote:

Never top-post.

      reply	other threads:[~2026-11-06 18:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 15:12 [PATCH] rev-list: skip --grep argument in early scan Azuama Odinaka Maximus
2026-10-21 15:42 ` Pushkar Singh
2026-10-21 17:24 ` [PATCH v2] " Azuama Odinaka Maximus
2026-10-22 13:45   ` Pushkar Singh
2026-10-23 18:14   ` Junio C Hamano
2026-10-26  8:30   ` [PATCH v3] " Azuama Odinaka Maximus
2026-11-05  7:53     ` Tanga Joris
2026-11-05 12:09       ` [PATCH v4] rev-list: handle arguments in early option scan Azuama Odinaka Maximus
2026-11-06  0:36         ` Junio C Hamano
2026-11-06 13:25           ` Azuama Odinaka Maximus
2026-11-06 18:18             ` Junio C Hamano [this message]

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=xmqqa4nlkelo.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=azuama69@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pushkarkumarsingh1970@gmail.com \
    --cc=tangajoris@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