Skip to content

Commit

Permalink
Use NUL character to extract meta and path from git diff
Browse files Browse the repository at this point in the history
Use NUL character instead of semicolon to extract meta and path. Avoid errors in during git diff when dealing with filenames containing semicolons
  • Loading branch information
NHanser authored and Byron committed Jan 7, 2022
1 parent da7b5b2 commit 01f0988
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 01f0988

Please sign in to comment.