Re: git log --pretty=format joins lines in the subject of commit message
- From
Jeff King <peff@peff.net>
- Date
- Sep 17, 2010, 14:55 UTC
- Message-ID
- <20100917145522.GB2860@sigill.intra.peff.net>
- In-Reply-To
- <4D8D88A4-FEBF-4FA9-A39F-410D76289E4B@jetbrains.com>
On Fri, Sep 17, 2010 at 03:56:53PM +0400, Kirill Likhodedov wrote:
> I think that if it is a feature, it should be reflected in the > documentation for custom pretty formats.
I agree it should be documented. I'm not sure where, though. The subject-munging affects more than just pretty formats. For example, at least git format-patch also has --keep-subjects to turn off munging. I guess a note should be made in a all relevant places.
> Anyway, that doesn't seem consistent enough: Git knows that the > subject is "first line\nsecond line\nthird line" (because it shows it > correctly in full or raw formats). Why does it join the lines in the > custom format's %s?
Because then the consumer of "git log --format=%s" knows that they will get exactly one line per commit.
The convention in git is to do "subject\n\nbody", with subject on a single line. However, we often see commits imported from other version control systems without this format. The subject-munging is an attempt to make them useful in git-aware tools (e.g., gitk or gitweb, which show the subject). Showing just the first line of a multi-line subject is often useless. People complained, and we got the behavior we have today.
-Peff