diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-15 16:49:39 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-15 16:53:15 +0100 |
commit | 508807e59ce9d6c3574d314d502e82238e3e606c (patch) | |
tree | 3ed89ce115e472f629b314a640e67be461b789d0 /git/objects/submodule/base.py | |
parent | b259098782c2248f6160d2b36d42672d6925023a (diff) | |
download | gitpython-508807e59ce9d6c3574d314d502e82238e3e606c.tar.gz |
Submodule.add() can now handle absolute module paths in agreement to the doc string.
Previously, it would say it can handle absolute module paths, but didn't
actually do so.
A test-case was improved to check for this case.
Fixes #161
Diffstat (limited to 'git/objects/submodule/base.py')
-rw-r--r-- | git/objects/submodule/base.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index ae45e3db..92b0c8e8 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -238,6 +238,17 @@ class Submodule(util.IndexObject, Iterable, Traversable): path = path[:-1] # END handle trailing slash + if os.path.isabs(path): + working_tree_linux = to_native_path_linux(repo.working_tree_dir) + if not path.startswith(working_tree_linux): + raise ValueError("Submodule checkout path '%s' needs to be within the parents repository at '%s'" + % (working_tree_linux, path)) + path = path[len(working_tree_linux) + 1:] + if not path: + raise ValueError("Absolute submodule path '%s' didn't yield a valid relative path" % path) + # end verify converted relative path makes sense + # end convert to a relative path + # assure we never put backslashes into the url, as some operating systems # like it ... if url is not None: |