A patch from aeron-gh fixes a segmentation fault in git for-each-ref --no-format. The --format option is declared with OPT_STRING(), so parse-options also accepts --no-format and sets the format string to NULL. The default format is assigned before parsing, so nothing restores it and verify_ref_format() dereferences NULL. git refs list shares the code and crashes the same way. The problem dates to c3428da87f (2007).

git branch and git tag have the same option and fall back to their default format when it is NULL. The patch does the same for for-each-ref by assigning the default after parsing when no format is set. Abhishek Agarwal confirmed the code path and said a new test checks that --format=<fmt> --no-format prints the same as no option.

Junio C Hamano first said that making --no-format mean "revert to the default" in for-each-ref may make sense, since git branch --no-format already works that way and its implementation is clean. In a later message he asked whether PARSE_OPT_NONEG is needed instead, and whether git branch --no-format should also error out. He thought exiting silently would not be a useful behaviour.

Junio also asked the author to check the DCO and real-name sections of SubmittingPatches. Abhishek said a v2 would fix the name in the sign-off but that he planned no code change unless something else turned up. Whether --no-format ends up as the default format or an error is not settled in these excerpts.