summaryrefslogtreecommitdiff
path: root/git/diff.py
diff options
context:
space:
mode:
authorNHanser <nicolas.hans@gmail.com>2021-12-23 12:51:32 +0100
committerSebastian Thiel <sebastian.thiel@icloud.com>2022-01-07 09:52:29 +0800
commit01f09888208341876d1480bd22dc8f4107c100f1 (patch)
tree5f7bac02a44331e9572de7a461613456228d6bec /git/diff.py
parentda7b5b286a8fc75f2d2e9183bf1d13f9d8cdce49 (diff)
downloadgitpython-01f09888208341876d1480bd22dc8f4107c100f1.tar.gz
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
Diffstat (limited to 'git/diff.py')
-rw-r--r--git/diff.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/git/diff.py b/git/diff.py
index cea66d7e..c8c57685 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -509,9 +509,9 @@ class Diff(object):
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)