# git-diff-tree --root

4 messages from 2014-09-12 to 2014-09-15. Participants: Roman Neuhauser, Junio C Hamano.
Thread: https://gitlist.dev/t/37543

## Roman Neuhauser, 2014-09-12 13:06

Subject: git-diff-tree --root
Message-ID: <20140912130607.GX4075@isis.sigpipe.cz>
URL: https://gitlist.dev/e/20140912130607.GX4075%40isis.sigpipe.cz

```
hello,

git-diff-tree without --root is absolutely silent for the root commit,
and i see no bad effects of --root on non-root commits.  are there any
hidden gotchas?  IOW, why is the --root behavior not the default?

cram[1] testcase::

  $ git init -q scratch
  $ cd scratch
  $ echo '.*.sw?' > .gitignore
  $ git add .gitignore
  $ git commit -q -m init .gitignore

  $ git diff-tree HEAD

  $ git diff-tree --root HEAD
  [0-9a-z]{40} (re)
  :000000 100644 0000000000000000000000000000000000000000 [0-9a-z]{40} A\\t.* (re)

[1] https://pypi.python.org/pypi/cram

-- 
roman

```

## Junio C Hamano, 2014-09-12 17:31

Subject: Re: git-diff-tree --root
Message-ID: <xmqq61gsbv9p.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq61gsbv9p.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20140912130607.GX4075@isis.sigpipe.cz>

```
Roman Neuhauser <neuhauser@sigpipe.cz> writes:

> git-diff-tree without --root is absolutely silent for the root commit,
> and i see no bad effects of --root on non-root commits.  are there any
> hidden gotchas?  IOW, why is the --root behavior not the default?

Because tools that was written before you proposed that change
expect to see nothing for the root commit, and then you are suddenly
breaking their expectations?

```

## Roman Neuhauser, 2014-09-13 08:57

Subject: Re: git-diff-tree --root
Message-ID: <20140913085735.GA4075@isis.sigpipe.cz>
URL: https://gitlist.dev/e/20140913085735.GA4075%40isis.sigpipe.cz
In-Reply-To: <xmqq61gsbv9p.fsf@gitster.dls.corp.google.com>

```
# gitster@pobox.com / 2014-09-12 10:31:30 -0700:
> Roman Neuhauser <neuhauser@sigpipe.cz> writes:
> > git-diff-tree without --root is absolutely silent for the root commit,
> > and i see no bad effects of --root on non-root commits.  are there any
> > hidden gotchas?  IOW, why is the --root behavior not the default?
> 
> Because tools that was written before you proposed that change
> expect to see nothing for the root commit, and then you are suddenly
> breaking their expectations?

i'm not proposing anything, i'm just curious why it is this way.
my line of thinking: there must be (or have been) a grave reason to
break the simple consistency, or the current behavior must be very
useful for something and i'm just missing what it is.  the reasons
for the behavior may have been invalidated by further developments,
or it may have been a wrong decision we're stuck with for BC; i'm
just curious about history.

motivation for my question is that i'm scripting git-diff-tree
and i need it to produce the diff for root commits as well.  i like
my scripts as simple as possible, so i'd like to use --root *always*.
is it safe?

-- 
roman

```

## Junio C Hamano, 2014-09-15 17:04

Subject: Re: git-diff-tree --root
Message-ID: <xmqqr3zc95o5.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqr3zc95o5.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20140913085735.GA4075@isis.sigpipe.cz>

```
Roman Neuhauser <neuhauser@sigpipe.cz> writes:

> ... I like
> my scripts as simple as possible, so I'd like to use --root *always*.

With "--root", the command does not do anything different without
for commits that are not root commits, and it shows "everything
created from nothing" for root commits.  The option was invented to
help those who want that behaviour, so if you'd like to use it
always, then you are welcome to do so ;-)

```
