summaryrefslogtreecommitdiff
path: root/lib/git
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-11 20:21:22 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-11 20:21:22 +0200
commit9a119924bd314934158515a1a5f5877be63f6f91 (patch)
tree927fbe62fe20c62eedf7beed91ac80b10dc60774 /lib/git
parent15b9129ec639112e94ea96b6a395ad9b149515d1 (diff)
downloadgitpython-9a119924bd314934158515a1a5f5877be63f6f91.tar.gz
fixed issue in Ref.name implementation which would not handle components properly
Diffstat (limited to 'lib/git')
-rw-r--r--lib/git/base.py10
-rw-r--r--lib/git/tree.py6
2 files changed, 11 insertions, 5 deletions
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):
diff --git a/lib/git/tree.py b/lib/git/tree.py
index db4a3e22..597668ae 100644
--- a/lib/git/tree.py
+++ b/lib/git/tree.py
@@ -47,11 +47,11 @@ class Tree(base.IndexObject):
return None
if typ == "tree":
- return Tree(repo, id=id, mode=mode, path=path)
+ return Tree(repo, id, mode, path)
elif typ == "blob":
- return blob.Blob(repo, id=id, mode=mode, path=path)
+ return blob.Blob(repo, id, mode, path)
elif typ == "commit":
- return None
+ return None
else:
raise(TypeError, "Invalid type: %s" % typ)