Re: [PATCH] diff-tree: do not show the sha1 of the given head with --quiet

5 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] diff-tree: do not show the sha1 of the given head with --quiet

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:05:51

Sebastian Schuberth [off-list ref] writes:
"--quite" is documented to "Disable all output of the program". Yet
calling diff-tree with a single commit like

$ git diff-tree --quiet c925fe2

was logging

c925fe23684455735c3bb1903803643a24a58d8f
At this point, unfortunately I think we need to call that a
documentation bug.  The "output" it refers to is output from the
"diff" portion, not the "poor-man's log" portion, of the program,
where diff-tree was the workhorse behind scripted "git log" that
gave the commit object name as the preamble for each commit it
shows information about.

Re: [PATCH] diff-tree: do not show the sha1 of the given head with --quiet

From: Sebastian Schuberth <hidden>
Date: 2016-06-15 23:05:51

On Wed, Jul 22, 2015 at 10:32 PM, Junio C Hamano [off-list ref] wrote:
quoted
"--quite" is documented to "Disable all output of the program". Yet
calling diff-tree with a single commit like

$ git diff-tree --quiet c925fe2

was logging

c925fe23684455735c3bb1903803643a24a58d8f
At this point, unfortunately I think we need to call that a
documentation bug.  The "output" it refers to is output from the
"diff" portion, not the "poor-man's log" portion, of the program,
where diff-tree was the workhorse behind scripted "git log" that
gave the commit object name as the preamble for each commit it
shows information about.
Well, from a user's perspective it does not matter which part of the
internal implementation of diff-tree is responsible for printing that
single line, a user would just expect "--quiet" to really mean
"quiet". As for almost any bug, we could turn it into a feature by
"fixing" the docs and claiming it's documented behavior. To me the
question simply is whether it makes sense for "--quiet" to not be
quiet, and I think it does not make sense. If you run diff-tree this
way there is no added value in the given output.

My use-case (also see [1]) is that I wanted to checked whether some
given commits change nothing but whitespace. So I did

if git diff-tree --quiet --ignore-space-change $commit; then
    echo "$commit only changes whitespace."
fi

just to see those SHA1s being printed to the console.

I probably could instead do

if git diff-tree --exit-code --ignore-space-change $commit > /dev/null
2>&1; then
    echo "$commit only changes whitespace."
fi

but that defeats the purpose of having "--quiet" in the first place.

[1] http://article.gmane.org/gmane.comp.version-control.git/273975

-- 
Sebastian Schuberth

Re: [PATCH] diff-tree: do not show the sha1 of the given head with --quiet

From: Jeff King <hidden>
Date: 2016-06-15 23:05:52

On Thu, Jul 23, 2015 at 09:06:01AM +0200, Sebastian Schuberth wrote:
My use-case (also see [1]) is that I wanted to checked whether some
given commits change nothing but whitespace. So I did

if git diff-tree --quiet --ignore-space-change $commit; then
    echo "$commit only changes whitespace."
fi

just to see those SHA1s being printed to the console.

I probably could instead do

if git diff-tree --exit-code --ignore-space-change $commit > /dev/null
2>&1; then
    echo "$commit only changes whitespace."
fi

but that defeats the purpose of having "--quiet" in the first place.
I have not been following the thread closely, but I do not recall seeing
anyone mention that the reason for the sha1-output is handing
only a single commit-ish to diff-tree is what puts it into its log-like
mode. Actually asking for a two-endpoint tree diff:

  git diff-tree --quiet --ignore-space-change $commit^ $commit

will do what you want.

I know that does not necessarily help the greater issue of "what
diff-tree is doing is confusing", but perhaps that sheds some light at
least on why it is doing what it is doing. :)

-Peff

Re: [PATCH] diff-tree: do not show the sha1 of the given head with --quiet

From: Sebastian Schuberth <hidden>
Date: 2016-06-15 23:05:52

On Thu, Jul 23, 2015 at 8:08 PM, Jeff King [off-list ref] wrote:
mode. Actually asking for a two-endpoint tree diff:

  git diff-tree --quiet --ignore-space-change $commit^ $commit

will do what you want.
Yes, I know, thanks. But I deliberately wanted to specify only a
single commit as an optimization, hoping that it would be slightly
faster than computing a commit range.

-- 
Sebastian Schuberth

Re: [PATCH] diff-tree: do not show the sha1 of the given head with --quiet

From: Jeff King <hidden>
Date: 2016-06-15 23:05:52

On Thu, Jul 23, 2015 at 10:02:27PM +0200, Sebastian Schuberth wrote:
On Thu, Jul 23, 2015 at 8:08 PM, Jeff King [off-list ref] wrote:
quoted
mode. Actually asking for a two-endpoint tree diff:

  git diff-tree --quiet --ignore-space-change $commit^ $commit

will do what you want.
Yes, I know, thanks. But I deliberately wanted to specify only a
single commit as an optimization, hoping that it would be slightly
faster than computing a commit range.
Ah, I see. It should not be any faster, as git has to internally find
the first-parent of $commit either way. The big thing you lose with the
above syntax is that you are specifying two endpoints, so you cannot do
anything clever with merge commits (e.g., if you gave "--cc").

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help