feat(git): extend the native gitstatus engine beyond status - #7843
Merged
Conversation
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.
📦 Release binary size reportCompares this PR's release-equivalent build against the latest published release, per OS (amd64).
🎉 Binary size shrank on at least one platform. |
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.
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.
Prerequisites
Description
Extends the native
gitstatusengine (currently used forgit statusbehind thenative_statusoption) 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— replacesrev-parse HEADLoadCommit— replaceslog -1 --decorate=full(author/committer/subject plus branch/tag/remote decoration)ExactTag— replacesdescribe --tags --exact-match, including peeling annotated tags; falls back to exec on an ambiguous multi-tag match rather than guessingAheadBehind/ResolveRef— reuses the existing paint-down-to-common walk for the push-remote ahead/behind countsWires these into the git segment's
Commit(),Kraken(),resolveDetachedHEAD, andsetPushStatus, all gated behind the existingnative_statusoption alongsidesetStatusNative.setUser()now readsuser.name/user.emailfrom the already-parsed repo-local config first (matching the existinggetPushRemote/getRemoteURLpattern), 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'sworktree list(breaks under--separate-git-dir), andname-revfor 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