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

Make "terminator behavior" the default with --pretty=format: ?

From
Hrvoje Nikšić <hniksic@gmail.com>
Date
Feb 22, 2011, 15:43 UTC
Message-ID
<AANLkTimFYsG3x0uGX32Ozo6C_shHd4k8jnXNhYmy7Q80@mail.gmail.com>

Is there a reason, other than backward compatibility, for "--prety=format:" to have separator rather than terminator semantics?

I got bitten by this badly today, because I was processing the output of git log --pretty=format:... through sh, like this:

    git log --pretty=format:"%H %an" $old..$new | (
        while read commit author; do
           ... some processing ...
        done
    )

It turns out that the sh (which includes bash, dash, and zsh) "read" built-in doesn't process lines that don't end in newline. The effect was that the last line of output was silently ignored. It took some hours to track down.

sh is not the only tool with this problem; many traditional Unix tools don't process lines that don't end with newlines, and some require special exceptions and kludges (think diff). Because of this I believe "format:" should be changed to do terminator semantics, and tformat deprecated. If this is not feasible, then the documentation should recommend "tformat:", and only mention "format" as an afterthought, rather than the other way around.

Next: Will Palmer
Message 1 of 4 in “Make "terminator behavior" the default with --pretty=format: ?”
  1. Hrvoje NikšićFeb 22, 2011
  2. Will PalmerFeb 22, 2011
  3. Hrvoje NikšićFeb 22, 2011
  4. Jay SoffianFeb 22, 2011

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.