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

Diff-tree does not work for initial commit

From
Anatol Pomozov <anatol.pomozov@gmail.com>
Date
Sep 15, 2008, 20:01 UTC
Message-ID
<3665a1a00809151301p7d8e6387g3cacfb879b45da2f@mail.gmail.com>
Hi, It looks like I found a bug in git.

The problem: In my script I need to know what files were modified by given commit. I use diff-tree for it. Although it works for most cases, for initial commit it does not. Here is a sequence of actions.

anatol:~ $ mkdir mkdir initialcommitissue
anatol:~ $ cd initialcommitissue/
anatol:initialcommitissue $ git init
Initialized empty Git repository in /home/anatol/initialcommitissue/.git/
anatol:initialcommitissue $ echo "First commit" > 1.txt
anatol:initialcommitissue $ git add 1.txt
anatol:initialcommitissue $ git commit -m "First commit"
Created initial commit 31ccc6a: First commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 1.txt
anatol:initialcommitissue $ git diff-tree HEAD     <<<<< PROBLEM IS HERE
anatol:initialcommitissue $ echo "Second commit" > 2.txt
anatol:initialcommitissue $ git add 2.txt
anatol:initialcommitissue $ git commit -m "Second commit"
Created commit 51e8bcb: Second commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 2.txt
anatol:initialcommitissue $ git diff-tree HEAD
51e8bcbb739fc8329fc092db7a84b02bbc64feb2
:000000 100644 0000000000000000000000000000000000000000
c133ee6afb86d836ae607cc12e7b7b42242aa5fa A	2.txt

so git diff-tree HEAD works fine but git diff-tree HEAD~1 does not. I guess in sake of consistency it should show all changed files in initial commit.

-- 
anatol
Next: Michael J Gruber
Message 1 of 22 in “Diff-tree does not work for initial commit”
  1. Anatol PomozovSep 15, 2008
  2. Michael J GruberSep 15, 2008
  3. Junio C HamanoSep 15, 2008
  4. Anatol PomozovSep 15, 2008
  5. Michael J GruberSep 15, 2008
  6. Sverre RabbelierSep 15, 2008
  7. Jeff KingSep 15, 2008
  8. Sverre RabbelierSep 16, 2008
  9. Jeff KingSep 16, 2008
  10. extend meaning of "--root" option to index comparisonsJeff King, Sep 18, 2008
  11. Anatol PomozovSep 18, 2008
  12. Sverre RabbelierSep 18, 2008
  13. Jeff KingSep 19, 2008
  14. Anatol PomozovSep 19, 2008
  15. Jeff KingSep 19, 2008
  16. Re* [RFC/PATCH] extend meaning of "--root" option to index comparisonsJunio C Hamano, Sep 19, 2008
  17. Jeff KingSep 21, 2008
  18. Anatol PomozovSep 21, 2008
  19. Jakub NarebskiSep 21, 2008
  20. Jeff KingSep 22, 2008
  21. Re* [RFC/PATCH] extend meaning of "--root" option to index comparisonsJunio C Hamano, Sep 21, 2008
  22. Jeff KingSep 22, 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.