summaryrefslogtreecommitdiff
path: root/lib/git
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/index/base.py2
-rw-r--r--lib/git/objects/base.py5
-rw-r--r--lib/git/refs.py2
-rw-r--r--lib/git/remote.py2
-rw-r--r--lib/git/repo/base.py19
5 files changed, 10 insertions, 20 deletions
diff --git a/lib/git/index/base.py b/lib/git/index/base.py
index 4b3197a2..0f02352f 100644
--- a/lib/git/index/base.py
+++ b/lib/git/index/base.py
@@ -1122,7 +1122,7 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
# item. Handle existing -R flags properly. Transform strings to the object
# so that we can call diff on it
if isinstance(other, basestring):
- other = Object.new(self.repo, other)
+ other = self.repo.rev_parse(other)
# END object conversion
if isinstance(other, Object):
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py
index 21b9b1ea..41862ac2 100644
--- a/lib/git/objects/base.py
+++ b/lib/git/objects/base.py
@@ -49,10 +49,7 @@ 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):
diff --git a/lib/git/refs.py b/lib/git/refs.py
index be094d01..03b80690 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -345,7 +345,7 @@ class SymbolicReference(object):
# figure out target data
target = reference
if resolve:
- target = Object.new(repo, reference)
+ target = repo.rev_parse(str(reference))
if not force and isfile(abs_ref_path):
target_data = str(target)
diff --git a/lib/git/remote.py b/lib/git/remote.py
index 1598e55a..801dcd62 100644
--- a/lib/git/remote.py
+++ b/lib/git/remote.py
@@ -391,7 +391,7 @@ class FetchInfo(object):
split_token = '...'
if control_character == ' ':
split_token = split_token[:-1]
- old_commit = Commit.new(repo, operation.split(split_token)[0])
+ old_commit = repo.rev_parse(operation.split(split_token)[0])
# END handle refspec
# END reference flag handling
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