git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4] rev-list: handle arguments in early option scan

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 6, 2026, 00:36 UTC
Message-ID
<xmqqwlqqokxr.fsf@gitster.g>
In-Reply-To
<20261105120937.10269-1-azuama69@gmail.com>
Azuama Odinaka Maximus <azuama69@gmail.com> writes:
Show 12 quoted lines
> 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.

Show 31 quoted lines
> 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.
Previous: Azuama Odinaka MaximusNext: Azuama Odinaka Maximus
Message 9 of 11 in “rev-list: skip --grep argument in early scan”
  1. rev-list: skip --grep argument in early scanAzuama Odinaka Maximus, Oct 21, 2026
  2. Pushkar SinghOct 21, 2026
  3. rev-list: skip --grep argument in early scanAzuama Odinaka Maximus, Oct 21, 2026
  4. Pushkar SinghOct 22, 2026
  5. Junio C HamanoOct 23, 2026
  6. rev-list: skip --grep argument in early scanAzuama Odinaka Maximus, Oct 26, 2026
  7. Tanga JorisNov 5, 2026
  8. rev-list: handle arguments in early option scanAzuama Odinaka Maximus, Nov 5, 2026
  9. Junio C HamanoNov 6, 2026
  10. Azuama Odinaka MaximusNov 6, 2026
  11. Junio C HamanoNov 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.