summaryrefslogtreecommitdiff
path: root/git/refs/reference.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2011-07-04 22:30:49 +0200
committerSebastian Thiel <byronimo@gmail.com>2011-07-04 22:30:49 +0200
commit916c45de7c9663806dc2cd3769a173682e5e8670 (patch)
treef1ce7416feb0cc5c4ede5fc0548fa1f6e92e2f6d /git/refs/reference.py
parente94df6acd3e22ce0ec7f727076fd9046d96d57b2 (diff)
downloadgitpython-916c45de7c9663806dc2cd3769a173682e5e8670.tar.gz
refs: added constructor flag to allow refs to be instatiated from any path, including simple test
Diffstat (limited to 'git/refs/reference.py')
-rw-r--r--git/refs/reference.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/git/refs/reference.py b/git/refs/reference.py
index 1a745ee9..7666b921 100644
--- a/git/refs/reference.py
+++ b/git/refs/reference.py
@@ -22,15 +22,17 @@ class Reference(SymbolicReference, LazyMixin, Iterable):
_resolve_ref_on_create = True
_common_path_default = "refs"
- def __init__(self, repo, path):
+ def __init__(self, repo, path, check_path = True):
"""Initialize this instance
:param repo: Our parent repository
:param path:
Path relative to the .git/ directory pointing to the ref in question, i.e.
- refs/heads/master"""
- if not path.startswith(self._common_path_default+'/'):
- raise ValueError("Cannot instantiate %r from path %s" % ( self.__class__.__name__, path ))
+ refs/heads/master
+ :param check_path: if False, you can provide any path. Otherwise the path must start with the
+ default path prefix of this type."""
+ if check_path and not path.startswith(self._common_path_default+'/'):
+ raise ValueError("Cannot instantiate %r from path %s" % (self.__class__.__name__, path))
super(Reference, self).__init__(repo, path)