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

Re: Replicating the default "git log" format with a format string.

From
Jeff King <peff@peff.net>
Date
Nov 13, 2015, 05:38 UTC
Message-ID
<20151113053800.GE29708@sigill.intra.peff.net>
In-Reply-To
<loom.20151112T011419-749@post.gmane.org>
On Thu, Nov 12, 2015 at 12:55:53AM +0000, Kannan Goundan wrote:
Show 22 quoted lines
> For our workflow, author dates aren't very useful.  I'm looking for a way to
> configure Git so that "git log" shows commit dates instead of author dates.
>  "--pretty=fuller" gets me almost what I want, but I'd like to avoid the
> extra two lines if possible.
> 
> I tried achieving this by putting a custom format string in ~/.gitconfig:
> 
> [format]
>   pretty = "%C(auto,yellow)commit %C(auto)%H\nAuthor: %an <%ae>\nDate:  
> %cd\n\n%w(0,4,4)%B"
> 
> This works pretty well, but has a few corner cases.  When you do "git log
> --decorate", the default format decorates commits with ref names.  I can add
> "%d" to my format string, but then the ref names show up all the time, even
> without "--decorate".
> 
> The "--walk-reflogs" option presents a similar problem.  The %g*
> placeholders all become empty strings when "--walk-reflogs" isn't present,
> which is sort of what I want, but it leaves extra blank lines in the output.
> 
> Is it possible to exactly replicate the default "git log" format with a
> format string?

Sadly, no, I don't think it is possible with the current format specifiers. It would be nice if it was, though.

-Peff
Previous: Kannan GoundanNext: Jacob Keller
Message 2 of 4 in “Replicating the default "git log" format with a format string.”
  1. Kannan GoundanNov 12, 2015
  2. Jeff KingNov 13, 2015
  3. Jacob KellerNov 13, 2015
  4. Jeff KingNov 13, 2015

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.