Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

_to_relative_path to support mixing slashes and backslashes#1961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 4 commits intogitpython-developers:mainfromAndrej730:main
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletiongit/index/base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -653,7 +653,7 @@ def _to_relative_path(self, path: PathLike) -> PathLike:
return path
if self.repo.bare:
raise InvalidGitRepositoryError("require non-bare repository")
if not str(path).startswith(str(self.repo.working_tree_dir)):
if notosp.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)

Expand Down
12 changes: 12 additions & 0 deletionstest/test_index.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1181,6 +1181,18 @@ def test_index_add_pathlike(self, rw_repo):

rw_repo.index.add(file)

@with_rw_repo("HEAD")
def test_index_add_non_normalized_path(self, rw_repo):
git_dir = Path(rw_repo.git_dir)

file = git_dir / "file.txt"
file.touch()
non_normalized_path = file.as_posix()
if os.name != "nt":
non_normalized_path = "/" + non_normalized_path[1:].replace("/", "//")

rw_repo.index.add(non_normalized_path)


class TestIndexUtils:
@pytest.mark.parametrize("file_path_type", [str, Path])
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp