git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: diff-tree -r and new directories

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 10, 2008, 06:52 UTC
Message-ID
<7v1w5eyzeh.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<47FDB3DB.8020705@viscovery.net>
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?
Previous: Johannes SixtNext: Johannes Sixt
Message 2 of 3 in “diff-tree -r and new directories”
  1. Johannes SixtApr 10, 2008
  2. Junio C HamanoApr 10, 2008
  3. Johannes SixtApr 10, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.