diff options
| author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-09 16:54:33 +0100 | 
|---|---|---|
| committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-09 17:16:35 +0100 | 
| commit | 85a5a8c6a931f8b3a220ed61750d1f9758d0810a (patch) | |
| tree | f17894d78fa475e53cbc2f1bdfa1b8aa21e2893f /git/diff.py | |
| parent | 18caa610d50b92331485013584f5373804dd0416 (diff) | |
| download | gitpython-85a5a8c6a931f8b3a220ed61750d1f9758d0810a.tar.gz | |
Fixed mode-handling in Diff creation, and added assertions to catch this in future
There is still some work todo in terms of how we handle the encoding
Diffstat (limited to 'git/diff.py')
| -rw-r--r-- | git/diff.py | 7 | 
1 files changed, 5 insertions, 2 deletions
| diff --git a/git/diff.py b/git/diff.py index f10bd1cd..595a8247 100644 --- a/git/diff.py +++ b/git/diff.py @@ -217,10 +217,12 @@ class Diff(object):          if a_blob_id is None:              self.a_blob = None          else: +            assert self.a_mode              self.a_blob = Blob(repo, hex_to_bin(a_blob_id), mode=self.a_mode, path=a_path)          if b_blob_id is None:              self.b_blob = None          else: +            assert self.b_mode              self.b_blob = Blob(repo, hex_to_bin(b_blob_id), mode=self.b_mode, path=b_path)          self.new_file = new_file @@ -313,8 +315,9 @@ class Diff(object):              # Make sure the mode is set if the path is set. Otherwise the resulting blob is invalid              # We just use the one mode we should have parsed -            index.append(Diff(repo, a_path, b_path, a_blob_id, b_blob_id, -                              old_mode or deleted_file_mode or b_mode, new_mode or new_file_mode or b_mode, +            a_mode = old_mode or deleted_file_mode or (a_path and (b_mode or new_mode or new_file_mode)) +            b_mode = b_mode or new_mode or new_file_mode or (b_path and a_mode) +            index.append(Diff(repo, a_path, b_path, a_blob_id, b_blob_id, a_mode, b_mode,                                new_file, deleted_file, rename_from, rename_to, None))              previous_header = header | 
