All of lore.kernel.org
 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: Thu, 05 Nov 2026 16:36:16 -0800	[thread overview]
Message-ID: <xmqqwlqqokxr.fsf@gitster.g> (raw)
In-Reply-To: <20261105120937.10269-1-azuama69@gmail.com> (Azuama Odinaka Maximus's message of "Thu, 5 Nov 2026 13:09:36 +0100")

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

> The early option scan in cmd_rev_list() looks for options that
> affect missing-object handling before setup_revisions() parses the
> command line. It must not interpret an option's separate argument
> as another option.
>
> Use parse_long_opt() to recognize revision options that take
> separate arguments, and skip those arguments. Handle -n and
> --default as well. Stop scanning at --, where subsequent arguments
> are pathspecs.
>
> Add tests to ensure that --grep and --author arguments beginning
> with -- are not mistaken for options during the early scan.

The commit log message explains the motivation well, and the attempt
to address the feedback from the previous round by handling all 19
options from revision.c is appreciated.

But the approach of hardcoding an array of option strings that take
arguments is inherently fragile and scales poorly.  By duplicating
parser knowledge into the early scan, this patch falls into the
exact trap described by the NEEDSWORK comment just below it.

> diff --git a/builtin/rev-list.c b/builtin/rev-list.c
> index 071a0e3cb5..4dd646050a 100644
> --- a/builtin/rev-list.c
> +++ b/builtin/rev-list.c
> @@ -744,6 +744,47 @@ static void prepare_maximal_independent(struct rev_info *revs)
>  	revs->no_walk = 1;
>  }
>  
> +static int rev_list_option_takes_argument(const char **argv)
> +{
> +	static const char * const options[] = {
> +		"max-count",
> +		"max-count-oldest",
> +		"skip",
> +		"max-age",
> +		"since",
> +		"since-as-filter",
> +		"after",
> +		"min-age",
> +		"before",
> +		"until",
> +		"date",
> +		"author",
> +		"committer",
> +		"grep-reflog",
> +		"grep",
> +		"encoding",
> +		"glob",
> +		"exclude",
> +		"exclude-hidden",
> +	};

Is this hardcoded list complete?  It misses options parsed via
diff_merges_parse_opts() in diff-merges.c (e.g., --diff-merges), as
well as options handled in diff.c (e.g., --src-prefix and
--dst-prefix), which also take separate arguments and are accepted
by git rev-list.  Would

    $ git rev-list --src-prefix --missing-only HEAD

take --missing-only as an extra option or a prefix?

Thanks.

  reply	other threads:[~2026-11-06  0:36 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 [this message]
2026-11-06 13:25           ` Azuama Odinaka Maximus
2026-11-06 18:18             ` 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=xmqqwlqqokxr.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.