* Replicating the default "git log" format with a format string.
@ 2015-11-12 0:55 Kannan Goundan
2015-11-13 5:38 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Kannan Goundan @ 2015-11-12 0:55 UTC (permalink / raw)
To: git
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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Replicating the default "git log" format with a format string.
2015-11-12 0:55 Replicating the default "git log" format with a format string Kannan Goundan
@ 2015-11-13 5:38 ` Jeff King
2015-11-13 21:41 ` Jacob Keller
0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2015-11-13 5:38 UTC (permalink / raw)
To: Kannan Goundan; +Cc: git
On Thu, Nov 12, 2015 at 12:55:53AM +0000, Kannan Goundan wrote:
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Replicating the default "git log" format with a format string.
2015-11-13 5:38 ` Jeff King
@ 2015-11-13 21:41 ` Jacob Keller
2015-11-13 21:52 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Jacob Keller @ 2015-11-13 21:41 UTC (permalink / raw)
To: Jeff King; +Cc: Kannan Goundan, git
On Thu, Nov 12, 2015 at 9:38 PM, Jeff King <peff@peff.net> wrote:
>> 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
> --
Isn't this something that might be obtainable using the new ref-filter
work being done?
Regards,
Jake
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Replicating the default "git log" format with a format string.
2015-11-13 21:41 ` Jacob Keller
@ 2015-11-13 21:52 ` Jeff King
0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2015-11-13 21:52 UTC (permalink / raw)
To: Jacob Keller; +Cc: Kannan Goundan, git
On Fri, Nov 13, 2015 at 01:41:23PM -0800, Jacob Keller wrote:
> On Thu, Nov 12, 2015 at 9:38 PM, Jeff King <peff@peff.net> wrote:
> >> 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.
>
> Isn't this something that might be obtainable using the new ref-filter
> work being done?
It moves in the right direction, but it isn't enough. I don't recall the
specifics, but I think it has conditional placeholders for things like
"if this is non-empty print it". But there are still some problems:
- the ref-filter formatting isn't unified with the commit
pretty-printer formatting. So this wouldn't help for a traversal,
anyway.
- the decoration thing needs a new placeholder. "%d" means "always
show the decoration", but the OP really wants "show the decoration
if the user asked for decorations, and empty otherwise".
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-13 21:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-12 0:55 Replicating the default "git log" format with a format string Kannan Goundan
2015-11-13 5:38 ` Jeff King
2015-11-13 21:41 ` Jacob Keller
2015-11-13 21:52 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).