From 9a119924bd314934158515a1a5f5877be63f6f91 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Oct 2009 20:21:22 +0200 Subject: fixed issue in Ref.name implementation which would not handle components properly --- lib/git/base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/git/base.py') diff --git a/lib/git/base.py b/lib/git/base.py index f3510558..b7976dab 100644 --- a/lib/git/base.py +++ b/lib/git/base.py @@ -222,9 +222,15 @@ class Ref(object): def name(self): """ Returns - Name of this reference + (shortest) Name of this reference - it may contain path components """ - return os.path.basename(self.path) + # first two path tokens are can be removed as they are + # refs/heads or refs/tags or refs/remotes + tokens = self.path.split('/') + if len(tokens) < 3: + return self.path # could be refs/HEAD + + return '/'.join(tokens[2:]) @classmethod def find_all(cls, repo, common_path = "refs", **kwargs): -- cgit v1.2.1