Skip to content

Command iter_change_type(change_type) returns that some files are modifed when they are renamed #819

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

Open
SpringEp opened this issue Dec 26, 2018 · 2 comments

Comments

@SpringEp
Copy link

SpringEp commented Dec 26, 2018

Command iter_change_type(change_type) returns that file was modified when actually it was renamed. I think that the problem is in this condition
elif change_type == "M" and diff.a_blob and diff.b_blob and diff.a_blob != diff.b_blob: yield diff
which is satisfied for some renamed files when the hashes for a_blob and b_blob change. I know that this shouldn't be the case and that the hashes should be the same in case of file renaming, but I have a several diffs with this problem.

Do you know how can I overcome this problem and have you thought about adding an extra condition that diff.renamed == False?

Link to photo https://imgur.com/a/0DrhOUu

@Byron
Copy link
Member

Byron commented Jan 1, 2019

Thanks for having dug into the issue, as I think your work can greatly facilitate a PR.
I think this kind of issue could easily be fixed by adding a respective test-case and then adjust the code for this to be fixed. A PR is very welcome.

@CptMikhailov
Copy link
Contributor

I've looked into the code, and, correct me if I'm mistaken, but I think that the root of the problem regarding the changing hash comes from the __hash__() method in IndexObject, which Blob inherits from. The hash for IndexObject is calculated from path as "index items are uniquely identifiable by path, not by their data". So maybe Blob should override the base class' __hash__() method?

Does that sound right, or am I a bit off base here?

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

No branches or pull requests

3 participants