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

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
Previous: Kirill LikhodedovNext: nolan.ring@emc.com
Message 4 of 7 in “git log --pretty=format joins lines in the subject of commit message”
  1. Kirill LikhodedovSep 15, 2010
  2. Ævar Arnfjörð BjarmasonSep 15, 2010
  3. Kirill LikhodedovSep 17, 2010
  4. Jeff KingSep 17, 2010
  5. svn2git question: Build directory inserted at top level?nolan.ring@emc.com, Sep 15, 2010
  6. Daniel JohnsonSep 15, 2010
  7. Torgny NyblomSep 15, 2010

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.