summaryrefslogtreecommitdiff
path: root/lib/git/repo.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-14 23:37:45 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-14 23:37:45 +0200
commit2e6d110fbfa1f2e6a96bc8329e936d0cf1192844 (patch)
tree2b792542f3de64e63763444ae350d2410c3d00e8 /lib/git/repo.py
parent832b56394b079c9f6e4c777934447a9e224facfe (diff)
downloadgitpython-2e6d110fbfa1f2e6a96bc8329e936d0cf1192844.tar.gz
tree: now reads tress directly by parsing the binary data, allowing it to safe possibly hundreds of command calls
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r--lib/git/repo.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index d5dab242..f07edbe0 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -340,11 +340,19 @@ class Repo(object):
if not isinstance(treeish, Ref):
raise ValueError( "Treeish reference required, got %r" % treeish )
- # we should also check whether the ref has a valid commit ... but lets n
- # not be over-critical
+
+ # As we are directly reading object information, we must make sure
+ # we truly point to a tree object. We resolve the ref to a sha in all cases
+ # to assure the returned tree can be compared properly. Except for
+ # heads, ids should always be hexshas
+ hexsha, typename, size = self.git.get_object_header( treeish )
+ if typename != "tree":
+ hexsha, typename, size = self.git.get_object_header( str(treeish)+'^{tree}' )
+ # END tree handling
+ treeish = hexsha
+
# the root has an empty relative path and the default mode
- root = Tree(self, treeish, 0, '')
- return root
+ return Tree(self, treeish, 0, '')
def diff(self, a, b, *paths):