@@ -1386,8 +1386,8 @@ def _clone( | |||
| 1386 | 1386 | Git.check_unsafe_protocols(url) | |
| 1387 | 1387 | if not allow_unsafe_options: | |
| 1388 | 1388 | Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=cls.unsafe_git_clone_options) | |
| 1389 | - if not allow_unsafe_options and multi_options: | ||
| 1390 | - Git.check_unsafe_options(options=multi_options, unsafe_options=cls.unsafe_git_clone_options) | ||
| 1389 | + if not allow_unsafe_options and multi: | ||
| 1390 | + Git.check_unsafe_options(options=multi, unsafe_options=cls.unsafe_git_clone_options) | ||
| 1391 | 1391 | ||
| 1392 | 1392 | proc = git.clone( | |
| 1393 | 1393 | multi, | |
@@ -137,6 +137,15 @@ def test_clone_unsafe_options(self, rw_repo): | |||
| 137 | 137 | rw_repo.clone(tmp_dir, **unsafe_option) | |
| 138 | 138 | assert not tmp_file.exists() | |
| 139 | 139 | ||
| 140 | + @with_rw_repo("HEAD") | ||
| 141 | + def test_clone_unsafe_options_are_checked_after_splitting_multi_options(self, rw_repo): | ||
| 142 | + with tempfile.TemporaryDirectory() as tdir: | ||
| 143 | + tmp_dir = pathlib.Path(tdir) | ||
| 144 | + payload = "--single-branch --config protocol.ext.allow=always" | ||
| 145 | + | ||
| 146 | + with self.assertRaises(UnsafeOptionError): | ||
| 147 | + rw_repo.clone(tmp_dir, multi_options=[payload]) | ||
| 148 | + | ||
| 140 | 149 | @pytest.mark.xfail( | |
| 141 | 150 | sys.platform == "win32", | |
| 142 | 151 | reason=( | |
@@ -216,6 +225,15 @@ def test_clone_from_unsafe_options(self, rw_repo): | |||
| 216 | 225 | Repo.clone_from(rw_repo.working_dir, tmp_dir, **unsafe_option) | |
| 217 | 226 | assert not tmp_file.exists() | |
| 218 | 227 | ||
| 228 | + @with_rw_repo("HEAD") | ||
| 229 | + def test_clone_from_unsafe_options_are_checked_after_splitting_multi_options(self, rw_repo): | ||
| 230 | + with tempfile.TemporaryDirectory() as tdir: | ||
| 231 | + tmp_dir = pathlib.Path(tdir) | ||
| 232 | + payload = "--single-branch --config protocol.ext.allow=always" | ||
| 233 | + | ||
| 234 | + with self.assertRaises(UnsafeOptionError): | ||
| 235 | + Repo.clone_from(rw_repo.working_dir, tmp_dir, multi_options=[payload]) | ||
| 236 | + | ||
| 219 | 237 | @pytest.mark.xfail( | |
| 220 | 238 | sys.platform == "win32", | |
| 221 | 239 | reason=( | |
@@ -1332,6 +1332,17 @@ def test_submodule_update_unsafe_options(self, rw_repo): | |||
| 1332 | 1332 | submodule.update(clone_multi_options=[unsafe_option]) | |
| 1333 | 1333 | assert not tmp_file.exists() | |
| 1334 | 1334 | ||
| 1335 | + @with_rw_repo("HEAD") | ||
| 1336 | + def test_submodule_update_unsafe_options_are_checked_after_splitting_multi_options(self, rw_repo): | ||
| 1337 | + with tempfile.TemporaryDirectory() as tdir: | ||
| 1338 | + tmp_dir = Path(tdir) | ||
| 1339 | + payload = "--single-branch --config protocol.ext.allow=always" | ||
| 1340 | + submodule = Submodule(rw_repo, b"\0" * 20, name="new", path="new", url=str(tmp_dir)) | ||
| 1341 | + | ||
| 1342 | + with self.assertRaises(UnsafeOptionError): | ||
| 1343 | + submodule.update(clone_multi_options=[payload]) | ||
| 1344 | + assert not submodule.module_exists() | ||
| 1345 | + | ||
| 1335 | 1346 | @with_rw_repo("HEAD") | |
| 1336 | 1347 | def test_submodule_update_unsafe_options_allowed(self, rw_repo): | |
| 1337 | 1348 | with tempfile.TemporaryDirectory() as tdir: | |
0 commit comments