git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git-diff-tree or git-commit: wrong diff(stat)
@ 2007-03-05 20:07 Matthias Lederhofer
  2007-03-05 20:22 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Lederhofer @ 2007-03-05 20:07 UTC (permalink / raw)
  To: git

git-commit.sh uses git-diff-tree [options] HEAD --.  The '--' was
added in 521f9c4d to prevent problems when HEAD exists as a file but
git-diff-tree shows only differences below the current directory when
'--' is used.  Hence git-commit in a subdirectory shows only stats for
the subdirectory.  Example:
~/foo% git init
Initialized empty Git repository in .git/
~/foo% mkdir d
~/foo% seq 1 10 | tee a > d/b
~/foo% git add a d/b
~/foo% cd d
~/foo/d% git commit -m blub
Created initial commit 49d6f2eac51d3a2665a539adc2cc8676e5b14a3d
 1 files changed, 10 insertions(+), 0 deletions(-)
 create mode 100644 d/b

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] git-diff-tree or git-commit: wrong diff(stat)
  2007-03-05 20:07 [BUG] git-diff-tree or git-commit: wrong diff(stat) Matthias Lederhofer
@ 2007-03-05 20:22 ` Junio C Hamano
  2007-03-05 22:08   ` Matthias Lederhofer
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-03-05 20:22 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: git

Matthias Lederhofer <matled@gmx.net> writes:

> git-commit.sh uses git-diff-tree [options] HEAD --.  The '--' was
> added in 521f9c4d to prevent problems when HEAD exists as a file but
> git-diff-tree shows only differences below the current directory when
> '--' is used.  Hence git-commit in a subdirectory shows only stats for
> the subdirectory.

A cd_to_toplevel before that diff-tree should fix that,
shouldn't it?

For that matter, I think the commit hook should be run from a
known environment without getting affected by the user running
git-commit from a random subdirectory, and so should rerere.  So
how about....


 git-commit.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/git-commit.sh b/git-commit.sh
index be3677c..b8c00b8 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -622,6 +622,9 @@ else
 fi
 ret="$?"
 rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
+
+cd_to_toplevel
+
 if test -d "$GIT_DIR/rr-cache"
 then
 	git-rerere

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [BUG] git-diff-tree or git-commit: wrong diff(stat)
  2007-03-05 20:22 ` Junio C Hamano
@ 2007-03-05 22:08   ` Matthias Lederhofer
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Lederhofer @ 2007-03-05 22:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
> A cd_to_toplevel before that diff-tree should fix that,
> shouldn't it?

That should fix this problem.  But anyway I think it is strange that
`git diff` and `git diff --` differ in subdirectories (the latter
shows only changes for the current directory).

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-05 22:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-05 20:07 [BUG] git-diff-tree or git-commit: wrong diff(stat) Matthias Lederhofer
2007-03-05 20:22 ` Junio C Hamano
2007-03-05 22:08   ` Matthias Lederhofer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).