summaryrefslogtreecommitdiff
path: root/git/diff.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-06 16:11:34 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-06 16:11:34 +0100
commit56e942318f3c493c8dcd4759f806034331ebeda5 (patch)
tree82cdca65cd197f36ea3680171186e0ddcf234266 /git/diff.py
parentd46e3fe9cb0dea2617cd9231d29bf6919b0f1e91 (diff)
parent68f8a43d1b643318732f30ee1cd75e1d315a4537 (diff)
downloadgitpython-56e942318f3c493c8dcd4759f806034331ebeda5.tar.gz
Merge branch 'py3' into 0.3
Conflicts: git/refs/log.py
Diffstat (limited to 'git/diff.py')
-rw-r--r--git/diff.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/git/diff.py b/git/diff.py
index 5325ad6b..3c4e8529 100644
--- a/git/diff.py
+++ b/git/diff.py
@@ -3,13 +3,15 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
-
import re
-from objects.blob import Blob
-from objects.util import mode_str_to_int
from gitdb.util import hex_to_bin
+from .objects.blob import Blob
+from .objects.util import mode_str_to_int
+
+from git.compat import defenc
+
__all__ = ('Diffable', 'DiffIndex', 'Diff')
@@ -195,7 +197,7 @@ class Diff(object):
""", re.VERBOSE | re.MULTILINE)
# can be used for comparisons
NULL_HEX_SHA = "0" * 40
- NULL_BIN_SHA = "\0" * 20
+ NULL_BIN_SHA = b"\0" * 20
__slots__ = ("a_blob", "b_blob", "a_mode", "b_mode", "new_file", "deleted_file",
"rename_from", "rename_to", "diff")
@@ -294,7 +296,7 @@ class Diff(object):
:param stream: result of 'git diff' as a stream (supporting file protocol)
:return: git.DiffIndex """
# for now, we have to bake the stream
- text = stream.read()
+ text = stream.read().decode(defenc)
index = DiffIndex()
diff_header = cls.re_header.match
@@ -323,6 +325,7 @@ class Diff(object):
# :100644 100644 687099101... 37c5e30c8... M .gitignore
index = DiffIndex()
for line in stream:
+ line = line.decode(defenc)
if not line.startswith(":"):
continue
# END its not a valid diff line