Skip to content

Commit a2cd130

Browse files
authored
Merge pull request #697 from cblegare/master
Remove trailing slash on drive path
2 parents 28cbb95 + 280e573 commit a2cd130

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ Contributors are:
2424
-Alexis Horgix Chotard
2525
-Piotr Babij <piotr.babij _at_ gmail.com>
2626
-Mikuláš Poul <mikulaspoul _at_ gmail.com>
27+
-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>
2728

2829
Portions derived from other open source works and are clearly marked.

git/objects/submodule/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def _to_relative_path(cls, parent_repo, path):
278278
if not path.startswith(working_tree_linux):
279279
raise ValueError("Submodule checkout path '%s' needs to be within the parents repository at '%s'"
280280
% (working_tree_linux, path))
281-
path = path[len(working_tree_linux) + 1:]
281+
path = path[len(working_tree_linux.rstrip('/')) + 1:]
282282
if not path:
283283
raise ValueError("Absolute submodule path '%s' didn't yield a valid relative path" % path)
284284
# end verify converted relative path makes sense

git/test/test_submodule.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import git
1212
from git.cmd import Git
13-
from git.compat import string_types
13+
from git.compat import string_types, is_win
1414
from git.exc import (
1515
InvalidGitRepositoryError,
1616
RepositoryDirtyError
@@ -911,3 +911,13 @@ def test_branch_renames(self, rw_dir):
911911
parent_repo.submodule_update(to_latest_revision=True, force_reset=True)
912912
assert sm_mod.commit() == sm_pfb.commit, "Now head should have been reset"
913913
assert sm_mod.head.ref.name == sm_pfb.name
914+
915+
@skipIf(not is_win, "Specifically for Windows.")
916+
def test_to_relative_path_with_super_at_root_drive(self):
917+
class Repo(object):
918+
working_tree_dir = 'D:\\'
919+
super_repo = Repo()
920+
submodule_path = 'D:\\submodule_path'
921+
relative_path = Submodule._to_relative_path(super_repo, submodule_path)
922+
msg = '_to_relative_path should be "submodule_path" but was "%s"' % relative_path
923+
assert relative_path == 'submodule_path', msg

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy