summaryrefslogtreecommitdiff
path: root/lib/git/objects/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-07-06 00:35:30 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-07-06 00:35:30 +0200
commitf963881e53a9f0a2746a11cb9cdfa82eb1f90d8c (patch)
treeea69501e471b2bc724b641cb360f1b15c095c9d6 /lib/git/objects/base.py
parenta4287f65878000b42d11704692f9ea3734014b4c (diff)
downloadgitpython-f963881e53a9f0a2746a11cb9cdfa82eb1f90d8c.tar.gz
Initial version of the rev-parse routine, which doesn't work too bad, but its still rather slow and many tests are not yet implemented
Diffstat (limited to 'lib/git/objects/base.py')
-rw-r--r--lib/git/objects/base.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py
index d4a46788..21b9b1ea 100644
--- a/lib/git/objects/base.py
+++ b/lib/git/objects/base.py
@@ -53,6 +53,17 @@ class Object(LazyMixin):
inst = get_object_type_by_name(typename)(repo, hex_to_bin(hexsha))
inst.size = size
return inst
+
+ @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