hotfix for repo.py in guess_is_binary(newblob) where 'newblob' could …#186
Open
LLuke wants to merge 1 commit intojonashaag:masterfrom
Open
hotfix for repo.py in guess_is_binary(newblob) where 'newblob' could …#186LLuke wants to merge 1 commit intojonashaag:masterfrom
LLuke wants to merge 1 commit intojonashaag:masterfrom
Conversation
…be referenced before assignment
Author
|
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 |
jonashaag
reviewed
Feb 14, 2018
| 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'') |
Owner
There was a problem hiding this comment.
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?)
Owner
|
Sorry, somehow GitHub didn't submit my review. It was pending for 6 months... |
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…be referenced before assignment