git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Get a git diff without taking index into account
@ 2015-02-18 14:57 Eric Frederich
  2015-02-18 15:06 ` Eric Frederich
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Frederich @ 2015-02-18 14:57 UTC (permalink / raw)
  To: git

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

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

end of thread, other threads:[~2015-02-18 22:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-18 14:57 Get a git diff without taking index into account Eric Frederich
2015-02-18 15:06 ` Eric Frederich
2015-02-18 15:37   ` Junio C Hamano
2015-02-18 15:42     ` Eric Frederich
2015-02-18 16:33       ` Junio C Hamano
2015-02-18 18:27         ` Eric Frederich
2015-02-18 18:32           ` Jeff King
2015-02-18 19:36             ` Eric Frederich
2015-02-18 21:38             ` Eric Frederich
2015-02-18 22:16               ` Junio C Hamano
2015-02-18 22:30               ` Jeff King

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).