◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
5 changes: 4 additions & 1 deletion git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,10 @@ def _to_relative_path(self, path: PathLike) -> PathLike:
raise InvalidGitRepositoryError("require non-bare repository")
if not osp.normpath(str(path)).startswith(str(self.repo.working_tree_dir)):
raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
return os.path.relpath(path, self.repo.working_tree_dir)

def _preprocess_add_items(
self, items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]]
Expand Down
22 changes: 22 additions & 0 deletions test/test_index.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import subprocess
import sys
import tempfile

from gitdb.base import IStream

Expand Down Expand Up @@ -1015,6 +1016,27 @@ class Mocked:
rel = index._to_relative_path(path)
self.assertEqual(rel, os.path.relpath(path, root))

@pytest.mark.xfail(
type(_win_bash_status) is WinBashStatus.Absent,
reason="Can't run a hook on Windows without bash.exe.",
Expand Down
Toggle all file notes Toggle all file annotations