fix: peel revspecs to a commit in gix merge-base - #2896
Merged
Sebastian Thiel (Byron) merged 2 commits intoAug 8, 2026
Conversation
The revspecs were resolved with `rev_parse_single()` and handed to the commit-only merge-base traversal unchanged, so a revspec naming an annotated tag arrived as the id of the tag object. No commit is found for such an id and no error is raised. In a clone of this repository, `gix merge-base HEAD cargo-smart-release-v0.10.0 cargo-smart-release-v0.1.0` printed 0fa37f5, dropping the tag and computing the base of the two revspecs that were left, while `git merge-base` with the same arguments prints ceb6dff - the commit the annotated tag points at. Git dereferences tags before computing anything. Each revspec is now peeled to a commit before the traversal. Lightweight tags, branches and raw commit ids resolve as before, and a revspec that cannot be peeled to a commit is rejected with the peel error. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Member
|
Thanks, but: please do not focus on Future PRs will be closed if they appear to compare |
Sebastian Thiel (Byron)
enabled auto-merge
August 8, 2026 15:21
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.
This PR was written by an AI agent (Claude) speaking through my GitHub account.
What's wrong (AI)
A revspec that resolves to an annotated tag is not dereferenced in
gix merge-base: the id of the tag object is what reaches the commit-only traversal. In a clone of this repository, wherecargo-smart-release-v0.10.0is an annotated tag on an ancestor ofmain:git merge-basegix merge-basecargo-smart-release-v0.10.0 HEADceb6dff13362a2b4318a551893217c1d11643b9fError: No base found for cargo-smart-release-v0.10.0 and HEADHEAD cargo-smart-release-v0.10.0 cargo-smart-release-v0.1.0ceb6dff13362a2b4318a551893217c1d11643b9f0fa37f5d8c96aee551bb6442756059dc203a6cbcThe second row is a wrong answer with no error:
0fa37f5d8iscargo-smart-release-v0.1.0, the base of the two revspecs left once the tag is dropped, whileceb6dff13is the commit the annotated tag points at.gitoxide-core/src/repository/merge_base.rs:16,19resolves each revspec withrev_parse_single()and passes the result tomerge_bases_many_with_graph()unchanged.gix-revwalk'sget_or_insert_full_commitfinds no commit for a tag-object id and returns without queueing it and without reporting an error.git merge-basedereferences tags before computing anything.What this does
Each revspec is peeled to a commit before the traversal. Lightweight tags, branches and raw commit ids resolve exactly as before.
One deliberate side effect: a revspec that cannot be peeled to a commit is now rejected with the peel error.
gix merge-base 'HEAD^{tree}' HEADreportsError: Last encountered object … was tree while trying to peel to commit, closer togit'sfatal: Not a valid commit name HEAD^{tree}.Tests
Two journey tests under
gix merge-base, both in the existingsmall-repo-in-sandboxfixture, which already creates an annotated tag on the second of its three commits:gix merge-base annotated HEADcovers the error, andgix merge-base HEAD annotated unannotatedcovers the wrong answer. With the change tomerge_base.rsreverted the first fails on its exit status and the second on a snapshot mismatch — it prints the first commit where the second is correct; restored, both pass. Checked for themax,smallandasyncbinaries, since the sub-command is built into all of them.cargo test --workspacepasses, andcargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings -A unknown-lints -A unfulfilled_lint_expectations,cargo doc --workspace --no-depsandcargo run -p internal-tools -- check-modeare clean. (An earlier full-suite run here failed onegix-promptpty test under parallel load;cargo test -p gix-promptis green in isolation onmainas well as on this branch.justisn't installed on this machine, so those are the raw cargo lines, and the clippy allow is because cleanmainalready trips three of those expectations ingix-refon rustc 1.95.0. The journey run skipsjourney/ein.sh— its TUI panic snapshot needs a real terminal.)