| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ | |||
| 9 | 9 | import ntpath | |
| 10 | 10 | import os | |
| 11 | 11 | import os.path as osp | |
| 12 | + import shlex | ||
| 12 | 13 | import stat | |
| 13 | 14 | import sys | |
| 14 | 15 | import uuid | |
@@ -363,6 +364,15 @@ def _clone_repo( | |||
| 363 | 364 | module_abspath = cls._module_abspath(repo, path, name) | |
| 364 | 365 | module_checkout_path = module_abspath | |
| 365 | 366 | if cls._need_gitfile_submodules(repo.git): | |
| 367 | + if not allow_unsafe_options: | ||
| 368 | + Git.check_unsafe_options(Git._option_candidates([], kwargs), repo.unsafe_git_clone_options) | ||
| 369 | + multi_options = kwargs.get("multi_options") | ||
| 370 | + if multi_options: | ||
| 371 | + Git.check_unsafe_options( | ||
| 372 | + shlex.split(" ".join(cast("Sequence[str]", multi_options))), | ||
| 373 | + repo.unsafe_git_clone_options, | ||
| 374 | + ) | ||
| 375 | + allow_unsafe_options = True | ||
| 366 | 376 | kwargs["separate_git_dir"] = module_abspath | |
| 367 | 377 | module_abspath_dir = osp.dirname(module_abspath) | |
| 368 | 378 | if not osp.isdir(module_abspath_dir): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,6 +159,8 @@ class Repo: | |||
| 159 | 159 | "-c", | |
| 160 | 160 | # Can install hooks that execute during clone: | |
| 161 | 161 | "--template", | |
| 162 | + # Redirects the repository metadata to a caller-controlled path: | ||
| 163 | + "--separate-git-dir", | ||
| 162 | 164 | # Fetches from an additional caller-controlled URI: | |
| 163 | 165 | "--bundle-uri", | |
| 164 | 166 | ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,7 @@ def test_clone_unsafe_options(self, rw_repo): | |||
| 133 | 133 | "-vcprotocol.ext.allow=always", | |
| 134 | 134 | f"--template={tmp_dir}", | |
| 135 | 135 | f"--bundle-uri=file://{tmp_dir}", | |
| 136 | + f"--separate-git-dir={tmp_dir / 'git-dir'}", | ||
| 136 | 137 | ] | |
| 137 | 138 | for unsafe_option in unsafe_options: | |
| 138 | 139 | with self.assertRaises(UnsafeOptionError): | |
@@ -149,6 +150,7 @@ def test_clone_unsafe_options(self, rw_repo): | |||
| 149 | 150 | {"c": "protocol.ext.allow=always"}, | |
| 150 | 151 | {"template": tmp_dir}, | |
| 151 | 152 | {"bundle_uri": f"file://{tmp_dir}"}, | |
| 153 | + {"separate_git_dir": tmp_dir / "git-dir"}, | ||
| 152 | 154 | ] | |
| 153 | 155 | for unsafe_option in unsafe_options: | |
| 154 | 156 | with self.assertRaises(UnsafeOptionError): | |
@@ -258,6 +260,7 @@ def test_clone_from_unsafe_options(self, rw_repo): | |||
| 258 | 260 | "-c protocol.ext.allow=always", | |
| 259 | 261 | "-cprotocol.ext.allow=always", | |
| 260 | 262 | "-vcprotocol.ext.allow=always", | |
| 263 | + f"--separate-git-dir={tmp_dir / 'git-dir'}", | ||
| 261 | 264 | ] | |
| 262 | 265 | for unsafe_option in unsafe_options: | |
| 263 | 266 | with self.assertRaises(UnsafeOptionError): | |
@@ -270,6 +273,7 @@ def test_clone_from_unsafe_options(self, rw_repo): | |||
| 270 | 273 | {"u": f"touch {tmp_file}"}, | |
| 271 | 274 | {"config": "protocol.ext.allow=always"}, | |
| 272 | 275 | {"c": "protocol.ext.allow=always"}, | |
| 276 | + {"separate_git_dir": tmp_dir / "git-dir"}, | ||
| 273 | 277 | ] | |
| 274 | 278 | for unsafe_option in unsafe_options: | |
| 275 | 279 | with self.assertRaises(UnsafeOptionError): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -954,6 +954,7 @@ def test_update_rejects_parent_component_in_name(self, rwdir): | |||
| 954 | 954 | source.working_tree_dir, | |
| 955 | 955 | osp.join(clone.working_tree_dir, "module"), | |
| 956 | 956 | separate_git_dir=osp.join(rwdir, "escaped", "module"), | |
| 957 | + allow_unsafe_options=True, | ||
| 957 | 958 | ) | |
| 958 | 959 | with pytest.raises(ValueError, match="submodule name"): | |
| 959 | 960 | clone.submodules[0].update(init=True) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments