git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* rev-list pretty format behavior
@ 2015-04-04 23:27 Oliver Runge
  2015-04-05 21:12 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Runge @ 2015-04-04 23:27 UTC (permalink / raw)
  To: git

Heyup, everybody.

Apologies if this turns out to be a duplicate. Gmane seems broken, so
I couldn't search the archive.

I'm using git version 2.4.0-rc1. The same behavior exists in 2.1.0.

With git-log it is possible to specify a custom pretty format that
outputs one line per commit:
> git log --pretty=format:"%h ..." HEAD~3...HEAD
826aed5 ...
915e44c ...
067178e ...

Trying the same with rev-list results in:
> git rev-list --pretty=format:"%h ..." HEAD~3...HEAD
commit 826aed50cbb072d8f159e4c8ba0f9bd3df21a234
826aed5 ...
commit 915e44c6357f3bd9d5fa498a201872c4367302d3
915e44c ...
commit 067178ed8a7822e6bc88ad606b707fc33658e6fc
067178e ...

Is the separate line of "commit <hash>" a must for all formats except
"oneline" or a possible bug?
Based on the git-rev-list man page and git-log, I would expect to be
able to override the format as described, since it is possible to get
the "commit <hash>" line for any format by prefixing it with "commit
%H".

The only way to get similar behaviour is to do something like:
> git rev-list ... | grep -v '^commit'
and that's quite hacky.

I looked at the code and the flow in rev-list seems odd to me. The
header_prefix is set outside of show_commit(), it is empty for
format=oneline, but set to "commit " for any other formats. It's then
printed inside show_commit() and followed by the (possibly
abbreviated) hash. So the display logic is split into two places,
neither of which knows much about the other, both make decisions based
on the pretty format specified.

Even if the behavior is correct, would you agree that this could be
refactored a bit, so the output is less stitched together?
I'd happily try to help refactoring or fixing it, if it is indeed a bug.

Thanks for your ears!
  Oliver

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-08 17:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-04 23:27 rev-list pretty format behavior Oliver Runge
2015-04-05 21:12 ` Junio C Hamano
2015-04-06 11:05   ` Oliver Runge
2015-04-07 13:53     ` Michael J Gruber
2015-04-08 17:12       ` Oliver Runge

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).