Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Split diff line by '\t' for metadata and path#398

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 2 commits intogitpython-developers:masterfromgitprime:master
Mar 16, 2016

Conversation

jonathanchu
Copy link
Contributor

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:

screenshot 2016-03-15 14 18 42

Notice there is a tab after thechange_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:

$ git diff --name-status <SHA1> <SHA2>DM       path/to/another/file.py...

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.

This protects against `.split(None)` which uses consecutive whitespaceas a separator to overlook paths where a single space is the filename.For example, in this diff line:line = ':100644 000000e69de290000000000000000000000000000000000000000 D       'The deleted file is a file named ' ' (just one space).  It's entirelypossible to commit this, remove, and to produce the following outputfrom `git diff`:git diff --name-status <SHA1> <SHA2>DM       path/to/another/file.py...This would cause the initial `.split(None, 5)` to fail as it will countall consecutive whitespace as a separator, disregarding the ' ' (singlespace)  filename.
@Byron
Copy link
Member

Thanks for the elaborate explanation and the fix! Do you think it's feasible to add a test for this as well, maybe with a fixture?

@jonathanchu
Copy link
ContributorAuthor

And thanks for the quick response@Byron! :) Sure thing, I was just looking into that after I created this PR actually.

I'll take a look at the current tests tonight and will see if I can work something in. I think it should be feasible and definitely worth it.

@ByronByron added this to thev1.0.3 - Fixes milestoneMar 15, 2016
This tests the edge case of doing a diff against a single whitespacefilename and returns the proper change type.  All other normal usage ofthis diff classmethod should remain unchanged.
@jonathanchu
Copy link
ContributorAuthor

@Byron can you review my test and fixture ine328ffd, if this fits and is in line with the rest of the library? Thanks!

@Byron
Copy link
Member

Thanks so much, it looks great!

Byron added a commit that referenced this pull requestMar 16, 2016
Split diff line by '\t' for metadata and path
@ByronByron merged commitc877794 intogitpython-developers:masterMar 16, 2016
@jonathanchu
Copy link
ContributorAuthor

🍻 :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
@jonathanchu@Byron

[8]ページ先頭

©2009-2025 Movatter.jp