summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorSantos Gallegos <stsewd@proton.me>2022-12-27 16:56:43 -0500
committerSantos Gallegos <stsewd@proton.me>2022-12-27 16:56:43 -0500
commitfd2c6da5f82009398d241dc07603fbcd490ced29 (patch)
tree9c83a970c472af64fe8acd4f7b0386858e684f0e /git
parente6108c7997f5c8f7361b982959518e982b973230 (diff)
downloadgitpython-fd2c6da5f82009398d241dc07603fbcd490ced29.tar.gz
Updates from review
Diffstat (limited to 'git')
-rw-r--r--git/cmd.py10
-rw-r--r--git/remote.py21
2 files changed, 14 insertions, 17 deletions
diff --git a/git/cmd.py b/git/cmd.py
index 9d4006b9..9ef1e3a6 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -488,12 +488,12 @@ class Git(LazyMixin):
"""
# Options can be of the form `foo` or `--foo bar` `--foo=bar`,
# so we need to check if they start with "--foo" or if they are equal to "foo".
- bare_options = [
+ bare_unsafe_options = [
option.lstrip("-")
for option in unsafe_options
]
for option in options:
- for unsafe_option, bare_option in zip(unsafe_options, bare_options):
+ for unsafe_option, bare_option in zip(unsafe_options, bare_unsafe_options):
if option.startswith(unsafe_option) or option == bare_option:
raise UnsafeOptionError(
f"{unsafe_option} is not allowed, use `allow_unsafe_options=True` to allow it."
@@ -1193,12 +1193,12 @@ class Git(LazyMixin):
return args
@classmethod
- def __unpack_args(cls, arg_list: Sequence[str]) -> List[str]:
+ def _unpack_args(cls, arg_list: Sequence[str]) -> List[str]:
outlist = []
if isinstance(arg_list, (list, tuple)):
for arg in arg_list:
- outlist.extend(cls.__unpack_args(arg))
+ outlist.extend(cls._unpack_args(arg))
else:
outlist.append(str(arg_list))
@@ -1283,7 +1283,7 @@ class Git(LazyMixin):
# Prepare the argument list
opt_args = self.transform_kwargs(**opts_kwargs)
- ext_args = self.__unpack_args([a for a in args if a is not None])
+ ext_args = self._unpack_args([a for a in args if a is not None])
if insert_after_this_arg is None:
args_list = opt_args + ext_args
diff --git a/git/remote.py b/git/remote.py
index 1eff00b9..520544b6 100644
--- a/git/remote.py
+++ b/git/remote.py
@@ -1029,12 +1029,11 @@ class Remote(LazyMixin, IterableObj):
self._assert_refspec()
kwargs = add_progress(kwargs, self.repo.git, progress)
- if not allow_unsafe_protocols and refspec:
- if isinstance(refspec, str):
- Git.check_unsafe_protocols(refspec)
- else:
- for ref in refspec:
- Git.check_unsafe_protocols(ref)
+ refspec = Git._unpack_args(refspec or [])
+ if not allow_unsafe_protocols:
+ for ref in refspec:
+ Git.check_unsafe_protocols(ref)
+
if not allow_unsafe_options:
Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_pull_options)
@@ -1084,12 +1083,10 @@ class Remote(LazyMixin, IterableObj):
be 0."""
kwargs = add_progress(kwargs, self.repo.git, progress)
- if not allow_unsafe_protocols and refspec:
- if isinstance(refspec, str):
- Git.check_unsafe_protocols(refspec)
- else:
- for ref in refspec:
- Git.check_unsafe_protocols(ref)
+ refspec = Git._unpack_args(refspec or [])
+ if not allow_unsafe_protocols:
+ for ref in refspec:
+ Git.check_unsafe_protocols(ref)
if not allow_unsafe_options:
Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_push_options)