summaryrefslogtreecommitdiff
path: root/git/objects/base.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/objects/base.py
parentd46e3fe9cb0dea2617cd9231d29bf6919b0f1e91 (diff)
parent68f8a43d1b643318732f30ee1cd75e1d315a4537 (diff)
downloadgitpython-56e942318f3c493c8dcd4759f806034331ebeda5.tar.gz
Merge branch 'py3' into 0.3
Conflicts: git/refs/log.py
Diffstat (limited to 'git/objects/base.py')
-rw-r--r--git/objects/base.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/git/objects/base.py b/git/objects/base.py
index 20147e57..3f595d9d 100644
--- a/git/objects/base.py
+++ b/git/objects/base.py
@@ -3,8 +3,8 @@
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
+from .util import get_object_type_by_name
from git.util import LazyMixin, join_path_native, stream_copy
-from util import get_object_type_by_name
from gitdb.util import (
bin_to_hex,
basename
@@ -21,7 +21,7 @@ class Object(LazyMixin):
"""Implements an Object which may be Blobs, Trees, Commits and Tags"""
NULL_HEX_SHA = '0' * 40
- NULL_BIN_SHA = '\0' * 20
+ NULL_BIN_SHA = b'\0' * 20
TYPES = (dbtyp.str_blob_type, dbtyp.str_tree_type, dbtyp.str_commit_type, dbtyp.str_tag_type)
__slots__ = ("repo", "binsha", "size")
@@ -60,7 +60,7 @@ class Object(LazyMixin):
:param sha1: 20 byte binary sha1"""
if sha1 == cls.NULL_BIN_SHA:
# the NULL binsha is always the root commit
- return get_object_type_by_name('commit')(repo, sha1)
+ return get_object_type_by_name(b'commit')(repo, sha1)
# END handle special case
oinfo = repo.odb.info(sha1)
inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
@@ -94,7 +94,7 @@ class Object(LazyMixin):
def __str__(self):
""":return: string of our SHA1 as understood by all git commands"""
- return bin_to_hex(self.binsha)
+ return self.hexsha
def __repr__(self):
""":return: string with pythonic representation of our object"""
@@ -103,7 +103,8 @@ class Object(LazyMixin):
@property
def hexsha(self):
""":return: 40 byte hex version of our 20 byte binary sha"""
- return bin_to_hex(self.binsha)
+ # b2a_hex produces bytes
+ return bin_to_hex(self.binsha).decode('ascii')
@property
def data_stream(self):