Skip to content

use gix::Id::shorten for legacy commit display IDs in but CLI#12633

Open
Byron wants to merge 3 commits intogitbutlerapp:masterfrom
Byron:codex/use-gix-id-shorten
Open

use gix::Id::shorten for legacy commit display IDs in but CLI#12633
Byron wants to merge 3 commits intogitbutlerapp:masterfrom
Byron:codex/use-gix-id-shorten

Conversation

@Byron
Copy link
Collaborator

@Byron Byron commented Mar 1, 2026

Tasks

  • review
    • double-check usages of lead,rest print
  • make it fast

Review Notes

but oplog changed as I am using uniformly shortened commit-ids instead.

Compare after and before.

Screenshot 2026-03-01 at 15 51 51

To my mind, there is no need for the extra coloring, particularly now where the shortening takes care of disambiguating prefixes, while respecting core.abbrev.

@vercel
Copy link

vercel bot commented Mar 1, 2026

@chatgpt-codex-connector[bot] is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

Otherwise, each shorten will hit the disk to check for added objects,
and we cannot have that.
@Byron Byron force-pushed the codex/use-gix-id-shorten branch from 116359e to d65bc2c Compare March 1, 2026 14:48
Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
@Byron Byron force-pushed the codex/use-gix-id-shorten branch from d65bc2c to c9bcd53 Compare March 1, 2026 14:49
@Byron Byron marked this pull request as ready for review March 1, 2026 14:49
@Byron Byron requested a review from krlvi as a code owner March 1, 2026 14:49
Copilot AI review requested due to automatic review settings March 1, 2026 14:49
@Byron Byron requested a review from Caleb-T-Owens as a code owner March 1, 2026 14:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the but CLI’s legacy command output to use gix’s repository-aware commit ID shortening (honoring core.abbrev and disambiguation), replacing fixed [..7] slicing and improving performance in high-volume display paths.

Changes:

  • Add shared commit/object-id helpers (shorten_object_id, shorten_hex_object_id, split_short_id) and wire them into legacy CLI output.
  • Introduce RepositoryExt::for_commit_shortening() to avoid ODB refresh overhead when only shortening IDs for display.
  • Update relevant legacy commands and one snapshot test expectation to reflect the new abbreviated-ID formatting.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/but/tests/but/command/commit.rs Updates oplog snapshot expectation to use the new short-hash placeholder.
crates/but/src/utils/object_id.rs Adds shared helpers for repo-disambiguated object-id shortening and display splitting.
crates/but/src/utils/mod.rs Re-exports the new object-id helper utilities.
crates/but/src/id/mod.rs Exposes ShortId alias for use outside the id module.
crates/but/src/command/legacy/teardown.rs Uses repo-aware shortening for snapshot/commit IDs in human output.
crates/but/src/command/legacy/status/mod.rs Switches multiple commit-id displays to repo-aware shortening; updates assignment/commit rendering to avoid brittle slicing.
crates/but/src/command/legacy/show.rs Uses repo-aware shortening for branch commit lists.
crates/but/src/command/legacy/rub/undo.rs Uses repo-aware shortening when printing the uncommitted commit ID.
crates/but/src/command/legacy/rub/squash.rs Uses repo-aware shortening in squash result output.
crates/but/src/command/legacy/rub/move_commit.rs Uses repo-aware shortening in move-to-branch output.
crates/but/src/command/legacy/rub/move.rs Uses repo-aware shortening in move-related human and JSON hint messages.
crates/but/src/command/legacy/rub/mod.rs Uses repo-aware shortening in disambiguation prompts; adds repo config for fast shortening.
crates/but/src/command/legacy/rub/amend.rs Uses repo-aware shortening + split styling for amended commit IDs.
crates/but/src/command/legacy/resolve.rs Uses repo-aware shortening in conflict-resolution messages and errors.
crates/but/src/command/legacy/push.rs Uses repo-aware shortening for push previews and SHA update output; configures repo for fast shortening where appropriate.
crates/but/src/command/legacy/pull/mod.rs Uses repo-aware shortening for upstream commit displays; configures repo for fast shortening.
crates/but/src/command/legacy/pick.rs Uses repo-aware shortening for user-facing picked-commit output and conflict messages; configures repo for fast shortening.
crates/but/src/command/legacy/oplog.rs Uses repo-aware shortening/length selection for oplog commit IDs; configures repo for fast shortening.
crates/but/src/command/legacy/merge.rs Uses repo-aware shortening in merge progress output.
crates/but/src/command/legacy/commit.rs Uses repo-aware shortening in “insert blank commit” success message.
crates/but/src/command/legacy/branch/show.rs Uses repo-aware shortening for commit lists shown in branch show output.
crates/but/src/command/legacy/branch/mod.rs Uses repo-aware shortening when displaying anchor commit IDs.
crates/but/src/command/legacy/absorb.rs Passes a repo configured for fast shortening into absorption plan display and shortens commit IDs via helper.
crates/but-core/src/repo_ext.rs Adds for_commit_shortening() (sets ODB refresh mode to Never) and reorders impl blocks accordingly.

Comment on lines +42 to +45
/// Return a repository configured for commit shortening,
/// i.e. with an object database configured to *not* check for new packs.
fn for_commit_shortening(self) -> Self;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this method was added.

All the other changes are an automatic "align implementation order with declaration order" refactor offered by RA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants