Repository navigation
fix(git): propagate exit code on git status failure in compact path - #2498
Merged
aeppling merged 3 commits intoJun 26, 2026
Merged
Conversation
The compact status path only caught the "not a git repository" error and let every other failure (corrupt index, lock contention, broken refs) fall through to a formatted "Clean working tree" + Ok(0), masking a real git error. The non-compact path already guards on result.success(); apply the same guard to the compact path, keeping the friendly not-a-repo message and propagating git's real exit code otherwise. Part of rtk-ai#2497
This was referenced Jun 18, 2026
Contributor
|
Hey @hgunduzoglu thanks clean fix, could you remove comment in all your conditions since this is pretty explicit by code ? This would just avoid accumulating noise in code. I'll merge the three parts then. |
Per review (rtk-ai#2498): the guard is self-explanatory; remove the comment to avoid noise.
hgunduzoglu
added a commit
to hgunduzoglu/rtk
that referenced
this pull request
Jun 26, 2026
Per review (rtk-ai#2498): self-explanatory guard; remove comment to avoid noise.
hgunduzoglu
added a commit
to hgunduzoglu/rtk
that referenced
this pull request
Jun 26, 2026
Per review (rtk-ai#2498): self-explanatory guards; remove comments to avoid noise.
Contributor
Author
Contributor
|
ci checks are manually triggered :) |
aeppling
approved these changes
Jun 26, 2026
Merged
Contributor
Author
windows tests returns error, I wanted to check whether it was temporary or related to the code |
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.
Part of #2497 (1/3).
Problem
rtk git status(compact path) reported a clean working tree with exit 0 whengit statusactually failed for any reason other than "not a git repository" — e.g. a corrupt index, a lock conflict, or unreadable refs. The non-compact path already guards onresult.success()(git.rs:824); the compact path only special-cased the not-a-repo string and let every other failure fall through to the formatted summary +Ok(0).Fix
Replace the narrow
"not a git repository"check with a generalif !result.success()guard (mirroring the non-compact path). The friendlyNot a git repositorymessage is preserved for that common case; any other failure surfaces git's stderr and returns its real exit code.Testing
test_run_status_compact_propagates_non_repo_failure: inits a temp repo, corrupts.git/index, assertsrun_statusreturns a non-zero exit (usesgit -Cvia global args; assertion is!= 0so it's exit-code-agnostic and cross-platform).cargo fmt --all --check && cargo clippy --all-targets && cargo test— clean, 2200 passed.* main / clean — nothing to commit, exit 0 (no regression)?? f2, exit 0 (no regression)Not a git repository, exit 128 (friendly message preserved)Same masking-failure class as #1581 / #1535 / #2446 / #2494. Sibling fixes for
run_worktreeandrun_stashwill follow as separate PRs under #2497.