Dear Git users,

I have some difficulties to understand, why git read-tree followed by a git 
diff-files actually shows some changes between the index and working 
directory. The attached script demonstrates the observation. The output on 
my computer can be seen in the following (note that echo line does 'echo 
test >testdir/testfile').

+ rm -Rf test
+ git init test
Initialized empty Git repository in /home/sba/gittest/test/.git/
+ cd test
+ mkdir testdir
+ echo test
+ git update-index --add testdir/testfile
++ git write-tree
+ tree=ccab85fd26420d7707f41efd82d4182d06bf0cde
+ git read-tree ccab85fd26420d7707f41efd82d4182d06bf0cde
+ git diff-files
:100644 100644 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 
0000000000000000000000000000000000000000 M testdir/testfile
+ git status
# On branch master
# Initial commit
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
# new file:   testdir/testfile
+ git diff-files

So what you see in this sequence is that git read-tree puts the tree into 
the index. The index matches the files in the working directory, but 
nonetheless, git diff-files lists the single file as different (git 
diff-files is supposed to list differences between index and working 
directory). After calling 'git status' 'git diff-files' works as expected.

Is there any explanation why git behaves like that? Note that this is a 
test case in the suite so this is actually the expected 

Thanks in advance!




set -x

rm -Rf test
git init test
cd test
mkdir testdir
echo test >testdir/testfile
git update-index --add testdir/testfile
tree=`git write-tree`
git read-tree $tree
git diff-files
git status
git diff-files

Reply via email to