Skip to content

Commit 01f0988

Browse files
NHanserByron
authored andcommitted
Use NUL character to extract meta and path from git diff
Use NUL character instead of semicolon to extract meta and path. Avoid errors in during git diff when dealing with filenames containing semicolons
1 parent da7b5b2 commit 01f0988

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git/diff.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,9 @@ def _index_from_patch_format(cls, repo: 'Repo', proc: Union['Popen', 'Git.AutoIn
509509
def _handle_diff_line(lines_bytes: bytes, repo: 'Repo', index: DiffIndex) -> None:
510510
lines = lines_bytes.decode(defenc)
511511

512-
for line in lines.split(':')[1:]:
513-
meta, _, path = line.partition('\x00')
514-
path = path.rstrip('\x00')
512+
it = iter(lines.split('\x00'))
513+
for meta, path in zip(it, it):
514+
meta = meta[1:]
515515
a_blob_id: Optional[str]
516516
b_blob_id: Optional[str]
517517
old_mode, new_mode, a_blob_id, b_blob_id, _change_type = meta.split(None, 4)

0 commit comments

Comments
 (0)