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

Re: [PATCH] for-each-ref: avoid segfault on --no-format

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2026, 22:10 UTC
Message-ID
<xmqqjymg9ycq.fsf@gitster.g>
In-Reply-To
<20261113161413.15688-1-agab0323@gmail.com>
aeron-gh <agab0323@gmail.com> writes:
Show 8 quoted lines
> The "--format" option is declared with OPT_STRING(), so the
> parse-options machinery also accepts "--no-format" and sets the
> format string to NULL. The default format is assigned before the
> command line is parsed, so nothing puts it back, and the NULL is
> dereferenced in verify_ref_format():
>
>     $ git for-each-ref --no-format
>     Segmentation fault

That is bad. PARSE_OPT_NONEG is necessary, I guess? Another plausible interpretation may be to exit without showing anything, but that does not sound like a very useful behaviour.

> Marking the option with PARSE_OPT_NONEG would also stop the crash,
> but then "--no-format" would work for "git branch" and "git tag"
> and be an error here.
Shouldn't "git branch --no-format" also error out?
> Signed-off-by: aeron-gh <agab0323@gmail.com>

Please check [[dco]] and [[real-name]] A few sections in Documentation/SubmittingPatches.

Thanks.
Previous: aeron-ghNext: Junio C Hamano
Message 2 of 6 in “for-each-ref: avoid segfault on --no-format”
  1. for-each-ref: avoid segfault on --no-formataeron-gh, Nov 13, 2026
  2. Junio C HamanoNov 13, 2026
  3. Junio C HamanoNov 13, 2026
  4. Abhishek AgarwalNov 14, 2026
  5. for-each-ref: avoid segfault on --no-formatAbhishek Agarwal, Nov 14, 2026
  6. Patrick SteinhardtNov 16, 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.