diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-05-30 18:53:23 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-05-30 18:53:23 +0200 |
commit | f5089d9d6c303b47936a741b7bdf37293ec3a1c6 (patch) | |
tree | 932a165ad2968a2c0dba7853c60b6da5e7e30ab9 /git/diff.py | |
parent | a3f24f64a20d1e09917288f67fd21969f4444acd (diff) | |
parent | 1faf84f8eb760b003ad2be81432443bf443b82e6 (diff) | |
download | gitpython-f5089d9d6c303b47936a741b7bdf37293ec3a1c6.tar.gz |
Merge pull request #454 from gitpython-developers/fix-octal-escaped-path-parser-bug
Fix bug in diff parser output
Diffstat (limited to 'git/diff.py')
-rw-r--r-- | git/diff.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/git/diff.py b/git/diff.py index 44a65017..9073767e 100644 --- a/git/diff.py +++ b/git/diff.py @@ -15,12 +15,23 @@ from git.compat import ( PY3 ) - __all__ = ('Diffable', 'DiffIndex', 'Diff', 'NULL_TREE') # Special object to compare against the empty tree in diffs NULL_TREE = object() +_octal_byte_re = re.compile(b'\\\\([0-9]{3})') + + +def _octal_repl(matchobj): + value = matchobj.group(1) + value = int(value, 8) + if PY3: + value = bytes(bytearray((value,))) + else: + value = chr(value) + return value + def decode_path(path, has_ab_prefix=True): if path == b'/dev/null': @@ -32,6 +43,8 @@ def decode_path(path, has_ab_prefix=True): .replace(b'\\"', b'"') .replace(b'\\\\', b'\\')) + path = _octal_byte_re.sub(_octal_repl, path) + if has_ab_prefix: assert path.startswith(b'a/') or path.startswith(b'b/') path = path[2:] @@ -337,7 +350,7 @@ class Diff(object): :note: This property is deprecated, please use ``renamed_file`` instead. """ return self.renamed_file - + @property def renamed_file(self): """:returns: True if the blob of our diff has been renamed |