| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -654,6 +654,12 @@ class Git(metaclass=_GitMeta): | |||
| 654 | 654 | "--upload-pack", | |
| 655 | 655 | ] | |
| 656 | 656 | ||
| 657 | + unsafe_git_pathspec_from_file_options = [ | ||
| 658 | + # Reads pathspecs from a caller-controlled file. Some commands include an | ||
| 659 | + # unmatched pathspec in their error output, which can disclose the file. | ||
| 660 | + "--pathspec-from-file", | ||
| 661 | + ] | ||
| 662 | + | ||
| 657 | 663 | def __getstate__(self) -> Dict[str, Any]: | |
| 658 | 664 | return slots_to_dict(self, exclude=self._excluded_) | |
| 659 | 665 | ||
@@ -1044,13 +1050,21 @@ def _option_candidates(cls, args: Sequence[Any] = (), kwargs: Optional[Mapping[s | |||
| 1044 | 1050 | values = value if isinstance(value, (list, tuple)) else (value,) | |
| 1045 | 1051 | if any(value is True or (value is not False and value is not None) for value in values): | |
| 1046 | 1052 | key = str(key) | |
| 1047 | - options.append(f"-{key}" if len(key) == 1 else f"--{dashify(key)}") | ||
| 1048 | - if len(key) == 1 and split_single_char_options: | ||
| 1053 | + if len(key) != 1: | ||
| 1054 | + options.append(f"--{dashify(key)}") | ||
| 1055 | + elif split_single_char_options: | ||
| 1056 | + options.append(f"-{key}") | ||
| 1049 | 1057 | options.extend( | |
| 1050 | 1058 | str(value) | |
| 1051 | 1059 | for value in values | |
| 1052 | 1060 | if value is not True and value not in (False, None) and str(value).startswith("-") | |
| 1053 | 1061 | ) | |
| 1062 | + else: | ||
| 1063 | + options.extend( | ||
| 1064 | + f"-{key}" if value is True else f"-{key}{value}" | ||
| 1065 | + for value in values | ||
| 1066 | + if value is True or (value is not False and value is not None) | ||
| 1067 | + ) | ||
| 1054 | 1068 | return options | |
| 1055 | 1069 | ||
| 1056 | 1070 | AutoInterrupt: TypeAlias = _AutoInterrupt | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,9 @@ | |||
| 75 | 75 | UNSAFE_CONFIG_CHARS_RE = re.compile(r"[\r\n\x00]") | |
| 76 | 76 | """Characters that cannot be safely written in config names or values.""" | |
| 77 | 77 | ||
| 78 | + VALID_CONFIG_OPTION_NAME_RE = re.compile(r"^[A-Za-z0-9_.-]+$") | ||
| 79 | + """Pattern for option names that can be written without changing config syntax.""" | ||
| 80 | + | ||
| 78 | 81 | ||
| 79 | 82 | class MetaParserBuilder(abc.ABCMeta): # noqa: B024 | |
| 80 | 83 | """Utility class wrapping base-class methods into decorators that assure read-only | |
@@ -900,6 +903,8 @@ def _value_to_string_safe(self, value: Union[str, bytes, int, float, bool]) -> s | |||
| 900 | 903 | def _assure_config_name_safe(self, name: "cp._SectionName", label: str) -> None: | |
| 901 | 904 | if isinstance(name, str) and UNSAFE_CONFIG_CHARS_RE.search(name): | |
| 902 | 905 | raise ValueError("Git config %s names must not contain CR, LF, or NUL" % label) | |
| 906 | + if label == "option" and isinstance(name, str) and not VALID_CONFIG_OPTION_NAME_RE.fullmatch(name): | ||
| 907 | + raise ValueError("Git config option names may contain only letters, digits, '-', '_', or '.'") | ||
| 903 | 908 | if label == "section" and isinstance(name, str): | |
| 904 | 909 | in_quotes = False | |
| 905 | 910 | escaped = False | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -134,6 +134,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable): | |||
| 134 | 134 | """ | |
| 135 | 135 | ||
| 136 | 136 | unsafe_git_checkout_index_options = ["--prefix"] | |
| 137 | + unsafe_git_read_tree_options = ["--index-output"] | ||
| 137 | 138 | ||
| 138 | 139 | __slots__ = ("repo", "version", "entries", "_extension_data", "_file_path") | |
| 139 | 140 | ||
@@ -259,7 +260,12 @@ def write( | |||
| 259 | 260 | ||
| 260 | 261 | @post_clear_cache | |
| 261 | 262 | @default_index | |
| 262 | - def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> "IndexFile": | ||
| 263 | + def merge_tree( | ||
| 264 | + self, | ||
| 265 | + rhs: Treeish, | ||
| 266 | + base: Union[None, Treeish] = None, | ||
| 267 | + allow_unsafe_options: bool = False, | ||
| 268 | + ) -> "IndexFile": | ||
| 263 | 269 | """Merge the given `rhs` treeish into the current index, possibly taking | |
| 264 | 270 | a common base treeish into account. | |
| 265 | 271 | ||
@@ -273,6 +279,9 @@ def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> "IndexF | |||
| 273 | 279 | Optional treeish reference pointing to the common base of `rhs` and this | |
| 274 | 280 | index which equals lhs. | |
| 275 | 281 | ||
| 282 | + :param allow_unsafe_options: | ||
| 283 | + Allow options that may write to arbitrary paths. | ||
| 284 | + | ||
| 276 | 285 | :return: | |
| 277 | 286 | self (containing the merge and possibly unmerged entries in case of | |
| 278 | 287 | conflicts) | |
@@ -283,6 +292,12 @@ def merge_tree(self, rhs: Treeish, base: Union[None, Treeish] = None) -> "IndexF | |||
| 283 | 292 | yourself, you have to commit the changed index (or make a valid tree from | |
| 284 | 293 | it) and retry with a three-way :meth:`index.from_tree <from_tree>` call. | |
| 285 | 294 | """ | |
| 295 | + if not allow_unsafe_options: | ||
| 296 | + Git.check_unsafe_options( | ||
| 297 | + options=Git._option_candidates([base, rhs]), | ||
| 298 | + unsafe_options=self.unsafe_git_read_tree_options, | ||
| 299 | + ) | ||
| 300 | + | ||
| 286 | 301 | # -i : ignore working tree status | |
| 287 | 302 | # --aggressive : handle more merge cases | |
| 288 | 303 | # -m : do an actual merge | |
@@ -327,7 +342,13 @@ def new(cls, repo: "Repo", *tree_sha: Union[str, Tree]) -> "IndexFile": | |||
| 327 | 342 | return inst | |
| 328 | 343 | ||
| 329 | 344 | @classmethod | |
| 330 | - def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile": | ||
| 345 | + def from_tree( | ||
| 346 | + cls, | ||
| 347 | + repo: "Repo", | ||
| 348 | + *treeish: Treeish, | ||
| 349 | + allow_unsafe_options: bool = False, | ||
| 350 | + **kwargs: Any, | ||
| 351 | + ) -> "IndexFile": | ||
| 331 | 352 | R"""Merge the given treeish revisions into a new index which is returned. | |
| 332 | 353 | The original index will remain unaltered. | |
| 333 | 354 | ||
@@ -351,6 +372,9 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile | |||
| 351 | 372 | :param kwargs: | |
| 352 | 373 | Additional arguments passed to :manpage:`git-read-tree(1)`. | |
| 353 | 374 | ||
| 375 | + :param allow_unsafe_options: | ||
| 376 | + Allow options that may write to arbitrary paths. | ||
| 377 | + | ||
| 354 | 378 | :return: | |
| 355 | 379 | New :class:`IndexFile` instance. It will point to a temporary index location | |
| 356 | 380 | which does not exist anymore. If you intend to write such a merged Index, | |
@@ -368,6 +392,12 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile | |||
| 368 | 392 | if len(treeish) == 0 or len(treeish) > 3: | |
| 369 | 393 | raise ValueError("Please specify between 1 and 3 treeish, got %i" % len(treeish)) | |
| 370 | 394 | ||
| 395 | + if not allow_unsafe_options: | ||
| 396 | + Git.check_unsafe_options( | ||
| 397 | + options=Git._option_candidates(treeish, kwargs), | ||
| 398 | + unsafe_options=cls.unsafe_git_read_tree_options, | ||
| 399 | + ) | ||
| 400 | + | ||
| 371 | 401 | arg_list: List[Union[Treeish, str]] = [] | |
| 372 | 402 | # Ignore that the working tree and index possibly are out of date. | |
| 373 | 403 | if len(treeish) > 1: | |
@@ -994,6 +1024,7 @@ def remove( | |||
| 994 | 1024 | self, | |
| 995 | 1025 | items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]], | |
| 996 | 1026 | working_tree: bool = False, | |
| 1027 | + allow_unsafe_options: bool = False, | ||
| 997 | 1028 | **kwargs: Any, | |
| 998 | 1029 | ) -> List[str]: | |
| 999 | 1030 | R"""Remove the given items from the index and optionally from the working tree | |
@@ -1024,6 +1055,10 @@ def remove( | |||
| 1024 | 1055 | physically removing the respective file. This may fail if there are | |
| 1025 | 1056 | uncommitted changes in it. | |
| 1026 | 1057 | ||
| 1058 | + :param allow_unsafe_options: | ||
| 1059 | + Allow unsafe options such as ``--pathspec-from-file`` to be passed to | ||
| 1060 | + :manpage:`git-rm(1)`. | ||
| 1061 | + | ||
| 1027 | 1062 | :param kwargs: | |
| 1028 | 1063 | Additional keyword arguments to be passed to :manpage:`git-rm(1)`, such as | |
| 1029 | 1064 | ``r`` to allow recursive removal. | |
@@ -1035,6 +1070,11 @@ def remove( | |||
| 1035 | 1070 | This is interesting to know in case you have provided a directory or globs. | |
| 1036 | 1071 | Paths are relative to the repository. | |
| 1037 | 1072 | """ | |
| 1073 | + if not allow_unsafe_options: | ||
| 1074 | + Git.check_unsafe_options( | ||
| 1075 | + options=Git._option_candidates([], kwargs), | ||
| 1076 | + unsafe_options=Git.unsafe_git_pathspec_from_file_options, | ||
| 1077 | + ) | ||
| 1038 | 1078 | args = [] | |
| 1039 | 1079 | if not working_tree: | |
| 1040 | 1080 | args.append("--cached") | |
@@ -1416,6 +1456,7 @@ def reset( | |||
| 1416 | 1456 | working_tree: bool = False, | |
| 1417 | 1457 | paths: Union[None, Iterable[PathLike]] = None, | |
| 1418 | 1458 | head: bool = False, | |
| 1459 | + allow_unsafe_options: bool = False, | ||
| 1419 | 1460 | **kwargs: Any, | |
| 1420 | 1461 | ) -> "IndexFile": | |
| 1421 | 1462 | """Reset the index to reflect the tree at the given commit. This will not adjust | |
@@ -1447,6 +1488,9 @@ def reset( | |||
| 1447 | 1488 | The paths need to exist at the commit, otherwise an exception will be | |
| 1448 | 1489 | raised. | |
| 1449 | 1490 | ||
| 1491 | + :param allow_unsafe_options: | ||
| 1492 | + Allow options that may write to arbitrary paths. | ||
| 1493 | + | ||
| 1450 | 1494 | :param kwargs: | |
| 1451 | 1495 | Additional keyword arguments passed to :manpage:`git-reset(1)`. | |
| 1452 | 1496 | ||
@@ -1463,7 +1507,7 @@ def reset( | |||
| 1463 | 1507 | """ | |
| 1464 | 1508 | # What we actually want to do is to merge the tree into our existing index, | |
| 1465 | 1509 | # which is what git-read-tree does. | |
| 1466 | - new_inst = type(self).from_tree(self.repo, commit) | ||
| 1510 | + new_inst = type(self).from_tree(self.repo, commit, allow_unsafe_options=allow_unsafe_options) | ||
| 1467 | 1511 | if not paths: | |
| 1468 | 1512 | self.entries = new_inst.entries | |
| 1469 | 1513 | else: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | 20 | from typing import Any, Sequence, TYPE_CHECKING, Union | |
| 21 | 21 | ||
| 22 | + from git.cmd import Git | ||
| 22 | 23 | from git.types import Commit_ish, PathLike | |
| 23 | 24 | ||
| 24 | 25 | if TYPE_CHECKING: | |
@@ -62,6 +63,7 @@ def reset( | |||
| 62 | 63 | index: bool = True, | |
| 63 | 64 | working_tree: bool = False, | |
| 64 | 65 | paths: Union[PathLike, Sequence[PathLike], None] = None, | |
| 66 | + allow_unsafe_options: bool = False, | ||
| 65 | 67 | **kwargs: Any, | |
| 66 | 68 | ) -> "HEAD": | |
| 67 | 69 | """Reset our HEAD to the given commit optionally synchronizing the index and | |
@@ -84,12 +86,21 @@ def reset( | |||
| 84 | 86 | Single path or list of paths relative to the git root directory | |
| 85 | 87 | that are to be reset. This allows to partially reset individual files. | |
| 86 | 88 | ||
| 89 | + :param allow_unsafe_options: | ||
| 90 | + Allow unsafe options such as ``--pathspec-from-file`` to be passed to | ||
| 91 | + :manpage:`git-reset(1)`. | ||
| 92 | + | ||
| 87 | 93 | :param kwargs: | |
| 88 | 94 | Additional arguments passed to :manpage:`git-reset(1)`. | |
| 89 | 95 | ||
| 90 | 96 | :return: | |
| 91 | 97 | self | |
| 92 | 98 | """ | |
| 99 | + if not allow_unsafe_options: | ||
| 100 | + Git.check_unsafe_options( | ||
| 101 | + options=Git._option_candidates([commit], kwargs), | ||
| 102 | + unsafe_options=Git.unsafe_git_pathspec_from_file_options, | ||
| 103 | + ) | ||
| 93 | 104 | mode: Union[str, None] | |
| 94 | 105 | mode = "--soft" | |
| 95 | 106 | if index: | |
@@ -234,7 +245,12 @@ def rename(self, new_path: PathLike, force: bool = False) -> "Head": | |||
| 234 | 245 | self.path = "%s/%s" % (self._common_path_default, new_path) | |
| 235 | 246 | return self | |
| 236 | 247 | ||
| 237 | - def checkout(self, force: bool = False, **kwargs: Any) -> Union["HEAD", "Head"]: | ||
| 248 | + def checkout( | ||
| 249 | + self, | ||
| 250 | + force: bool = False, | ||
| 251 | + allow_unsafe_options: bool = False, | ||
| 252 | + **kwargs: Any, | ||
| 253 | + ) -> Union["HEAD", "Head"]: | ||
| 238 | 254 | """Check out this head by setting the HEAD to this reference, by updating the | |
| 239 | 255 | index to reflect the tree we point to and by updating the working tree to | |
| 240 | 256 | reflect the latest index. | |
@@ -246,6 +262,10 @@ def checkout(self, force: bool = False, **kwargs: Any) -> Union["HEAD", "Head"]: | |||
| 246 | 262 | If ``False``, :exc:`~git.exc.GitCommandError` will be raised in that | |
| 247 | 263 | situation. | |
| 248 | 264 | ||
| 265 | + :param allow_unsafe_options: | ||
| 266 | + Allow unsafe options such as ``--pathspec-from-file`` to be passed to | ||
| 267 | + :manpage:`git-checkout(1)`. | ||
| 268 | + | ||
| 249 | 269 | :param kwargs: | |
| 250 | 270 | Additional keyword arguments to be passed to git checkout, e.g. | |
| 251 | 271 | ``b="new_branch"`` to create a new branch at the given spot. | |
@@ -261,6 +281,11 @@ def checkout(self, force: bool = False, **kwargs: Any) -> Union["HEAD", "Head"]: | |||
| 261 | 281 | the HEAD detached which is allowed and possible, but remains a special state | |
| 262 | 282 | that some tools might not be able to handle. | |
| 263 | 283 | """ | |
| 284 | + if not allow_unsafe_options: | ||
| 285 | + Git.check_unsafe_options( | ||
| 286 | + options=Git._option_candidates([], kwargs), | ||
| 287 | + unsafe_options=Git.unsafe_git_pathspec_from_file_options, | ||
| 288 | + ) | ||
| 264 | 289 | kwargs["f"] = force | |
| 265 | 290 | if kwargs["f"] is False: | |
| 266 | 291 | kwargs.pop("f") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,6 +142,14 @@ class Repo: | |||
| 142 | 142 | re_author_committer_start = re.compile(r"^(author|committer)") | |
| 143 | 143 | re_tab_full_line = re.compile(r"^\t(.*)$") | |
| 144 | 144 | ||
| 145 | + unsafe_git_init_options = [ | ||
| 146 | + # Can install hooks that execute during later Git commands: | ||
| 147 | + "--template", | ||
| 148 | + # Redirects the repository metadata to a caller-controlled path: | ||
| 149 | + "--separate-git-dir", | ||
| 150 | + ] | ||
| 151 | + """Options to :manpage:`git-init(1)` that permit unsafe code execution or I/O.""" | ||
| 152 | + | ||
| 145 | 153 | unsafe_git_clone_options = [ | |
| 146 | 154 | # Executes arbitrary commands: | |
| 147 | 155 | "--upload-pack", | |
@@ -1398,6 +1406,7 @@ def init( | |||
| 1398 | 1406 | mkdir: bool = True, | |
| 1399 | 1407 | odbt: Type[GitCmdObjectDB] = GitCmdObjectDB, | |
| 1400 | 1408 | expand_vars: bool = True, | |
| 1409 | + allow_unsafe_options: bool = False, | ||
| 1401 | 1410 | **kwargs: Any, | |
| 1402 | 1411 | ) -> "Repo": | |
| 1403 | 1412 | """Initialize a git repository at the given path if specified. | |
@@ -1422,13 +1431,22 @@ def init( | |||
| 1422 | 1431 | information disclosure, allowing attackers to access the contents of | |
| 1423 | 1432 | environment variables. | |
| 1424 | 1433 | ||
| 1434 | + :param allow_unsafe_options: | ||
| 1435 | + Allow unsafe options to be used, such as ``--template`` and | ||
| 1436 | + ``--separate-git-dir``. | ||
| 1437 | + | ||
| 1425 | 1438 | :param kwargs: | |
| 1426 | 1439 | Keyword arguments serving as additional options to the | |
| 1427 | 1440 | :manpage:`git-init(1)` command. | |
| 1428 | 1441 | ||
| 1429 | 1442 | :return: | |
| 1430 | 1443 | :class:`Repo` (the newly created repo) | |
| 1431 | 1444 | """ | |
| 1445 | + if not allow_unsafe_options: | ||
| 1446 | + Git.check_unsafe_options( | ||
| 1447 | + options=Git._option_candidates([], kwargs), | ||
| 1448 | + unsafe_options=cls.unsafe_git_init_options, | ||
| 1449 | + ) | ||
| 1432 | 1450 | if path: | |
| 1433 | 1451 | path = expand_path(path, expand_vars) | |
| 1434 | 1452 | if mkdir and path and not osp.exists(path): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -194,6 +194,43 @@ def test_set_value_rejects_unsafe_section_and_option_names(self, rw_dir): | |||
| 194 | 194 | self.assertEqual(git_config.get_value("user", "name"), "safe") | |
| 195 | 195 | self.assertFalse(git_config.has_section("core")) | |
| 196 | 196 | ||
| 197 | + @with_rw_directory | ||
| 198 | + def test_writer_rejects_invalid_option_names(self, rw_dir): | ||
| 199 | + config_path = osp.join(rw_dir, "config") | ||
| 200 | + bad_options = ( | ||
| 201 | + "name=value", | ||
| 202 | + "name#comment", | ||
| 203 | + "name;comment", | ||
| 204 | + "name with space", | ||
| 205 | + "name\twith-tab", | ||
| 206 | + "name[section", | ||
| 207 | + "name]section", | ||
| 208 | + "name:colon", | ||
| 209 | + 'name"quote', | ||
| 210 | + "name\\escape", | ||
| 211 | + ) | ||
| 212 | + | ||
| 213 | + with GitConfigParser(config_path, read_only=False) as git_config: | ||
| 214 | + git_config.add_section("user") | ||
| 215 | + for bad_option in bad_options: | ||
| 216 | + with pytest.raises(ValueError, match="option name"): | ||
| 217 | + git_config.set("user", bad_option, "unsafe") | ||
| 218 | + with pytest.raises(ValueError, match="option name"): | ||
| 219 | + git_config.set_value("user", bad_option, "unsafe") | ||
| 220 | + with pytest.raises(ValueError, match="option name"): | ||
| 221 | + git_config.add_value("user", bad_option, "unsafe") | ||
| 222 | + | ||
| 223 | + git_config.set_value("user", "safe-option1", "safe") | ||
| 224 | + git_config.set_value("user", "safe_option2", "safe") | ||
| 225 | + git_config.set_value("user", "3safe_option", "safe") | ||
| 226 | + git_config.set_value("user", "safe.option3", "safe") | ||
| 227 | + | ||
| 228 | + with GitConfigParser(config_path, read_only=True) as git_config: | ||
| 229 | + self.assertEqual(git_config.get_value("user", "safe-option1"), "safe") | ||
| 230 | + self.assertEqual(git_config.get_value("user", "safe_option2"), "safe") | ||
| 231 | + self.assertEqual(git_config.get_value("user", "3safe_option"), "safe") | ||
| 232 | + self.assertEqual(git_config.get_value("user", "safe.option3"), "safe") | ||
| 233 | + | ||
| 197 | 234 | @with_rw_directory | |
| 198 | 235 | def test_writer_rejects_unquoted_section_terminators(self, rw_dir): | |
| 199 | 236 | config_path = osp.join(rw_dir, "config") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -215,6 +215,18 @@ def test_option_candidates_ignore_untransformed_kwargs(self): | |||
| 215 | 215 | ||
| 216 | 216 | self.assertEqual(options, ["--max-count"]) | |
| 217 | 217 | ||
| 218 | + def test_option_candidates_include_falsey_non_boolean_values(self): | ||
| 219 | + kwargs = {"pathspec_from_file": 0} | ||
| 220 | + candidates = Git._option_candidates(kwargs=kwargs) | ||
| 221 | + | ||
| 222 | + self.assertEqual(candidates, ["--pathspec-from-file"]) | ||
| 223 | + self.assertEqual(self.git.transform_kwargs(**kwargs), ["--pathspec-from-file=0"]) | ||
| 224 | + with self.assertRaises(UnsafeOptionError): | ||
| 225 | + Git.check_unsafe_options( | ||
| 226 | + options=candidates, | ||
| 227 | + unsafe_options=Git.unsafe_git_pathspec_from_file_options, | ||
| 228 | + ) | ||
| 229 | + | ||
| 218 | 230 | def test_option_candidates_include_split_single_char_option_values(self): | |
| 219 | 231 | cases = [ | |
| 220 | 232 | ({"n": "--upload-pack=helper"}, ["-n", "--upload-pack=helper"], ["--upload-pack"]), | |
@@ -230,7 +242,15 @@ def test_option_candidates_include_split_single_char_option_values(self): | |||
| 230 | 242 | ||
| 231 | 243 | unsplit_kwargs = {"n": "--upload-pack=helper", "split_single_char_options": False} | |
| 232 | 244 | self.assertEqual(self.git.transform_kwargs(**unsplit_kwargs), ["-n--upload-pack=helper"]) | |
| 233 | - self.assertEqual(Git._option_candidates(kwargs=unsplit_kwargs), ["-n"]) | ||
| 245 | + self.assertEqual(Git._option_candidates(kwargs=unsplit_kwargs), ["-n--upload-pack=helper"]) | ||
| 246 | + | ||
| 247 | + def test_option_candidates_include_joined_single_char_option_values(self): | ||
| 248 | + kwargs = {"n": "uhelper", "split_single_char_options": False} | ||
| 249 | + candidates = Git._option_candidates(kwargs=kwargs) | ||
| 250 | + | ||
| 251 | + self.assertEqual(candidates, ["-nuhelper"]) | ||
| 252 | + with self.assertRaises(UnsafeOptionError): | ||
| 253 | + Git.check_unsafe_options(options=candidates, unsafe_options=["-u"]) | ||
| 234 | 254 | ||
| 235 | 255 | _shell_cases = ( | |
| 236 | 256 | # value_in_call, value_from_class, expected_popen_arg | |
| Back | FazBrowse Home | New Git URL |
0 commit comments