fix: allow negative fetch refspec patterns#2661
Merged
Merged
Conversation
Sebastian Thiel (Byron)
marked this pull request as ready for review
June 21, 2026 08:26
Sebastian Thiel (Byron)
marked this pull request as draft
June 21, 2026 08:28
There was a problem hiding this comment.
Pull request overview
This PR updates gix-refspec to accept Git-compatible negative fetch refspec patterns like ^refs/heads/*-deploy (full refs/... source with a single *), and ensures reverse fetch mapping honors these negative source exclusions (fixes #2210).
Changes:
- Allow negative refspecs with a single-asterisk pattern when the source is a full refname (
refs/...) (still rejecting empty negatives, object IDs, destinations, partial names, multi-asterisk patterns, and invalid refname-pattern syntax). - Apply negative source filters correctly during reverse fetch matching (tracking ref → derived remote ref).
- Extend parsing/matching tests and Git-baseline fixtures to cover the new allowed negative pattern behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| gix-refspec/src/parse.rs | Permits and validates negative single-asterisk refs/... patterns via validate_negative_pattern(). |
| gix-refspec/src/match_group/mod.rs | Fixes reverse fetch negation filtering to match against derived LHS (remote source) rather than RHS. |
| gix-refspec/tests/refspec/parse/fetch.rs | Updates negative parsing expectations and adds acceptance tests for ^refs/heads/*-deploy / ^refs/tags/*-deploy. |
| gix-refspec/tests/refspec/parse/push.rs | Aligns negative parsing expectation and adds acceptance test for ^refs/heads/*-deploy (push exclude). |
| gix-refspec/tests/refspec/parse/invalid.rs | Adds negative-pattern invalid cases (multi-asterisk + invalid refname-pattern syntax). |
| gix-refspec/tests/refspec/match_group.rs | Adds baseline coverage for negative patterns and a focused reverse-mapping regression test. |
| gix-refspec/tests/fixtures/match_baseline.sh | Adds a deploy-deploy branch and baseline scenario to ensure negative *-deploy exclusions are exercised. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Issue #2210 reports that repositories with configured fetch refspecs like `^refs/heads/*-deploy` fail to open because gix-refspec rejects all negative glob patterns during parsing. Git accepts negative refspecs that name a full ref or a single-asterisk refspec pattern, while still rejecting empty negative specs, object IDs, destinations, partial names, and patterns with multiple asterisks. The Git reference points are `refspec.c::parse_refspec()` and `t/t5582-fetch-negative-refspec.sh`, which exercises negative fetch patterns. Co-authored-by: Sebastian Thiel <[email protected]>
Sebastian Thiel (Byron)
marked this pull request as ready for review
June 21, 2026 11:14
Sebastian Thiel (Byron)
force-pushed
the
negative-refspec-parsing
branch
from
June 21, 2026 11:15
0efd26e to
aa41c10
Compare
Sebastian Thiel (Byron)
enabled auto-merge
June 21, 2026 11:26
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by Codex GPT-5.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Summary
Fixes #2210.
Repositories can configure negative fetch refspec patterns such as
^refs/heads/*-deployand^refs/tags/*-deploy. Git accepts those single-asterisk negative refspec patterns, butgix-refspecrejected all negative glob patterns while parsing remote configuration.This change allows negative refspecs with a full
refs/...source and one*, while preserving rejection of empty negative specs, object IDs, destinations, partial names, unsupported multi-asterisk patterns, and invalid refname-pattern syntax. It also makes reverse fetch matching apply negative source filters to the derived source ref, so tracking-branch reverse lookup honors the same exclusions.Git Baseline
Checked against Git's
refspec.c::parse_refspec()behavior andt/t5582-fetch-negative-refspec.sh, which covers negative fetch refspecs. Added a Git-baseline fixture case with an actualdeploy-deploybranch so^refs/heads/*-deployis tested as an exclusion, not only as a parse case.Validation
GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix-refspec --test refspeccargo test -p gix-refspec --test refspeccargo fmtcargo test -p gix-refspeccargo check -p gix-refspec --no-default-features --features sha1cargo fmt --checkcodex review --commit 0efd26e2131ab0167d6181e2f4e99786c3c5a79c