{"thread":{"id":"7097","subject":"[BUG] git-diff-tree or git-commit: wrong diff(stat)","startedAt":"2007-03-05T20:07:51Z","lastAt":"2007-03-05T22:08:14Z","messageCount":3,"participants":["Matthias Lederhofer","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"36360","messageId":"20070305200751.GA13655@moooo.ath.cx","threadId":"7097","inReplyTo":null,"subject":"[BUG] git-diff-tree or git-commit: wrong diff(stat)","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-03-05T20:07:51Z","receivedAt":"2007-03-05T20:07:51Z","isPatch":false,"sender":{"key":"matled@gmx.net","avatar":null},"body":"git-commit.sh uses git-diff-tree [options] HEAD --.  The '--' was\nadded in 521f9c4d to prevent problems when HEAD exists as a file but\ngit-diff-tree shows only differences below the current directory when\n'--' is used.  Hence git-commit in a subdirectory shows only stats for\nthe subdirectory.  Example:\n~/foo% git init\nInitialized empty Git repository in .git/\n~/foo% mkdir d\n~/foo% seq 1 10 | tee a > d/b\n~/foo% git add a d/b\n~/foo% cd d\n~/foo/d% git commit -m blub\nCreated initial commit 49d6f2eac51d3a2665a539adc2cc8676e5b14a3d\n 1 files changed, 10 insertions(+), 0 deletions(-)\n create mode 100644 d/b\n"},{"id":"36361","messageId":"7v3b4jzbha.fsf@assigned-by-dhcp.cox.net","threadId":"7097","inReplyTo":"20070305200751.GA13655@moooo.ath.cx","subject":"Re: [BUG] git-diff-tree or git-commit: wrong diff(stat)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-05T20:22:57Z","receivedAt":"2007-03-05T20:22:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> git-commit.sh uses git-diff-tree [options] HEAD --.  The '--' was\n> added in 521f9c4d to prevent problems when HEAD exists as a file but\n> git-diff-tree shows only differences below the current directory when\n> '--' is used.  Hence git-commit in a subdirectory shows only stats for\n> the subdirectory.\n\nA cd_to_toplevel before that diff-tree should fix that,\nshouldn't it?\n\nFor that matter, I think the commit hook should be run from a\nknown environment without getting affected by the user running\ngit-commit from a random subdirectory, and so should rerere.  So\nhow about....\n\n\n git-commit.sh |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex be3677c..b8c00b8 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -622,6 +622,9 @@ else\n fi\n ret=\"$?\"\n rm -f \"$GIT_DIR/COMMIT_MSG\" \"$GIT_DIR/COMMIT_EDITMSG\" \"$GIT_DIR/SQUASH_MSG\"\n+\n+cd_to_toplevel\n+\n if test -d \"$GIT_DIR/rr-cache\"\n then\n \tgit-rerere\n"},{"id":"36373","messageId":"20070305220814.GA17302@moooo.ath.cx","threadId":"7097","inReplyTo":"7v3b4jzbha.fsf@assigned-by-dhcp.cox.net","subject":"Re: [BUG] git-diff-tree or git-commit: wrong diff(stat)","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2007-03-05T22:08:14Z","receivedAt":"2007-03-05T22:08:14Z","isPatch":false,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> A cd_to_toplevel before that diff-tree should fix that,\n> shouldn't it?\n\nThat should fix this problem.  But anyway I think it is strange that\n`git diff` and `git diff --` differ in subdirectories (the latter\nshows only changes for the current directory).\n"}]}