Skip to content

refactor(list): hoist short_sha onto ListItem so every row has it - #2577

Merged
max-sixty merged 1 commit into
mainfrom
push-merge-sha-abbrev
May 4, 2026
Merged

max-sixty merged 1 commit into
mainfrom
push-merge-sha-abbrev

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #2576. The parent PR routed every short-SHA display through git's abbreviation logic, but the JSON path kept a sha[..7] slice fallback for prunable worktrees and rows whose batch failed — those rows have no CommitDetails populated, so the field had nowhere to read from.

The pre-skeleton commit_details_many batch already returns %h for every row in the list, including prunable worktrees (the batch runs against the repo, not the worktree dir). Hoisting short_sha out of CommitDetails and onto ListItem directly lets the populate loops set it on every row before the prunable skip; JsonItem::from_list_item then reads item.short_sha without a fallback. CommitDetails keeps the prunable skip for the timestamp/message bundle, which is what actually preserves the old task-queue UX.

Net effect: every short-SHA emission in worktrunk now routes through git's %h/rev-parse --short machinery — no manual slicing left in the user-facing path.

This was written by Claude Code on behalf of @max-sixty

The pre-skeleton `commit_details_many` batch already returns `%h` for
every row, but the abbreviated form was tucked inside `CommitDetails` —
which is intentionally left empty for prunable worktrees and any row
missing from the batch. The JSON path then had to fall back to slicing
`sha[..7]` to keep `short_sha` populated, reintroducing the manual prefix
trick this branch's parent PR removed everywhere else.

Move `short_sha` onto `ListItem` directly. The populate loops now set it
on every row before the prunable skip, and `JsonItem::from_list_item`
reads `item.short_sha` without a fallback. `CommitDetails` shrinks to
the per-commit data (timestamp + message) it actually gates.

Co-Authored-By: Claude <[email protected]>
@max-sixty
max-sixty merged commit 2b77ff3 into main May 4, 2026
27 checks passed
@max-sixty
max-sixty deleted the push-merge-sha-abbrev branch May 4, 2026 07:11
max-sixty added a commit that referenced this pull request May 4, 2026
The last manual `&self.head[..8]` slice in the list path. Routes through
the canonical `short_sha` instead, completing the cutover started in
#2576 (every short-SHA emission through git's `%h`/`rev-parse --short`
machinery) and #2577 (hoisting `short_sha` onto `ListItem`).

When `short_sha` is empty the function returns `""`. The unborn-branch
case is caught by the branch arm. The only path where this falls through
to an empty string is "detached HEAD where the `commit_details_many`
batch failed" — already a degraded state with placeholders in every
other cell, so an empty diagnostic label is acceptable.

> _This was written by Claude Code on behalf of @max-sixty_

Co-authored-by: Claude <[email protected]>
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.

2 participants