Skip to content

Deleted file showing as new file #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
craigcabrey opened this issue Jun 6, 2016 · 2 comments
Closed

Deleted file showing as new file #466

craigcabrey opened this issue Jun 6, 2016 · 2 comments

Comments

@craigcabrey
Copy link

I'm running into a problem where a deleted file is showing as new. I reproduced the issue to the best of my ability below.

Repository: https://github.com/apache/httpclient.git
Commit: b29c819645a404a064f022d5a75d8597985f6fac

Using Python 3.5.1, GitPython 2.0.5, and git 2.8.3.

import git

repo = git.Repo('.')
commit = repo.commit('b29c819645a404a064f022d5a75d8597985f6fac')
diffs = [diff for diff in c.diff(c.parents[0]) if 'AbstractVerifier.java' in diff.a_path]

print(diffs) # [<git.diff.Diff object at 0x7f6786634748>]
print(diffs[0].deleted_file) # False
print(diffs[0].new_file) # True
@nvie
Copy link
Contributor

nvie commented Jun 6, 2016

You're running the diff the wrong way around. GitPython follows the order of arguments to that command line git diff would also require: old -> new. So you should use c.parents[0].diff(c) rather than c.diff(c.parents[0]). That's why you get the inverse. It's definitely not super intuitive, but that's how it works.

@nvie nvie closed this as completed Jun 6, 2016
@craigcabrey
Copy link
Author

Thanks for the tip, appreciate it.
On Jun 6, 2016 2:56 PM, "Vincent Driessen" [email protected] wrote:

Closed #466 #466
.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#466 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AA2mZW76jz6CCscAcmpPAbUf4vou_pu0ks5qJG1bgaJpZM4IvJOV
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants