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

Re: [PATCH] pretty-format: add append line-feed format specifier

From
Jeff King <peff@peff.net>
Date
Sep 12, 2014, 04:49 UTC
Message-ID
<20140912044901.GC15519@peff.net>
In-Reply-To
<xmqqtx4fgzqe.fsf@gitster.dls.corp.google.com>
On Wed, Sep 10, 2014 at 10:19:21AM -0700, Junio C Hamano wrote:
Show 27 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Something like the patch below might work, but I didn't test it very
> > thoroughly (and note the comments, which might need dealing with). Maybe
> > it would make a sensible base for Harry to build on if he wants to
> > pursue this.
> >
> > With it, you can do:
> >
> >   git log --format='%h %s%if(%d,%n  Decoration:%d)' origin
> > ...
> > You could also make "%d" more flexible with it. We unconditionally
> > include the " (...)" wrapper when expanding it. But assuming we
> > introduced a "%D" that is _just_ the decoration names, you could do:
> >
> >   %if(%D, (%D))
> >
> > to get the same effect with much more flexibility.
> 
> Yup.
> 
> I do not think we need to go overboard to support nesting and stuff,
> let alone turing completeness ;-), especially when we are going to
> test the condition part only for emptyness.  Even with this simple
> patch, I sense that we are near a slipperly slope of wanting to add
> %unless(%d, ) or %ifelse(%d,%d, \(undefined\)), so I am not 100%
> convinced yet.

What compelled me is the fact that we already started down the slippery slope with %+ and friends. Providing conditionals but then only allowing certain characters seems weirdly limiting. But I guess it is all part of the same slope.

I dunno. I wrote that original set of lua pretty-format patches to try to stop the insanity once and for all. But I realized that I do not actually want to do anything complicated with the output formats, and "--oneline" and a few simple "--format" calls usually are enough. And if I do want more, I pipe it into a perl script (typically using --format to make it simple to parse).

We could also provide the data in some standard structured format like JSON to make the "pipe to your language of choice" option easier on people. But using custom --formats to do so is not that hard, and is way more efficient than dumping all of the data.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 10 in “pretty-format: add append line-feed format specifier”
  1. pretty-format: add append line-feed format specifierHarry Jeffery, Sep 9, 2014
  2. Junio C HamanoSep 9, 2014
  3. Harry JefferySep 9, 2014
  4. Junio C HamanoSep 9, 2014
  5. Jeff KingSep 9, 2014
  6. Harry JefferySep 9, 2014
  7. Jeff KingSep 9, 2014
  8. Junio C HamanoSep 10, 2014
  9. Jeff KingSep 12, 2014
  10. Junio C HamanoSep 12, 2014

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.