fix(git): keep git status --porcelain empty on a clean tree - #3498
Closed
asem89 wants to merge 1 commit into
Closed
Conversation
`filter_status_with_args` collapses empty filtered output to the literal string `ok`. That is a good compaction for human-readable `git status`, but `--porcelain`, `--porcelain=v1/v2`, `-z` and `--null` are machine-readable formats where **zero bytes is the documented result**: consumers parse "no output" as "no changes". Today `rtk git status --porcelain` on a clean tree prints `ok`, so any script doing `[ -z "$(git status --porcelain)" ]` — the standard clean-tree check — sees a non-empty string and concludes the tree is dirty. `--porcelain` is not routed through the compact path (`uses_compact_status_path` returns false for it), so it lands here and gets rewritten. Pass the user's args down and skip the `ok` substitution for those four formats, echoing stdout unchanged instead. Human-readable forms, including the short `-s` flag, are unaffected.
|
|
Author
|
Closing — I'm not in a position to sign the CLA, so this can't be merged as-is. Leaving the analysis here in case a maintainer wants to reimplement it; both are small and self-contained, and the reproduction steps in the description stand on their own. No response needed. |
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.
Summary
rtk git status --porcelainprintsokon a clean tree instead of the zero bytes git emits.--porcelain,--porcelain=v1/v2,-zand--null, emptiness is the result — consumers parse "no output" as "no changes", so theokcompaction breaks them.filter_status_with_argsnow takes the user's args and skips the substitution for those four machine-readable formats. Human-readable output, including short-s, is unchanged.Why it bites
The standard clean-tree check inverts:
--porcelainisn't routed through the compact path —uses_compact_status_pathreturns false for it — so it reachesfilter_status_with_argsand gets rewritten.Test plan
cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo test --all— 2657 passed, 0 failedtest_filter_status_porcelain_clean_stays_empty(all four flags) andtest_filter_status_short_still_collapses_to_ok(guards the compaction that should stay)rtk git status --porcelain→ 0 bytes;rtk git status→ stillclean — nothing to commit