From 615647080e256d163f266834863a695cbf3c83ce Mon Sep 17 00:00:00 2001 From: NHanser Date: Thu, 23 Dec 2021 12:51:32 +0100 Subject: [PATCH] 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 --- git/diff.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/git/diff.py b/git/diff.py index cea66d7ee..c8c57685b 100644 --- a/git/diff.py +++ b/git/diff.py @@ -509,9 +509,9 @@ def _index_from_patch_format(cls, repo: 'Repo', proc: Union['Popen', 'Git.AutoIn def _handle_diff_line(lines_bytes: bytes, repo: 'Repo', index: DiffIndex) -> None: lines = lines_bytes.decode(defenc) - for line in lines.split(':')[1:]: - meta, _, path = line.partition('\x00') - path = path.rstrip('\x00') + it = iter(lines.split('\x00')) + for meta, path in zip(it, it): + meta = meta[1:] a_blob_id: Optional[str] b_blob_id: Optional[str] old_mode, new_mode, a_blob_id, b_blob_id, _change_type = meta.split(None, 4)