Repository navigation
fix(git): propagate exit code on git worktree list failure - #2499
Merged
aeppling merged 3 commits intoJun 26, 2026
Merged
Conversation
run_worktree list mode never checked result.success() — a failed `git worktree list` (e.g. run outside a repo) was flattened to empty output + exit 0. The has_action branch already guards on success; apply the same guard to list mode and surface git's error with its exit code. Part of rtk-ai#2497
This was referenced Jun 18, 2026
Per review (rtk-ai#2498): self-explanatory guard; remove comment to avoid noise.
Merged
Contributor
|
@hgunduzoglu Same problem on #2500 , otherwise LGTM :) |
Contributor
|
Thanks for contributing to RTK ! |
aeppling
approved these changes
Jun 26, 2026
| let result = exec_capture(&mut cmd).context("Failed to run git worktree list")?; | ||
|
|
||
| if !result.success() { | ||
| eprintln!("FAILED: git worktree list"); |
Contributor
There was a problem hiding this comment.
The result should already contain the git error and if not we should just be transparent, writing our own error message like this is not a good idea
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 (2/3).
Problem
rtk git worktree(list mode) never checkedresult.success()— a failedgit worktree list(e.g. run outside a repository) was flattened to empty output + exit 0. Thehas_actionbranch right above it (add/remove/prune/…) already guards on success and returns the real exit code; only list mode was missing the guard.Fix
Add
if !result.success()before the format/print/Ok(0)fall-through: surfacegit's stderr (with aFAILED: git worktree listheader, matching the sibling handlers) and returnresult.exit_code.Testing
test_run_worktree_list_propagates_failure: runsrun_worktreeagainst a non-git temp dir viagit -C, asserts a non-zero exit (!= 0, exit-code-agnostic / cross-platform).cargo fmt --all --check && cargo clippy --all-targets && cargo test— clean, 2200 passed.Same masking-failure class as #1581 / #1535 / #2446 / #2494.
run_statusis #2498;run_stashPR follows.