Skip to content

feat(git): extend the native gitstatus engine beyond status - #7843

Merged
JanDeDobbeleer merged 3 commits into
mainfrom
claude/git-cli-custom-logic-t8svdb
Aug 30, 2026
Merged

feat(git): extend the native gitstatus engine beyond status#7843
JanDeDobbeleer merged 3 commits into
mainfrom
claude/git-cli-custom-logic-t8svdb

Conversation

@JanDeDobbeleer

@JanDeDobbeleer JanDeDobbeleer commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).

Description

Extends the native gitstatus engine (currently used for git status behind the native_status option) to cover more of the git segment's CLI calls, following the same pattern: read the repository's on-disk state directly, and fall back to exec git whenever the engine can't confidently answer.

Adds to gitstatus:

  • LoadHead — replaces rev-parse HEAD
  • LoadCommit — replaces log -1 --decorate=full (author/committer/subject plus branch/tag/remote decoration)
  • ExactTag — replaces describe --tags --exact-match, including peeling annotated tags; falls back to exec on an ambiguous multi-tag match rather than guessing
  • AheadBehind / ResolveRef — reuses the existing paint-down-to-common walk for the push-remote ahead/behind counts

Wires these into the git segment's Commit(), Kraken(), resolveDetachedHEAD, and setPushStatus, all gated behind the existing native_status option alongside setStatusNative. setUser() now reads user.name/user.email from the already-parsed repo-local config first (matching the existing getPushRemote/getRemoteURL pattern), falling back to exec whenever either key is missing locally so a global-only gitconfig still resolves correctly.

Left as exec-only for now (documented, not attempted in this pass): LatestTag's nearest-ancestor tag lookup and Kraken's root-commit lookup (both need a full ancestry walk), MainWorktree's worktree list (breaks under --separate-git-dir), and name-rev for rebase-state display (rare path).

Validated with parity tests in both packages comparing native output to the real git CLI (branch and detached-HEAD checkouts, lightweight/annotated/ambiguous tags, decorated commits with local/remote/tag refs, and ahead/behind push counts), plus manual validation against this repository itself.


Generated by Claude Code

Follows the pattern the native_status option already established for
`git status`: read the repository's on-disk state directly instead of
spawning git, falling back to exec on anything the engine can't
confidently answer.

Adds to gitstatus:
- LoadHead: resolves HEAD without a `rev-parse HEAD` spawn.
- LoadCommit: reads a commit's author/committer/subject and the local
  branches, tags, and remote-tracking branches decorating it, replacing
  `git log -1 --decorate=full`.
- ExactTag: mirrors `git describe --tags --exact-match`, including
  peeling annotated tags; falls back on an ambiguous multi-tag match
  rather than guessing.
- AheadBehind/ResolveRef: reuses the existing paint-down-to-common walk
  for the push-remote ahead/behind counts.

Wires these into the git segment's Commit(), Kraken(), resolveDetachedHEAD,
and setPushStatus, all gated behind the existing native_status option
alongside setStatusNative. setUser() now reads user.name/user.email from
the already-parsed repo-local config first (matching the existing
getPushRemote/getRemoteURL pattern), falling back to exec whenever either
key is missing locally so a global-only gitconfig still resolves
correctly.

Validated against real repositories (this repo included) with parity
tests comparing native output to the real git CLI for branch and
detached-HEAD checkouts, annotated/lightweight/ambiguous tags, decorated
commits with local/remote/tag refs, and ahead/behind push counts.
@github-actions

Copy link
Copy Markdown

📦 Release binary size report

Compares this PR's release-equivalent build against the latest published release, per OS (amd64).

OS Baseline This PR Delta
darwin 14.16 MB 14.18 MB +24.3 KB (+0.17%)
linux 13.82 MB 13.84 MB +24.0 KB (+0.17%)
windows 14.33 MB 14.31 MB -17.8 KB (-0.12%)

🎉 Binary size shrank on at least one platform.

claude added 2 commits August 30, 2026 17:33
CI's fieldalignment check flagged CommitInfo for 8 extra leading bytes
of pointer data; reordering Refs after the string fields matches what
fieldalignment -fix produces.
fileContent() always joins folder+"/"+file, regardless of OS, but the
test built its mock's expected key with filepath.Join, which uses
backslashes on Windows. That mismatch made the mock call unexpected on
the windows-latest CI runner. Build the expected key the same way
fileContent() does.
@JanDeDobbeleer
JanDeDobbeleer merged commit 857a49a into main Aug 30, 2026
14 checks passed
@JanDeDobbeleer
JanDeDobbeleer deleted the claude/git-cli-custom-logic-t8svdb branch August 30, 2026 19:34
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