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

Re: Simplify '--prett=xyz' options

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Aug 15, 2009, 20:36 UTC
Message-ID
<alpine.LFD.2.01.0908151324380.3162@localhost.localdomain>
In-Reply-To
<7viqgoestz.fsf@alter.siamese.dyndns.org>
On Sat, 15 Aug 2009, Junio C Hamano wrote:
Show 8 quoted lines
> 
> If you try that without --stat, i.e.
> 
>     $ git log -4 --pretty=format:%s | cat -e
>     $ git log -4 --pretty=tformat:%s | cat -e
> 
> I suspect you may then find that --pretty=format (not --pretty=tformat) is
> broken.

I disagree. The real brokenness is that we don't have any way to say "I want no newline at all after the format", and then having this mixup with the whole "terminator" thing - sometimes it's "between commits" (which is _correct_ any time you have stat info or something), and sometimes it's "after header" (which is almost always incorrect).

For an example of this, try to do a one-line format that shows the diffstat on the same line. IOW, what you really want is something like

	git log -4 --shortstat --format=%s%NOTERM

but you can't do it at all right now - and defaulting to the "tformat" thing is actually _worse_.

So I do agree that "format" is broken and confused. I just think that "tformat" is EVEN MORE broken and confused, it just happens to fix that one form of brokenness that "format" has.

Notice how "CMIT_FMT_ONELINE" use the "use_terminator" (like tformat), but then does things right (unlike tformat). In particular, it's this one:

        pp_header(fmt, abbrev, dmode, encoding, commit, &msg, sb);
        if (fmt != CMIT_FMT_ONELINE && !subject) {
                strbuf_addch(sb, '\n');
        }       
	..
        /* Make sure there is an EOLN for the non-oneline case */
        if (fmt != CMIT_FMT_ONELINE)
                strbuf_addch(sb, '\n');
and notice how we have no way to edit those from the "format" descriptors.
			Linus
Previous: Junio C HamanoNext: Avery Pennarun
Message 5 of 9 in “Simplify '--prett=xyz' options”
  1. Linus TorvaldsAug 15, 2009
  2. Thomas RastAug 15, 2009
  3. Linus TorvaldsAug 15, 2009
  4. Junio C HamanoAug 15, 2009
  5. Linus TorvaldsAug 15, 2009
  6. Avery PennarunAug 15, 2009
  7. Linus TorvaldsAug 15, 2009
  8. Linus TorvaldsAug 15, 2009
  9. Johannes SchindelinAug 15, 2009

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.