# [BUG] git diff-tree --stdin doesn't accept two trees

6 messages from 2008-08-05 to 2008-08-06. Participants: Karl Hasselström, Junio C Hamano.
Thread: https://gitlist.dev/t/14841

## Karl Hasselström, 2008-08-05 16:48

Subject: [BUG] git diff-tree --stdin doesn't accept two trees
Message-ID: <20080805164839.GA3934@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080805164839.GA3934%40diana.vm.bytemark.co.uk

```
I'm trying to use diff-tree --stdin to diff several trees in one go.
But I just get error messages when I feed it two space-separated trees
(one commit works fine):

  $ echo $(git rev-parse HEAD^{tree}) $(git rev-parse HEAD^^{tree}) | git diff-tree -p --stdin
  error: Object 7bfd9971f77438858e412be0219ec78afb3ca46f not a commit

This is at odds with the documentation:

  --stdin::
        When '--stdin' is specified, the command does not take
        <tree-ish> arguments from the command line.  Instead, it
        reads either one <commit> or a pair of <tree-ish>
        separated with a single space from its standard input.

I tried reading the code to figure out what's wrong, and as far as I
can tell the code to do this is there, but seems to be protected by
logic that aborts everything unless the whole input line is a valid
commit. Or maybe I'm just confused ...

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Junio C Hamano, 2008-08-05 20:07

Subject: Re: [BUG] git diff-tree --stdin doesn't accept two trees
Message-ID: <7vwsivusy2.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwsivusy2.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080805164839.GA3934@diana.vm.bytemark.co.uk>

```
Karl Hasselström <kha@treskal.com> writes:

> I'm trying to use diff-tree --stdin to diff several trees in one go.
> But I just get error messages when I feed it two space-separated trees
> (one commit works fine):
>
>   $ echo $(git rev-parse HEAD^{tree}) $(git rev-parse HEAD^^{tree}) | git diff-tree -p --stdin
>   error: Object 7bfd9971f77438858e412be0219ec78afb3ca46f not a commit
>
> This is at odds with the documentation:
>
>   --stdin::
>         When '--stdin' is specified, the command does not take
>         <tree-ish> arguments from the command line.  Instead, it
>         reads either one <commit> or a pair of <tree-ish>
>         separated with a single space from its standard input.
>
> I tried reading the code to figure out what's wrong, and as far as I
> can tell the code to do this is there, but seems to be protected by
> logic that aborts everything unless the whole input line is a valid
> commit. Or maybe I'm just confused ...

No, the documentation was made wrong during 1.2.0 timeperiod.

The feature of --stdin to take a commit and its parents on one line was
broken before that to support the common

	rev-list --parents $commits... -- $paths... |
        diff-tree --stdin -v -p

usage pattern by Porcelains.  For diff-tree to talk sensibly about
commits, it needs to see commits, not just trees.


 

```

## Junio C Hamano, 2008-08-06 05:32

Subject: [PATCH] fix diff-tree --stdin documentation
Message-ID: <7v7iauu2s3.fsf_-_@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v7iauu2s3.fsf_-_%40gitster.siamese.dyndns.org
In-Reply-To: <7vwsivusy2.fsf@gitster.siamese.dyndns.org>

```
Long time ago, the feature of "diff-tree --stdin" to take a commit and its
parents on one line was broken, and did not support the common:

    git rev-list --parents $commits... -- $paths... |
    git diff-tree --stdin -v -p

usage pattern by Porcelains properly.  For diff-tree to talk sensibly
about commits, it needs to see commits, not just trees; the code was fixed
to take list of commits on the standard input in 1.2.0.

However we left the documentation stale for a long time, until Karl
Hasselström finally noticed it very recently.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff --git a/Documentation/git-diff-tree.txt b/Documentation/git-diff-tree.txt
index 8c8f35b..1fdf20d 100644
--- a/Documentation/git-diff-tree.txt
+++ b/Documentation/git-diff-tree.txt
@@ -49,13 +49,13 @@ include::diff-options.txt[]
 --stdin::
 	When '--stdin' is specified, the command does not take
 	<tree-ish> arguments from the command line.  Instead, it
-	reads either one <commit> or a pair of <tree-ish>
+	reads either one <commit> or a list of <commit>
 	separated with a single space from its standard input.
 +
 When a single commit is given on one line of such input, it compares
 the commit with its parents.  The following flags further affects its
-behavior.  This does not apply to the case where two <tree-ish>
-separated with a single space are given.
+behavior.  The remaining commits, when given, are used as if they are
+parents of the first commit.
 
 -m::
 	By default, 'git-diff-tree --stdin' does not show

```

## Karl Hasselström, 2008-08-06 10:04

Subject: Re: [PATCH] fix diff-tree --stdin documentation
Message-ID: <20080806100450.GB18336@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080806100450.GB18336%40diana.vm.bytemark.co.uk
In-Reply-To: <7v7iauu2s3.fsf_-_@gitster.siamese.dyndns.org>

```
On 2008-08-05 22:32:28 -0700, Junio C Hamano wrote:

> -	reads either one <commit> or a pair of <tree-ish>
> +	reads either one <commit> or a list of <commit>

Thanks. Didn't quite solve my problem though, since diffing trees was
what I wanted to use diff-tree for. :-/ But I think I can rephrase my
problem so that I give it a commit instead.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Karl Hasselström, 2008-08-06 11:53

Subject: Re: [BUG] git diff-tree --stdin doesn't accept two trees
Message-ID: <20080806115358.GD18336@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080806115358.GD18336%40diana.vm.bytemark.co.uk
In-Reply-To: <7vwsivusy2.fsf@gitster.siamese.dyndns.org>

```
On 2008-08-05 13:07:17 -0700, Junio C Hamano wrote:

> Karl Hasselström <kha@treskal.com> writes:
>
> > I'm trying to use diff-tree --stdin to diff several trees in one
> > go. But I just get error messages when I feed it two
> > space-separated trees (one commit works fine):
>
> No, the documentation was made wrong during 1.2.0 timeperiod.
>
> The feature of --stdin to take a commit and its parents on one line was
> broken before that to support the common
>
>         rev-list --parents $commits... -- $paths... |
>                 diff-tree --stdin -v -p
>
> usage pattern by Porcelains.  For diff-tree to talk sensibly about
> commits, it needs to see commits, not just trees.

But is there any fundamental reason why it couldn't accept tree-ishes
as well? It only talks about commits if asked to do so with
command-line options.

Or would that break existing users somehow?

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Junio C Hamano, 2008-08-06 15:31

Subject: Re: [BUG] git diff-tree --stdin doesn't accept two trees
Message-ID: <7vbq06rwhq.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbq06rwhq.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080806115358.GD18336@diana.vm.bytemark.co.uk>

```
Karl Hasselström <kha@treskal.com> writes:

>> The feature of --stdin to take a commit and its parents on one line was
>> broken before that to support the common
>>
>>         rev-list --parents $commits... -- $paths... |
>>                 diff-tree --stdin -v -p
>>
>> usage pattern by Porcelains.  For diff-tree to talk sensibly about
>> commits, it needs to see commits, not just trees.
>
> But is there any fundamental reason why it couldn't accept tree-ishes
> as well?

The -v option given to diff-tree is the key.  Without it, it could take
trees.

```
