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

Re: [PATCH v2] check-ref-format: use parse-options API

From
HSHussain Sitamouwala <husainsitamuwala21@gmail.com>
Date
Nov 9, 2026, 07:43 UTC
Message-ID
<20261109074352.163019-1-husainsitamuwala21@gmail.com>
In-Reply-To
<CAOLa=ZS3ULcNVjV1DMO-iB+LcC2Gnw+9oU2_7VXKoLvgiVRnbg@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
> Seems like Junio's review went unanswered. Which makes it hard for me
> to consider dedicating time to do another review of the newer version.
Hi Karthik, Junio,

Sorry about that. I sent v2 before replying to Junio's review of v1, and I should have discussed it first. I have now re-read Documentation/SubmittingPatches and MyFirstContribution, and I will wait for feedback before sending any further version.

> What is this change about?  More importantly, is it sensible to have
> this and ... another variable with very similar and confusing name

You are right, keeping two usage variables in sync made no sense. v2 has a single builtin_check_ref_format_usage[] array, and usage_with_options() is used for the error path, so the old string is gone.

> As can be seen in the usage string ... we still accept "--print" as
> a deprecated synonym but we do not advertise it.

In v2, --print is marked PARSE_OPT_HIDDEN and its help text says it is a deprecated synonym for --normalize.

> Do we want to barf when the user says
>
>     $ git check-ref-format --no-print --no-normalize
>       --no-refspec-pattern ...

No. v2 adds PARSE_OPT_NONEG to --normalize, --print and --refspec-pattern. Only --no-allow-onelevel is still accepted, as before, so the set of accepted options is unchanged.

> The call to show_usage_if_asked() is still here, which means
> "git check-ref-format -h" is intercepted ...

v2 drops that call, so "-h" now goes through parse_options() and the option list is generated from the table.

I also used PARSE_OPT_STOP_AT_NON_OPTION so that options placed after <refname> are still rejected, as they were before.

Two behavior differences come with parse_options(), both mentioned in the commit message: unambiguous abbreviations such as --norm are now accepted, and "--" may now precede <refname>. If either is unwanted, I am happy to change it. I ran t1402-check-ref-format.sh and it passes.

I will wait for further comments before preparing v3.

Thanks, Hussain Sitamouwala

Previous: Junio C Hamano
Message 6 of 6 in “check-ref-format: use parse-options API”
  1. check-ref-format: use parse-options APIHusain Sitamuwala via GitGitGadget, Oct 29, 2026
  2. Junio C HamanoOct 29, 2026
  3. check-ref-format: use parse-options APIHusain Sitamuwala via GitGitGadget, Nov 3, 2026
  4. Karthik NayakNov 3, 2026
  5. Junio C HamanoNov 3, 2026
  6. Hussain SitamouwalaNov 9, 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.