summaryrefslogtreecommitdiff
path: root/lib/git/objects/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-07-07 17:43:36 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-07-07 17:43:36 +0200
commitca288d443f4fc9d790eecb6e1cdf82b6cdd8dc0d (patch)
tree647089e9f091411c69ff4ee62747c53606671485 /lib/git/objects/base.py
parenta4287f65878000b42d11704692f9ea3734014b4c (diff)
parent01ab5b96e68657892695c99a93ef909165456689 (diff)
downloadgitpython-ca288d443f4fc9d790eecb6e1cdf82b6cdd8dc0d.tar.gz
Merge branch 'revparse'
Diffstat (limited to 'lib/git/objects/base.py')
-rw-r--r--lib/git/objects/base.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py
index d4a46788..41862ac2 100644
--- a/lib/git/objects/base.py
+++ b/lib/git/objects/base.py
@@ -49,10 +49,18 @@ class Object(LazyMixin):
:note: This cannot be a __new__ method as it would always call __init__
with the input id which is not necessarily a binsha."""
- hexsha, typename, size = repo.git.get_object_header(id)
- inst = get_object_type_by_name(typename)(repo, hex_to_bin(hexsha))
- inst.size = size
- return inst
+ return repo.rev_parse(str(id))
+
+ @classmethod
+ def new_from_sha(cls, repo, sha1):
+ """
+ :return: new object instance of a type appropriate to represent the given
+ binary sha1
+ :param sha1: 20 byte binary sha1"""
+ oinfo = repo.odb.info(sha1)
+ inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha)
+ inst.size = oinfo.size
+ return inst
def _set_self_from_args_(self, args_dict):
"""Initialize attributes on self from the given dict that was retrieved