fix: split refspecs on the last colon, like Git does - #2888
Merged
Sebastian Thiel (Byron) merged 2 commits intoAug 6, 2026
Conversation
`parse_refspec()` in `refspec.c` locates the separator with `rhs = strrchr(lhs, ':')`, so everything before the final colon is the source. That matters for push, where the source is a revision rather than a ref name and may itself contain a colon - `:/message` searches commit messages, `<rev>:<path>` addresses a blob or tree. Both are accepted by Git today. Splitting on the first colon instead made `:/message:refs/heads/x` parse as the destination `message:refs/heads/x`, which is not a valid reference name, so the spec was rejected outright. Fetch is unaffected, as its source is a ref name that cannot contain a colon. Baseline entries cover both operations; both archives are regenerated because the archive identity derives from the fixture script.
Sebastian Thiel (Byron)
force-pushed
the
refspec-last-colon
branch
from
August 6, 2026 18:05
5fc127c to
9864e70
Compare
Member
|
Thanks a lot, great catch!
This sounds like a bug in Git? If not, let's haeve a PR |
Sebastian Thiel (Byron)
enabled auto-merge
August 6, 2026 18:11
Sebastian Thiel (Byron)
merged commit Aug 6, 2026
04b91a1
into
GitoxideLabs:main
26 of 56 checks passed
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.
Created by Claude Code on behalf of Amey, who reviewed it before submitting. Everything below this line is the agent's writing, not his.
Summary
Git baseline
parse_refspec()inrefspec.cfinds the separator withrhs = strrchr(lhs, ':'), so everything before the final colon is the source. That matters for push, where the source is a revision rather than a ref name, and revisions may contain colons —:/messagesearches commit messages, and<rev>:<path>addresses a blob or tree.Both work in Git today:
gix-refspecsplit on the first colon, so it read the destination asfindme-marker:refs/heads/viaregex, rejected that as an invalid reference name, and the spec never parsed.Fetch is unaffected: its source is a ref name, which cannot contain a colon, so Git rejects the same inputs there. The added baseline entries cover both directions.
Validation
parse_baseline.shruns every spec through real Git viagit ls-remote, so the six new entries record Git's own verdict rather than an expectation. Reverting the change makes that test fail withOut of 84 baseline entries, got 80 right, (4 mismatches and 0 panics)— the four push forms.cargo test -p gix-refspecGIX_TEST_FIXTURE_HASH=sha256cargo test -p gixcargo fmt --check -p gix-refspecBoth
parse_baseline.tarandparse_baseline_sha256.tarare regenerated. The archive identity is derived from the fixture script, so leaving the second one stale would have it rewritten on the next local run ofjust unit-tests, which exercises this crate undersha256.One thing stays divergent, and it isn't the split:
::aparses in Git because a non-glob push source is not validated at all —/* anything goes, for now */— whilegix-refspecrequires the source to be a ref name or a revision. That is unchanged here.cargo clippy -p gix-refspeccannot be run on its own in this checkout; it stops ongix-hash's owncompile_error!about hash feature selection, which is unrelated to this change.