More concise example: cd /tmp git clone --bare https://github.com/defnull/bottle.git mkdir /tmp/bottlecopy git --git-dir=/tmp/bottle.git --work-tree=/tmp/bottlecopy checkout master . # this shows no diffs git --git-dir=/tmp/bottle.git --work-tree=/tmp/bottlecopy diff master rm /tmp/bottle.git/index # why does this one now show a diff? # how can I compare a working directory to a commit without taking the index into account? git --git-dir=/tmp/bottle.git --work-tree=/tmp/bottlecopy diff master On Wed, Feb 18, 2015 at 9:57 AM, Eric Frederich <eric.frederich@xxxxxxxxx> wrote: > Some background. > I'm trying to use Git as an object store for trees. > I put trees into the repo and can retrieve them. > I'm having issues with diffing these trees that I retrieve from the repo. > If I use a "git checkout" the diffs seem to work but if I create the > tree myself user lower level ls-tree and cat-file commands then the > diff doesn't work. > It seems to take the index into account. > > Below is a complete working example. > Should be able to copy / paste line by line. > I am trying to run the diff of form: > git diff [--options] <commit> [--] [<path>...] > where it says it does a diff from working tree to a commit > > Maybe git is interpreting my command as one of the other forms? > Can someone help me understand what is going on? > > # > # EXAMPLE > # > > # cleanup and create dummy data > rm -rf /tmp/mydatastore && mkdir -p /tmp/mydatastore > rm -rf /tmp/test /tmp/test2 && mkdir -p /tmp/test/d1 /tmp/test2 > echo "this is f1" > /tmp/test/f1 > echo "this is f2" > /tmp/test/d1/f2 > > # create a new branch called test with data from /tmp/test > git --git-dir=/tmp/mydatastore/.db init --bare > git --git-dir=/tmp/mydatastore/.db hash-object -w /tmp/test/d1/f2 /tmp/test/f1 > echo -e "100644 blob c837441e09d13d3a0a2d906d7c3813adda504833\tf2" | > git --git-dir=/tmp/mydatastore/.db mktree --batch > echo -e "100644 blob > 11ac5613caf504eec18b2e60f1e6b3c598b085eb\tf1\n40755 tree > 055f1133fbc9872f3093cca5f182b16611e6789a\td1" | git > --git-dir=/tmp/mydatastore/.db mktree > commit_sha=`git --git-dir=/tmp/mydatastore/.db commit-tree -m "initial > commit" c427094b22e74d1eaeebdc9e49e6790b5b6a706a` > git --git-dir=/tmp/mydatastore/.db update-ref refs/heads/test $commit_sha > > # why does this show diffs? > git --git-dir=/tmp/mydatastore/.db --work-tree=/tmp/test diff $commit_sha > > # after doing a checkout somewhere else it doesn't show any diffs > git --git-dir=/tmp/mydatastore/.db --work-tree=/tmp/test2 checkout test . > git --git-dir=/tmp/mydatastore/.db --work-tree=/tmp/test diff $commit_sha > > # remove the index and it shows diffs again > rm /tmp/mydatastore/.db/index > git --git-dir=/tmp/mydatastore/.db --work-tree=/tmp/test diff $commit_sha > > # it was my understanding from "git help diff" that this form of diff > is supposed to > # compare a work tree against a commit or branch and not take into > account the index. > # Clearly it takes into account the index because we get different > results with and without it -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html