summaryrefslogtreecommitdiff
path: root/lib/git/refs.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-26 11:21:59 +0100
committerSebastian Thiel <byronimo@gmail.com>2009-10-26 11:21:59 +0100
commit0725af77afc619cdfbe3cec727187e442cceaf97 (patch)
tree6fd8b2816a31d27d661ad9684292472c67bff6ec /lib/git/refs.py
parent9dfd6bcca5499e1cd472c092bc58426e9b72cccc (diff)
downloadgitpython-0725af77afc619cdfbe3cec727187e442cceaf97.tar.gz
refs.SymoblicRef: implemented direcft setting of the symbolic references commit, which possibly dereferences to the respective head
Diffstat (limited to 'lib/git/refs.py')
-rw-r--r--lib/git/refs.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/git/refs.py b/lib/git/refs.py
index 47c37af6..26e7c09e 100644
--- a/lib/git/refs.py
+++ b/lib/git/refs.py
@@ -118,7 +118,7 @@ class Reference(LazyMixin, Iterable):
"""
commit = self.object
if commit.type != "commit":
- raise TypeError("Object of reference %s did not point to a commit" % self)
+ raise TypeError("Object of reference %s did not point to a commit, but to %r" % (self, commit))
return commit
commit = property(_get_commit, _set_commit, doc="Return Commit object the reference points to")
@@ -250,8 +250,7 @@ class SymbolicReference(object):
def _get_path(self):
return os.path.join(self.repo.path, self.name)
- @property
- def commit(self):
+ def _get_commit(self):
"""
Returns:
Commit object we point to, works for detached and non-detached
@@ -271,6 +270,18 @@ class SymbolicReference(object):
# Otherwise it would have detached it
return Head(self.repo, tokens[1]).commit
+ def _set_commit(self, commit):
+ """
+ Set our commit, possibly dereference our symbolic reference first.
+ """
+ if self.is_detached:
+ return self._set_reference(commit)
+
+ # set the commit on our reference
+ self._get_reference().commit = commit
+
+ commit = property(_get_commit, _set_commit, doc="Query or set commits directly")
+
def _get_reference(self):
"""
Returns