summaryrefslogtreecommitdiff
path: root/lib/git/repo/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-07-07 17:30:47 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-07-07 17:30:47 +0200
commitbc31651674648f026464fd4110858c4ffeac3c18 (patch)
treed52bd46d5a2c00c6c852148dba16a29d31ae3a5c /lib/git/repo/base.py
parentf068cdc5a1a13539c4a1d756ae950aab65f5348b (diff)
downloadgitpython-bc31651674648f026464fd4110858c4ffeac3c18.tar.gz
Adjusted previous object creators to use the rev_parse method directly. rev_parse could be adjusted not to return Objects anymore, providing better performance for those who just want a sha only. On the other hand, the method is high-level and should be convenient to use as well, its a starting point for more usually, hence its unlikely to call it in tight loops
Diffstat (limited to 'lib/git/repo/base.py')
-rw-r--r--lib/git/repo/base.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/git/repo/base.py b/lib/git/repo/base.py
index e659225e..ed805991 100644
--- a/lib/git/repo/base.py
+++ b/lib/git/repo/base.py
@@ -323,11 +323,9 @@ class Repo(object):
:param rev: revision specifier, see git-rev-parse for viable options.
:return: ``git.Commit``"""
if rev is None:
- rev = self.active_branch
-
- c = Object.new(self, rev)
- assert c.type == "commit", "Revision %s did not point to a commit, but to %s" % (rev, c)
- return c
+ return self.active_branch.commit
+ else:
+ return self.rev_parse(str(rev)+"^0")
def iter_trees(self, *args, **kwargs):
""":return: Iterator yielding Tree objects
@@ -348,14 +346,9 @@ class Repo(object):
it cannot know about its path relative to the repository root and subsequent
operations might have unexpected results."""
if rev is None:
- rev = self.active_branch
-
- c = Object.new(self, rev)
- if c.type == "commit":
- return c.tree
- elif c.type == "tree":
- return c
- raise ValueError( "Revision %s did not point to a treeish, but to %s" % (rev, c))
+ return self.active_branch.commit.tree
+ else:
+ return self.rev_parse(str(rev)+"^{tree}")
def iter_commits(self, rev=None, paths='', **kwargs):
"""A list of Commit objects representing the history of a given ref/commit