summaryrefslogtreecommitdiff
path: root/git/index/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'git/index/base.py')
-rw-r--r--git/index/base.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/git/index/base.py b/git/index/base.py
index 14a3117a..04a3934d 100644
--- a/git/index/base.py
+++ b/git/index/base.py
@@ -561,10 +561,9 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable):
return path
if self.repo.bare:
raise InvalidGitRepositoryError("require non-bare repository")
- relative_path = path.replace(self.repo.working_tree_dir + os.sep, "")
- if relative_path == path:
+ if not path.startswith(self.repo.working_tree_dir):
raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
- return relative_path
+ return os.path.relpath(path, self.repo.working_tree_dir)
def _preprocess_add_items(self, items):
""" Split the items into two lists of path strings and BaseEntries. """