threads / discuss / 27016

git diff-tree output inconsistency?

Subject: git diff-tree output inconsistency?

## tl;dr

2 messages between Apr 7, 2011 and Apr 7, 2011.

replies: 1people: 2as markdown or json

Arjen Laarhoven· Apr 7, 2011, 13:59 UTC · lore
Hi all,

I was fiddling with the git-diff-tree command to retrieve a list of files which have in a commit:

$ git diff-tree --name-only HEAD

According to the documentation, the output starts with the SHA-1 of the tree-ish given, after which the list of changed files follows. This is the case when just one commit-id is given.

However, when given 2 tree-ish objects, the separate line with the SHA-1 is not shown.

I browsed through the code and the history for diff-tree.c, but couldn't find an explanation for the inconsistency. The documentation for the --no-commit-id confuses me a bit more, as it states that the commit id is shown 'when applicable'. Unfortunately, it fails to explain when exactly that is :-)

Have I found a documentation bug/shortcoming, is it a code bug or am I misunderstanding something else?

Arjen
-- 
Arjen Laarhoven

The presence of those seeking the truth is infinitely to be preferred to 
those who think they've found it.
                                -- Terry Pratchett, "Monstrous Regiment"
Jeff King· Apr 7, 2011, 19:08 UTC · re: Arjen Laarhoven · lore

Re: git diff-tree output inconsistency?

On Thu, Apr 07, 2011 at 03:59:38PM +0200, Arjen Laarhoven wrote:
Show 20 quoted lines
> I was fiddling with the git-diff-tree command to retrieve a list of
> files which have in a commit:
> 
> $ git diff-tree --name-only HEAD
> 
> According to the documentation, the output starts with the SHA-1 of the
> tree-ish given, after which the list of changed files follows.  This is
> the case when just one commit-id is given.
> 
> However, when given 2 tree-ish objects, the separate line with the SHA-1
> is not shown.
> 
> I browsed through the code and the history for diff-tree.c, but couldn't
> find an explanation for the inconsistency.  The documentation for the
> --no-commit-id confuses me a bit more, as it states that the commit id
> is shown 'when applicable'.  Unfortunately, it fails to explain when
> exactly that is :-)
> 
> Have I found a documentation bug/shortcoming, is it a code bug or am I
> misunderstanding something else?

I think it's a documentation bug. The sha1 is shown only when a single tree-ish is given (either on the command line, or via --stdin). This is a historical behavior, as one of the original uses of diff-tree was to implement log as:

  git rev-list | git diff-tree --stdin

You can even do "git diff-tree --stdin --pretty=medium" to get the full log-ish output. These days, though, log does everything in one process.

But I don't think we make that clear anywhere in the diff-tree manpage.
-Peff

← back to recent threads