FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: validate checkout positional reference options by Byron · Pull Request #2233 · gitpython-developers/GitPython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions doc/source/changes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog
Security fixes for

* https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-gq48-pqfc-9p58
* https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-23mf-xhv8-69c2

If you can, also try and provide feedback on the upcoming v4 branch
https://github.com/gitpython-developers/GitPython/pull/2177 - patches welcome.
Expand Down
2 changes: 1 addition & 1 deletion git/refs/head.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def checkout(
"""
if not allow_unsafe_options:
Git.check_unsafe_options(
options=Git._option_candidates([], kwargs),
options=Git._option_candidates([self], kwargs),
unsafe_options=Git.unsafe_git_pathspec_from_file_options,
)
kwargs["f"] = force
Expand Down
19 changes: 19 additions & 0 deletions test/test_refs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,25 @@ def test_head_checkout_rejects_pathspec_from_file(self, rw_repo):
pathspec_file_nul=True,
**{option_name: str(pathspecs)},
)
for option_name in ("--pathspec-from-file", "--pathspec-from"):
branch = Head(rw_repo, f"refs/heads/{option_name}={pathspecs}")
with self.assertRaises(UnsafeOptionError):
branch.checkout()

def test_cloned_head_checkout_rejects_pathspec_from_file(self):
with tempfile.TemporaryDirectory() as tdir:
base_dir = Path(tdir)
with self._repo_with_initial_commit(base_dir) as source:
branch = source.create_head("--pathspec-from-file=pathspecs")
source.head.reference = branch
with Repo.clone_from(source.working_tree_dir, base_dir / "clone") as cloned:
(base_dir / "clone" / "pathspecs").write_text("unmatched-private-content\n", encoding="utf-8")
assert cloned.active_branch.name == branch.name
with self.assertRaises(UnsafeOptionError):
cloned.active_branch.checkout()
with self.assertRaises(GitCommandError) as error:
cloned.active_branch.checkout(allow_unsafe_options=True)
assert "unmatched-private-content" in str(error.exception)

@with_rw_repo("HEAD")
def test_head_reset_rejects_pathspec_from_file(self, rw_repo):
Expand Down
Loading

Back | FazBrowse Home | New Git URL