Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LLuke
Copy link

@LLuke LLuke commented Jun 17, 2017

…be referenced before assignment

@LLuke
Copy link
Author

LLuke commented Jun 17, 2017

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'')
Copy link
Owner

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

@jonashaag
Copy link
Owner

jonashaag commented Feb 14, 2018

Sorry, somehow GitHub didn't submit my review. It was pending for 6 months...

@LLuke
Copy link
Author

LLuke commented Apr 23, 2018

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.

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

Successfully merging this pull request may close these issues.

None yet

3 participants