-
Notifications
You must be signed in to change notification settings - Fork 102
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
hotfix for repo.py in guess_is_binary(newblob) where 'newblob' could … #186
base: master
Are you sure you want to change the base?
Conversation
…be referenced before assignment
Jonas, Thank for the excellent work in Klaus. I have noticed this issue and create the hotfix. Please feel free to accept or revise. Regards, Luke |
@@ -194,6 +194,7 @@ def commit_diff(self, commit): | |||
dulwich_changes = self.object_store.tree_changes(parent_tree, commit.tree) | |||
for (oldpath, newpath), (oldmode, newmode), (oldsha, newsha) in dulwich_changes: | |||
summary['nfiles'] += 1 | |||
newblob = oldblob = Blob.from_string(b'') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the patch! I'd prefer this to be expressed in a more explicit way, and without the redundant Blob.from_string
below.
How about something along the lines of:
if oldsha is None:
# File was newly created [newsha: deleted]
oldblob = Blob.from_string(b'')
elif oldsha not in self.object_store:
# newsha/oldsha are probably related to submodules.
# Dulwich will handle that.
oldblob = Blob.from_string(b'')
else:
oldblob = self.object_store[oldsha]
And the same duplicated for newsha/newblob.
(Note: Not sure if None
is the only false-y value the `sha variables can have?)
Sorry, somehow GitHub didn't submit my review. It was pending for 6 months... |
Your suggestion is better. :-) Also Apologize for late reply. Somehow gmail chose to send all my github threads to spam while I'm working mostly off the web interface these days. |
…be referenced before assignment