All of lore.kernel.org
 help / color / mirror / Atom feed
* Make "terminator behavior" the default with --pretty=format: ?
@ 2011-02-22 15:43 Hrvoje Nikšić
  2011-02-22 16:43 ` Will Palmer
  0 siblings, 1 reply; 4+ messages in thread
From: Hrvoje Nikšić @ 2011-02-22 15:43 UTC (permalink / raw)
  To: git

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.

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

* Re: Make "terminator behavior" the default with --pretty=format: ?
  2011-02-22 15:43 Make "terminator behavior" the default with --pretty=format: ? Hrvoje Nikšić
@ 2011-02-22 16:43 ` Will Palmer
  2011-02-22 16:51   ` Hrvoje Nikšić
  0 siblings, 1 reply; 4+ messages in thread
From: Will Palmer @ 2011-02-22 16:43 UTC (permalink / raw)
  To: Hrvoje Nikšić; +Cc: git

On Tue, 2011-02-22 at 16:43 +0100, Hrvoje Nikšić wrote:
> Is there a reason, other than backward compatibility, for
> "--prety=format:" to have separator rather than terminator semantics?
> 

The "default behaviour" is the behaviour which occurs when one /doesn't/
specify something. For example: --pretty="%H %an" uses terminator
semantics.

I agree that --pretty=sformat: might be less ambiguous, though.

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

* Re: Make "terminator behavior" the default with --pretty=format: ?
  2011-02-22 16:43 ` Will Palmer
@ 2011-02-22 16:51   ` Hrvoje Nikšić
  2011-02-22 22:41     ` Jay Soffian
  0 siblings, 1 reply; 4+ messages in thread
From: Hrvoje Nikšić @ 2011-02-22 16:51 UTC (permalink / raw)
  Cc: git

On Tue, Feb 22, 2011 at 5:43 PM, Will Palmer <wmpalmer@gmail.com> wrote:
> On Tue, 2011-02-22 at 16:43 +0100, Hrvoje Nikšić wrote:
>> Is there a reason, other than backward compatibility, for
>> "--prety=format:" to have separator rather than terminator semantics?
>
> The "default behaviour" is the behaviour which occurs when one /doesn't/
> specify something. For example: --pretty="%H %an" uses terminator
> semantics.

I didn't know that you could simply omit the "format:". Is it
documented anywhere? The docs say:

       --pretty[=<format>], --format[=<format>]
           Pretty-print the contents of the commit logs in a given
format, where <format> can be one of oneline, short,
           medium, full, fuller, email, raw and format:<string>. When
omitted, the format defaults to medium.

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

* Re: Make "terminator behavior" the default with --pretty=format: ?
  2011-02-22 16:51   ` Hrvoje Nikšić
@ 2011-02-22 22:41     ` Jay Soffian
  0 siblings, 0 replies; 4+ messages in thread
From: Jay Soffian @ 2011-02-22 22:41 UTC (permalink / raw)
  To: Hrvoje Nikšić; +Cc: git

On Tue, Feb 22, 2011 at 11:51 AM, Hrvoje Nikšić <hniksic@gmail.com> wrote:
> On Tue, Feb 22, 2011 at 5:43 PM, Will Palmer <wmpalmer@gmail.com> wrote:
>> On Tue, 2011-02-22 at 16:43 +0100, Hrvoje Nikšić wrote:
>>> Is there a reason, other than backward compatibility, for
>>> "--prety=format:" to have separator rather than terminator semantics?
>>
>> The "default behaviour" is the behaviour which occurs when one /doesn't/
>> specify something. For example: --pretty="%H %an" uses terminator
>> semantics.
>
> I didn't know that you could simply omit the "format:". Is it
> documented anywhere? The docs say:
>
>       --pretty[=<format>], --format[=<format>]
>           Pretty-print the contents of the commit logs in a given
> format, where <format> can be one of oneline, short,
>           medium, full, fuller, email, raw and format:<string>. When
> omitted, the format defaults to medium.

In the tformat section is:

 "In addition, any unrecognized string that has a % in it is
interpreted as if it has tformat: in front of it."

Of course, you need to know to read that far into the man page to find
that sentence, and the earlier summary of --pretty never gives any
hint to do so.

Mind submitting a documentation patch?

j.

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

end of thread, other threads:[~2011-02-22 22:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22 15:43 Make "terminator behavior" the default with --pretty=format: ? Hrvoje Nikšić
2011-02-22 16:43 ` Will Palmer
2011-02-22 16:51   ` Hrvoje Nikšić
2011-02-22 22:41     ` Jay Soffian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.