threads / discuss / 13043

diff-tree -r and new directories

Subject: diff-tree -r and new directories

## tl;dr

3 messages between Apr 10, 2008 and Apr 10, 2008.

replies: 2people: 2as markdown or json

Johannes Sixt· Apr 10, 2008, 06:29 UTC · lore
In one of my scriptlets I have this:
   git diff-tree -r --name-only --diff-filter=AM -z "$rev" HEAD --

and I had assumed that only files would ever be listed because of the -r switch. But this is not true: If there is a new directory, it lists only the directory's name instead of the files. Is this the intent? Is it worth changing?

-- Hannes
Junio C Hamano· Apr 10, 2008, 06:52 UTC · re: Johannes Sixt · lore

Re: diff-tree -r and new directories

Johannes Sixt <j.sixt@viscovery.net> writes:
Show 8 quoted lines
> In one of my scriptlets I have this:
>
>    git diff-tree -r --name-only --diff-filter=AM -z "$rev" HEAD --
>
> and I had assumed that only files would ever be listed because of the -r
> switch. But this is not true: If there is a new directory, it lists only
> the directory's name instead of the files. Is this the intent? Is it worth
> changing?
Hmm. you would need a better reproduction recipe than that.
    $ git init
    Initialized empty Git repository in .git/
    $ >file
    $ git add file
    $ git commit -a -m initial
    Created initial commit 2f9da65: initial
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 file
    $ mkdir new
    $ >new/file
    $ git add new/file
    $ git commit -a -m second
    Created commit a1fa8fb: second
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 new/file
    $ git diff-tree -r --name-only --diff-filter=AM -z HEAD^ HEAD |
      tr '\0' '\n'
    new/file
    $ git diff-tree --name-only --diff-filter=AM -z HEAD^ HEAD |
      tr '\0' '\n'
    new
Perhaps you somehow did not have "-r" even though you thought you had?
Johannes Sixt· Apr 10, 2008, 07:24 UTC · re: Junio C Hamano · lore

Re: diff-tree -r and new directories

Junio C Hamano schrieb:
Show 12 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> In one of my scriptlets I have this:
>>
>>    git diff-tree -r --name-only --diff-filter=AM -z "$rev" HEAD --
>>
>> and I had assumed that only files would ever be listed because of the -r
>> switch. But this is not true: If there is a new directory, it lists only
>> the directory's name instead of the files. Is this the intent? Is it worth
>> changing?
> 
> Hmm. you would need a better reproduction recipe than that.

Heh. It turns out that the questionable directory is actually versioned by git. My scriptlets have added it as a submodule while I looked in the other direction:

  $ git diff --summary $rev.. -- . | cat
  create mode 160000 D/Project/foo
:-) Problem solved. Thank you.
-- Hannes

← back to recent threads