Split diff line by '\t' for metadata and path #398
Merged
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.
What's this PR do?
This protects against
.split(None)
, which uses consecutive whitespace as a separator and may overlook paths where a single space is the filename. While having a filename consisting of only a single space is unlikely in practical usage, it is entirely possible.For example, take this diff line:
Notice there is a tab after the
change_type
and a space for the path. The deleted file is a file named ' ' (just one space) at the git root. To replicate this issue, add and commit this file, then delete and commit. This will produce the following output fromgit diff
:This would cause the initial
.split(None, 5)
to fail as it will count all consecutive whitespace as a separator, disregarding the ' ' (single space) filename.