Subject: Re: [PATCH v2] log: if --decorate is not given, default to --decorate=auto

From: Junio C Hamano <[email-masked]>
Date: Thu, 30 Mar 2017 14:54:57 -0700

Jeff King <[email-masked]> writes:

> On Thu, Mar 30, 2017 at 11:03:51AM -0700, Junio C Hamano wrote:
>
>> With the "--decorate=auto" option becoming the default for "git
>> log", "git tbdiff" will be broken.
>> ...
> I'm confused. I thought "auto" would kick in only when we are outputting
> to a terminal. Or is the problem that the "is it a terminal" check is
> fooled by $GIT_PAGER_IN_USE, because you are running "git -p tbdiff"?

Interesting.  Yes, I do use 

    [pager]
	tbdiff

in my ~/.gitconfig file.

    $ git tbdiff ..@{-1} @{-1}..

is one of the most frequently used commands in my ~/.bash_history
these days [*1*].  I by accident has been running the 'master'
version (not my private edition 'jch' that is a bit ahead of 'next')
for the past few weeks, and I just switched back to using the 'jch'
version so that I can say

    $ git tbdiff ..- -..

instead, and that is when I noticed we broke "tbdiff".

> If so, this is the symptom of a more general problem, which is that
> a script outputting to a pager will have confused sub-processes, who do
> not know if their pipe is the pager one or not. Perhaps it is time to
> resurrect my patch from:
>
>   http://public-inbox.org/git/[email-masked]/
>
> I think it would need a Windows-specific variant, but the general idea
> is sound.

Yes, that might be necessary.

[Footnote]

*1* The general flow to accept a reroll of a topic "au/topic" goes
    like this:

    $ git checkout au/topic
    $ git log master.. ;# to remind me what it was about
    $ git checkout master... ;# to go back to the original base
    $ Meta/CP ./+au-topic.mbox ;# run checkpatch
    $ git am -s3c
    $ git tbdiff ..@{-1} @{-1}..

    Then if the initial N patches are identical, e.g. when the
    output of tbdiff begins like this:

     1: f6d8dfd8b6 =  1: d681cf5ada do not check odb_mkstemp return value for errors
     2: 52dcad2c2e =  2: abf30edce4 odb_mkstemp: write filename into strbuf
     3: 033d6ae6cb =  3: 38fceca547 odb_mkstemp: use git_path_buf
     4: 55e3179076 !  4: 344267b632 diff: avoid fixed-size buffer for patch-ids
        @@ ... @@

    $ git rebase --onto 033d6ae6cb 38fceca547
    $ git tbdiff ..@{-1} @{-1}..

    That way, I can preserve the author and committer timestamps of
    the earlier part that did not change.