summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorCharles Bouchard-Légaré <charles.bouchard-legare@optelgroup.com>2017-11-16 15:07:47 -0500
committerCharles Bouchard-Légaré <charles.bouchard-legare@optelgroup.com>2017-11-16 15:07:47 -0500
commit280e573beb90616fe9cb0128cec47b3aff69b86a (patch)
treedf3756ba28864f3bddf7e6ebc14d644a6abbcfa4 /git
parentbfae362363b28be9b86250eb7f6a32dac363c993 (diff)
downloadgitpython-280e573beb90616fe9cb0128cec47b3aff69b86a.tar.gz
Remove trailing slash on drive path
Diffstat (limited to 'git')
-rw-r--r--git/objects/submodule/base.py2
-rw-r--r--git/test/test_submodule.py12
2 files changed, 12 insertions, 2 deletions
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