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

Re: [RFC PATCH 1/1] for-each-ref: do not output empty lines

From
Jeff King <peff@peff.net>
Date
Sep 10, 2019, 16:35 UTC
Message-ID
<20190910163541.GA13873@sigill.intra.peff.net>
In-Reply-To
<xmqqpnk8heow.fsf@gitster-ct.c.googlers.com>
On Mon, Sep 09, 2019 at 11:02:07PM -0700, Junio C Hamano wrote:
Show 24 quoted lines
> Eric Freese <ericdfreese@gmail.com> writes:
> 
> > If the format string expands to an empty string for a given ref, do not
> > print the empty line.
> >
> > This is helpful when wanting to print only certain kinds of refs that
> > you can't already filter for.
> 
> We tend to prefer stating the reason why we want to do so first and
> then give a command to the codebase to "become like so".  Here is to
> illustrate how you would do it:
> 
>     The custom format specifier "--format=<format>" can be used to
>     tell the for-each-ref command to say nothing for certain kind of
>     refs, e.g.
> 
>        --format="%(if)%(symref)%(then)%(else)%(refname)%(end)"
> 
>     may be used to show the refname only for refs that are not
>     symbolic refs.  Except that the command still would show one
>     blank line per each symbolic ref, which is fairly useless.
> 
>     Introduce the `--omit-empty-lines` option to squelch these
>     useless lines from the output.

Your proposed commit message (and the suggested code below) have a command-line option, but Eric's patch does it by default. Which do we want? :)

I'm inclined to say that this new behavior should be the default; even though it's technically a compatibility change, I find it hard to imagine people would see it as a regression.

But we could also introduce "--omit-empty-lines", and then flip the default. That gives an escape hatch of "--no-omit-empty-lines", at the minor cost of having to carry an option that we assume nobody would ever use.

-Peff
Previous: Junio C Hamano
Message 5 of 5 in “for-each-ref: do not output empty lines”
  1. 0/1 for-each-ref: do not output empty linesEric Freese, Sep 10, 2019
  2. 1/1 for-each-ref: do not output empty linesEric Freese, Sep 10, 2019
  3. Junio C HamanoSep 10, 2019
  4. Junio C HamanoSep 10, 2019
  5. Jeff KingSep 10, 2019

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.