summaryrefslogtreecommitdiff
path: root/git/objects
diff options
context:
space:
mode:
Diffstat (limited to 'git/objects')
-rw-r--r--git/objects/base.py7
-rw-r--r--git/objects/commit.py4
-rw-r--r--git/objects/fun.py3
3 files changed, 7 insertions, 7 deletions
diff --git a/git/objects/base.py b/git/objects/base.py
index 1f0d5752..004e3981 100644
--- a/git/objects/base.py
+++ b/git/objects/base.py
@@ -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")
@@ -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):
diff --git a/git/objects/commit.py b/git/objects/commit.py
index f8b5c969..53af22cd 100644
--- a/git/objects/commit.py
+++ b/git/objects/commit.py
@@ -62,7 +62,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
"author", "authored_date", "author_tz_offset",
"committer", "committed_date", "committer_tz_offset",
"message", "parents", "encoding", "gpgsig")
- _id_attribute_ = "binsha"
+ _id_attribute_ = "hexsha"
def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
committer=None, committed_date=None, committer_tz_offset=None,
@@ -395,7 +395,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
write(("encoding %s\n" % self.encoding).encode('ascii'))
if self.gpgsig:
- write("gpgsig")
+ write(b"gpgsig")
for sigline in self.gpgsig.rstrip("\n").split("\n"):
write((" " + sigline + "\n").encode('ascii'))
diff --git a/git/objects/fun.py b/git/objects/fun.py
index f92a4c06..610bdb5c 100644
--- a/git/objects/fun.py
+++ b/git/objects/fun.py
@@ -2,7 +2,6 @@
from stat import S_ISDIR
from git.compat import (
byte_ord,
- force_bytes,
defenc,
xrange,
text_type
@@ -37,7 +36,7 @@ def tree_to_stream(entries, write):
# takes the input literally, which appears to be utf8 on linux.
if isinstance(name, text_type):
name = name.encode(defenc)
- write(b''.join(mode_str, b' ', name, b'\0', binsha))
+ write(b''.join((mode_str, b' ', name, b'\0', binsha)))
# END for each item
def tree_entries_from_data(data):