Repository navigation
test(git): cover exit-code propagation for git stash list/show failure - #2500
Merged
aeppling merged 1 commit intoJun 26, 2026
Merged
Conversation
3 tasks
This was referenced Jun 26, 2026
Merged
develop already propagates the exit code for failed git stash list/show (via the empty-stdout guard). Add regression tests so the masking-failure behavior (rtk-ai#2497) can't creep back.
hgunduzoglu
force-pushed
the
fix/git-stash-list-show-exit-code
branch
from
June 26, 2026 10:16
c2de29d to
c04dec1
Compare
Contributor
Author
|
Rebased onto current Rather than duplicate that, I've reset this branch to ( |
aeppling
approved these changes
Jun 26, 2026
| let result = exec_capture(&mut cmd).context("Failed to run git stash list")?; | ||
|
|
||
| if !result.success() { | ||
| eprintln!("FAILED: git stash list"); |
| let result = exec_capture(&mut cmd).context("Failed to run git stash show")?; | ||
|
|
||
| if !result.success() { | ||
| eprintln!("FAILED: git stash show"); |
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 (3/3).
Problem
run_stash'slistandshowbranches printed output and returnedOk(0)without checkingresult.success(). A failedgit stash list(e.g. outside a repo) was reported asNo stashes+ exit 0, andgit stash showfailures asEmpty stash+ exit 0. Theapply/pop/pushbranches already guard on success.Fix
Add
if !result.success()guards to both branches: surface git's stderr (FAILED: git stash list/showheader) and return the real exit code.Behavior now matches native git exactly:
stash list, no stashes (valid repo)No stashes, exit 0 ✓ (unchanged)stash list, non-git dirFAILED…exit 128 ✓stash show, no stashesNo stash entries found)stash show, non-git dirFAILED…exit 128 ✓Note
git stash listexits 0 when there are genuinely no stashes, so the friendlyNo stashessuccess path is preserved — only real failures now propagate.Testing
test_run_stash_list_propagates_failureandtest_run_stash_show_propagates_failure(non-git temp dir viagit -C, assert non-zero exit;!= 0so cross-platform).cargo fmt --all --check && cargo clippy --all-targets && cargo test— clean, 2201 passed.Completes the #2497 series (
run_status#2498,run_worktree#2499). Same masking-failure class as #1581 / #1535 / #2446 / #2494.