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

Commit25f27c8

Browse files
committed
Split diff line by '\t' for metadata and path
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.
1 parentb297148 commit25f27c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎git/diff.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ def _index_from_raw_format(cls, repo, stream):
365365
ifnotline.startswith(":"):
366366
continue
367367
# END its not a valid diff line
368-
old_mode,new_mode,a_blob_id,b_blob_id,change_type,path=line[1:].split(None,5)
368+
meta,_,path=line[1:].partition('\t')
369+
old_mode,new_mode,a_blob_id,b_blob_id,change_type=meta.split(None,4)
369370
path=path.strip()
370371
a_path=path
371372
b_path=path

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp