summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2017-11-19 16:03:37 +0100
committerGitHub <noreply@github.com>2017-11-19 16:03:37 +0100
commita2cd130bed184fe761105d60edda6936f348edc6 (patch)
tree3e463012cf8fa4bd540e558f2f84f386a244b0a5
parent28cbb953ce01b4eea7f096c28f84da1fbab26694 (diff)
parent280e573beb90616fe9cb0128cec47b3aff69b86a (diff)
downloadgitpython-a2cd130bed184fe761105d60edda6936f348edc6.tar.gz
Merge pull request #697 from cblegare/master
Remove trailing slash on drive path
-rw-r--r--AUTHORS1
-rw-r--r--git/objects/submodule/base.py2
-rw-r--r--git/test/test_submodule.py12
3 files changed, 13 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index f9540907..6f93b20d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -24,5 +24,6 @@ Contributors are:
-Alexis Horgix Chotard
-Piotr Babij <piotr.babij _at_ gmail.com>
-Mikuláš Poul <mikulaspoul _at_ gmail.com>
+-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>
Portions derived from other open source works and are clearly marked.
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index dc4ee3c6..33151217 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -278,7 +278,7 @@ class Submodule(IndexObject, Iterable, Traversable):
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:]
+ path = path[len(working_tree_linux.rstrip('/')) + 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
diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py
index e667ae17..f970dd2c 100644
--- a/git/test/test_submodule.py
+++ b/git/test/test_submodule.py
@@ -10,7 +10,7 @@ except ImportError:
import git
from git.cmd import Git
-from git.compat import string_types
+from git.compat import string_types, is_win
from git.exc import (
InvalidGitRepositoryError,
RepositoryDirtyError
@@ -911,3 +911,13 @@ class TestSubmodule(TestBase):
parent_repo.submodule_update(to_latest_revision=True, force_reset=True)
assert sm_mod.commit() == sm_pfb.commit, "Now head should have been reset"
assert sm_mod.head.ref.name == sm_pfb.name
+
+ @skipIf(not is_win, "Specifically for Windows.")
+ def test_to_relative_path_with_super_at_root_drive(self):
+ class Repo(object):
+ working_tree_dir = 'D:\\'
+ super_repo = Repo()
+ submodule_path = 'D:\\submodule_path'
+ relative_path = Submodule._to_relative_path(super_repo, submodule_path)
+ msg = '_to_relative_path should be "submodule_path" but was "%s"' % relative_path
+ assert relative_path == 'submodule_path', msg \ No newline at end of file