Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ases

Now do this:
$ python
>>> import git as pygit
>>> c = pygit.Repo('github.aaakk.us.kg-tomrittervg-Code-Audit-Feed-Test-Cases.git/')
>>> x = c.commit('4aee3ae658c1320619432817d63ec7adabf0f43a')
>>> p = [i for i in x.diff('HEAD~1')][0]

That is this commit: tomrittervg/Code-Audit-Feed-Test-Cases@4aee3ae
This is the addition of a single file.

Unless I'm misunderstanding git, as well as this documentation: http://packages.python.org/GitPython/0.3.1/tutorial.html#obtaining-diff-information

   tdiff = hcommit.diff('HEAD~1')  # diff tree against previous tree

x.diff('HEAD~1') ought to give a 'new_file' commit
But it was reversing the commit.

It ran this:
  git diff 4aee3ae658c1320619432817d63ec7adabf0f43a HEAD~1 --abbrev=40 --full-index --raw
producing
  :100644 000000 5f9b998a3e2916af6671a0f8d296ad7c1fe1490d 0000000000000000000000000000000000000000 D      api-call-test.c

When it should be running this:
  git diff HEAD~1 4aee3ae658c1320619432817d63ec7adabf0f43a --abbrev=40 --full-index --raw
producing this:
  :000000 100644 0000000000000000000000000000000000000000 5f9b998a3e2916af6671a0f8d296ad7c1fe1490d A      api-call-test.c

I changed the order of arguments to get it to give a file addition.  This would also affect which diff the a_blob and b_blob in a 'M' and how a 'R' behaves... I think.
  • Loading branch information
tomrittervg committed Dec 20, 2011
1 parent 6e86f8a commit 0386f7b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def diff(self, other=Index, paths=None, create_patch=False, **kwargs):
if paths is not None and not isinstance(paths, (tuple,list)):
paths = [ paths ]

args.insert(0,self)

if other is not None and other is not self.Index:
args.insert(0, other)
if other is self.Index:
args.insert(0, "--cached")

args.insert(0,self)

# paths is list here or None
if paths:
args.append("--")
Expand Down

0 comments on commit 0386f7b

Please sign in to comment.