fix: validate checkout positional reference options by Byron · Pull Request #2233 · gitpython-developers/GitPython
Repository navigation
fix: validate checkout positional reference options - #2233
Merged
Byron merged 1 commit into main from clone-check-head-ref Sep 10, 2026
Merged
fix: validate checkout positional reference options #2233 Byron merged 1 commit into main from clone-check-head-ref
Conversation
Byron commented Sep 10, 2026
Copy link Copy Markdown
Member
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
- refackiew
Everything below this line was generated by Codex GPT-6.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Head.checkout() now includes its positional reference in the existing unsafe-option validation. This keeps validation consistent for keyword arguments and reference names, including references obtained from a clone, while preserving explicit opt-in and normal branch switching.
Advisory summary
GHSA-23mf-xhv8-69c2 : severity high; affected package PyPI GitPython, reported range <= 3.1.62. No patched version or CVE is assigned in the advisory. The advisory is unpublished; this description omits its reproduction details.
Validation
- Both new regression paths failed before the fix.
- All 30 tests in
test/test_refs.pypass (Python 3.12.14, Apple Git 2.50.1), including explicit opt-in, ordinary checkout, and detached HEAD behavior. git diff --checkpasses.- Git behavior reference: local Git checkout
1630431f326e15fcde608827b5ff38422528eb59,builtin/checkout.cpathspec-file handling. A leading argument separator would change branch checkout into path checkout, so this change reuses the existing validation helper.
AI
lite review requested due to automatic review settings September 10, 2026 06:10 Copilot started reviewing on behalf of Byron September 10, 2026 06:11
View session
Copilot PR reviewer Copilot
AI
reviewed Sep 10, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
🟢 Approval recommended
No unresolved review issues remain, and all reviewers assessed it as approval-ready.
Pull request overviewFixes Head.checkout() validation for unsafe positional references, with regression coverage.
Changes:
- Validates positional checkout references.
- Adds tests for local and cloned repositories.
| File | Description |
|---|---|
test/test_refs.py |
Adds regression tests for unsafe references. |
git/refs/head.py |
Validates positional checkout references. |
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
d03962f to
0f74a9b
Compare
September 10, 2026 06:30
fix: validate checkout positional reference options
8da6508
<!-- agent --> Head.checkout checked keyword options but omitted the serialized reference from its existing unsafe-option validation (GHSA-23mf-xhv8-69c2). Reference names can originate in a cloned repository, so callers could reach behavior that normally requires explicit opt-in without supplying any checkout options themselves. Pass self through the shared option-candidate helper, matching the argument actually sent to Git. This applies the existing policy to direct and cloned references, including abbreviated option spellings, while retaining allow_unsafe_options=True and ordinary checkout semantics. A leading -- separator would instead make the reference a pathspec and break branch switching. Add direct-reference regression coverage and a local clone regression using synthetic file content; the latter also verifies explicit opt-in. Both regression tests failed before the guard change. All 30 tests in test/test_refs.py pass with Python 3.12.14 and Apple Git 2.50.1; git diff --check passes. Git behavior reference: local git/git checkout at 1630431f326e15fcde608827b5ff38422528eb59, builtin/checkout.c checkout_main pathspec_from_file handling, which parses file contents as pathspecs. No Git source was copied. Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <codex@openai.com>Byron force-pushed the clone-check-head-ref branch from
0f74a9b to
8da6508
Compare
September 10, 2026 11:14 Copilot PR reviewer Copilot
AI
review requested due to automatic review settings September 10, 2026 11:14 Copilot started reviewing on behalf of Byron September 10, 2026 11:22
View session
Copilot PR reviewer Copilot
AI
reviewed Sep 10, 2026
View reviewed changes
Copilot
AI
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
🟢 Approval recommended
No unresolved review comments remain, and the validation, tests, and documentation are covered.
Review details- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
dcb6b14
into
main
Sep 10, 2026
54 checks passed
Byron
deleted the
clone-check-head-ref
branch
October 5, 2026 03:23
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment