| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,13 +269,21 @@ def summary(self) -> Union[str, bytes]: | |||
| 269 | 269 | else: | |
| 270 | 270 | return self.message.split(b"\n", 1)[0] | |
| 271 | 271 | ||
| 272 | - def count(self, paths: Union[PathLike, Sequence[PathLike]] = "", **kwargs: Any) -> int: | ||
| 272 | + def count( | ||
| 273 | + self, | ||
| 274 | + paths: Union[PathLike, Sequence[PathLike]] = "", | ||
| 275 | + allow_unsafe_options: bool = False, | ||
| 276 | + **kwargs: Any, | ||
| 277 | + ) -> int: | ||
| 273 | 278 | """Count the number of commits reachable from this commit. | |
| 274 | 279 | ||
| 275 | 280 | :param paths: | |
| 276 | 281 | An optional path or a list of paths restricting the return value to commits | |
| 277 | 282 | actually containing the paths. | |
| 278 | 283 | ||
| 284 | + :param allow_unsafe_options: | ||
| 285 | + Allow unsafe options, like ``--output``. | ||
| 286 | + | ||
| 279 | 287 | :param kwargs: | |
| 280 | 288 | Additional options to be passed to :manpage:`git-rev-list(1)`. They must not | |
| 281 | 289 | alter the output style of the command, or parsing will yield incorrect | |
@@ -284,6 +292,11 @@ def count(self, paths: Union[PathLike, Sequence[PathLike]] = "", **kwargs: Any) | |||
| 284 | 292 | :return: | |
| 285 | 293 | An int defining the number of reachable commits | |
| 286 | 294 | """ | |
| 295 | + if not allow_unsafe_options: | ||
| 296 | + Git.check_unsafe_options( | ||
| 297 | + options=Git._option_candidates([], kwargs), unsafe_options=self.unsafe_git_rev_options | ||
| 298 | + ) | ||
| 299 | + | ||
| 287 | 300 | # Yes, it makes a difference whether empty paths are given or not in our case as | |
| 288 | 301 | # the empty paths version will ignore merge commits for some reason. | |
| 289 | 302 | if paths: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -301,6 +301,11 @@ def test_iter_items_rejects_unsafe_options(self): | |||
| 301 | 301 | with self.assertRaises(UnsafeOptionError): | |
| 302 | 302 | list(Commit.iter_items(self.rorepo, "HEAD", output=marker)) | |
| 303 | 303 | ||
| 304 | + def test_count_rejects_unsafe_options(self): | ||
| 305 | + with tempfile.NamedTemporaryFile() as marker: | ||
| 306 | + with self.assertRaises(UnsafeOptionError): | ||
| 307 | + self.rorepo.head.commit.count(output=marker.name) | ||
| 308 | + | ||
| 304 | 309 | def test_rev_list_bisect_all(self): | |
| 305 | 310 | """ | |
| 306 | 311 | 'git rev-list --bisect-all' returns additional information | |
| Back | FazBrowse Home | New Git URL |
0 commit comments