diff options
Diffstat (limited to 'git/refs')
| -rw-r--r-- | git/refs/head.py | 8 | ||||
| -rw-r--r-- | git/refs/tag.py | 7 |
2 files changed, 12 insertions, 3 deletions
diff --git a/git/refs/head.py b/git/refs/head.py index 9a9a8596..9ad890db 100644 --- a/git/refs/head.py +++ b/git/refs/head.py @@ -8,6 +8,12 @@ from .reference import Reference __all__ = ["HEAD", "Head"] +def strip_quotes(string): + if string.startswith('"') and string.endswith('"'): + return string[1:-1] + return string + + class HEAD(SymbolicReference): """Special case of a Symbolic Reference as it represents the repository's @@ -152,7 +158,7 @@ class Head(Reference): from .remote import RemoteReference reader = self.config_reader() if reader.has_option(self.k_config_remote) and reader.has_option(self.k_config_remote_ref): - ref = Head(self.repo, Head.to_full_path(reader.get_value(self.k_config_remote_ref))) + ref = Head(self.repo, Head.to_full_path(strip_quotes(reader.get_value(self.k_config_remote_ref)))) remote_refpath = RemoteReference.to_full_path(join_path(reader.get_value(self.k_config_remote), ref.name)) return RemoteReference(self.repo, remote_refpath) # END handle have tracking branch diff --git a/git/refs/tag.py b/git/refs/tag.py index cf41d971..37ee1240 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -22,14 +22,17 @@ class TagReference(Reference): @property def commit(self): - """:return: Commit object the tag ref points to""" + """:return: Commit object the tag ref points to + + :raise ValueError: if the tag points to a tree or blob""" obj = self.object while obj.type != 'commit': if obj.type == "tag": # it is a tag object which carries the commit as an object - we can point to anything obj = obj.object else: - raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self) + raise ValueError(("Cannot resolve commit as tag %s points to a %s object - " + + "use the `.object` property instead to access it") % (self, obj.type)) return obj @property |
