GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: validate checkout positional reference options by Byron · Pull Request #2233 · gitpython-developers/GitPython

fix: validate checkout positional reference options #2233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Byron merged 1 commit into main from clone-check-head-ref
Sep 10, 2026
+21 −1
Merged

fix: validate checkout positional reference options #2233

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
8da6508
fix: validate checkout positional reference options
Byron Sep 10, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

1 change: 1 addition & 0 deletions 1 doc/source/changes.rst
Show comments
View file
Open in desktop
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 2 git/refs/head.py
Show comments
View file
Open in desktop
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 19 test/test_refs.py
Show comments
View file
Open in desktop
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
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.