| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 914a4ae commit dcd956a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -416,11 +416,14 @@ def _to_relative_path(cls, parent_repo: "Repo", path: PathLike) -> PathLike: | |||
| 416 | 416 | ||
| 417 | 417 | @property | |
| 418 | 418 | def abspath(self) -> PathLike: | |
| 419 | - path = super().abspath | ||
| 420 | 419 | root = self.repo.working_tree_dir | |
| 421 | - assert root is not None | ||
| 422 | - if _to_relative_path(osp.realpath(root), osp.realpath(path)) == ".": | ||
| 423 | - raise ValueError("Submodule checkout path must not be the repository root") | ||
| 420 | + if root is None: | ||
| 421 | + return super().abspath | ||
| 422 | + path = root | ||
| 423 | + for component in os.fspath(self._to_relative_path(self.repo, self.path)).split("/"): | ||
| 424 | + path = join_path_native(path, component) | ||
| 425 | + if osp.islink(path): | ||
| 426 | + raise ValueError("Submodule checkout path %r contains a symbolic link" % self.path) | ||
| 424 | 427 | return path | |
| 425 | 428 | ||
| 426 | 429 | @classmethod | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1385,9 +1385,10 @@ def test_update_rejects_checkout_path_outside_parent(self, rwdir): | |||
| 1385 | 1385 | submodule.update(init=True) | |
| 1386 | 1386 | ||
| 1387 | 1387 | @with_rw_directory | |
| 1388 | - def test_update_rejects_checkout_path_through_outside_symlink(self, rwdir): | ||
| 1388 | + def test_update_rejects_checkout_path_through_symlink(self, rwdir): | ||
| 1389 | 1389 | parent = git.Repo.init(osp.join(rwdir, "parent")) | |
| 1390 | - os.symlink(osp.join(rwdir, "outside"), osp.join(parent.working_tree_dir, "link")) | ||
| 1390 | + os.mkdir(osp.join(parent.working_tree_dir, "target")) | ||
| 1391 | + os.symlink("target", osp.join(parent.working_tree_dir, "link")) | ||
| 1391 | 1392 | submodule = Submodule( | |
| 1392 | 1393 | parent, | |
| 1393 | 1394 | Submodule.NULL_BIN_SHA, | |
@@ -1397,7 +1398,7 @@ def test_update_rejects_checkout_path_through_outside_symlink(self, rwdir): | |||
| 1397 | 1398 | ) | |
| 1398 | 1399 | ||
| 1399 | 1400 | with mock.patch.object(Submodule, "_clone_repo", side_effect=AssertionError("clone attempted")): | |
| 1400 | - with pytest.raises(ValueError, match="is not in repository"): | ||
| 1401 | + with pytest.raises(ValueError, match="contains a symbolic link"): | ||
| 1401 | 1402 | submodule.update(init=True) | |
| 1402 | 1403 | ||
| 1403 | 1404 | @with_rw_directory | |
| Back | FazBrowse Home | New Git URL |
0 commit comments