← 返回首页
Merge pull request #2130 from gitpython-developers/fix-multi-options · gitpython-developers/GitPython@da54523 · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Commit da54523

Browse files
authored
Merge pull request #2130 from gitpython-developers/fix-multi-options
Make sure that multi-options are checked after splitting them with `shlex`
2 parents 75e6c6b + c9a2678 commit da54523

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎git/repo/base.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,8 @@ def _clone(
13861386
Git.check_unsafe_protocols(url)
13871387
if not allow_unsafe_options:
13881388
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)
13911391

13921392
proc = git.clone(
13931393
multi,

‎test/test_clone.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ def test_clone_unsafe_options(self, rw_repo):
137137
rw_repo.clone(tmp_dir, **unsafe_option)
138138
assert not tmp_file.exists()
139139

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+
140149
@pytest.mark.xfail(
141150
sys.platform == "win32",
142151
reason=(
@@ -216,6 +225,15 @@ def test_clone_from_unsafe_options(self, rw_repo):
216225
Repo.clone_from(rw_repo.working_dir, tmp_dir, **unsafe_option)
217226
assert not tmp_file.exists()
218227

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+
219237
@pytest.mark.xfail(
220238
sys.platform == "win32",
221239
reason=(

‎test/test_submodule.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,17 @@ def test_submodule_update_unsafe_options(self, rw_repo):
13321332
submodule.update(clone_multi_options=[unsafe_option])
13331333
assert not tmp_file.exists()
13341334

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+
13351346
@with_rw_repo("HEAD")
13361347
def test_submodule_update_unsafe_options_allowed(self, rw_repo):
13371348
with tempfile.TemporaryDirectory() as tdir:

0 commit comments

Comments
 (0)

Footer

© 2026 GitHub, Inc.