feat: add commit name-rev support#2662
Draft
Sebastian Thiel (Byron) wants to merge 1 commit into
Draft
Conversation
Issue #1268 asks for git-name-rev style commit naming so callers can find the branch or ref context for a commit. Git's builtin/name-rev.c propagates prepared ref names backwards through the commit graph, using first-parent generation names like main~2 and side-parent markers like main^2~1. Add gix_revision::name_rev() over prepared tip data, with repository/ref collection and filtering implemented in gix::Commit::name_rev(). The gix layer reuses the describe ref collection path where useful while keeping describe's shortened tag names separate from name-rev's ref-style names. Add a basic gix commit name-rev command with --tags, --refs, --exclude, --always, --no-undefined, and --name-only. Validation: - cargo test -p gix-revision name_rev - cargo test -p gix commit::name_rev - cargo test -p gitoxide-core commit - cargo check -p gix -p gitoxide-core - cargo check -p gix-revision --all-features - cargo check -p gitoxide - cargo run -p gitoxide --bin gix -- commit name-rev --no-undefined --always --exclude=tags/* --exclude=remotes/* HEAD Note: cargo check -p gix -p gix-revision -p gitoxide-core --all-features was attempted, but gix-protocol rejects enabling its mutually exclusive blocking-client and async-client features together.
2299ed2 to
29ce60c
Compare
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
Implements Git-style commit name lookup for issue #1268.
gix_revision::name_rev()over caller-provided ref tips, so low-level revision logic only knows the prepared names it is allowed to use.gix::Commit::name_rev()with a configurable platform for ref selection, repeated include/exclude filters, and id fallback formatting.gix commit name-revwith--tags, repeated--refs <pattern>, repeated--exclude <pattern>,--always,--no-undefined, and--name-only.Issue
Fixes #1268
The issue asks for functionality similar to:
for shell integration use cases that need to find a branch/ref-based name for a commit.
Git Baseline
Used Git's
builtin/name-rev.cbehavior as the baseline: prepared ref tips are propagated backwards through the commit graph, first-parent ancestors format asname~N, side-parent paths format asname^M/name~N^M, annotated tags get^0when naming their peeled commit, and filtering is handled before the revision-layer walk.Additional spot checks compared local Git 2.50.1 with the new
gix commit name-revimplementation across branch, tag, merge, include, exclude,--tags,--always, and--name-onlycombinations.Validation
cargo fmtcargo test -p gix-revision name_revcargo test -p gix commit::name_revcargo test -p gix commit::describe::tags_preserve_the_full_git_timestamp_rangecargo test -p gitoxide-core commitcargo check -p gix -p gitoxide-corecargo check -p gix-revision --all-featurescargo check -p gitoxidejust clippy -D warnings -A unknown-lints --no-depscargo run -q -p gitoxide --bin gix -- commit name-rev --no-undefined --always --exclude='tags/*' --exclude='remotes/*' HEADGIX_TEST_FIXTURE_HASH=sha256targeted fixture tests for the new name-rev fixturescodex review --commit 29ce60c6729894abeaa230fa7801d259613dd0a1Attempted
cargo check -p gix -p gix-revision -p gitoxide-core --all-features, but it fails before this change is reached becausegix-protocolrejects enabling its mutually exclusiveblocking-clientandasync-clientfeatures together.