rtk-ai / rtk-ai/rtk

rtk git diff --check emits no output at all, silently discarding every whitespace diagnostic

Open
#3,984 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli bug good first issue priority:high resolved-pending-close
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

rtk git diff --check emits no output at all, silently discarding every whitespace diagnostic

Version: rtk 0.49.0
Platform: Linux x86_64 (musl build, installed via install.sh)

Summary

git diff --check is a diagnostic mode whose entire value is its stdout: it prints one line per whitespace error and exits 2. Under rtk, stdout is empty while exit 2 is preserved.

An agent or pre-commit script therefore sees a failure with no reason attached. Worse, a script that reads the output to decide what to fix concludes there is nothing to fix, while the non-zero exit blocks the commit.

Reproduction

T=$(mktemp -d); cd "$T"; git init -q .
printf 'line one\nline two\n' > f.txt
git add -A; git -c user.email=t@t -c user.name=t commit -qm init
printf 'line one\nline two   \nline three\t\n' > f.txt   # add trailing whitespace

git --no-pager diff --check; echo "raw exit=$?"
rtk git diff --check;        echo "rtk exit=$?"
Actual
-- raw --
f.txt:2: trailing whitespace.
+line two
f.txt:3: trailing whitespace.
+line three
raw exit=2
-- rtk --
rtk exit=2

Raw: 4 lines of diagnostics + exit 2. rtk: zero bytes + exit 2.

Expected

--check output passes through unfiltered. It is already minimal (one line per offending line plus the offending line), so there is nothing to compress, and every line is actionable.

Why this one matters more than general diff reshaping

This is not a formatting difference — it is total loss of the only signal the command produces. Related but distinct from #1918 (rtk git diff breaking patch/--name-only/exit-code consumers): that issue is about generating a usable patch, whereas --check produces no patch at all and is purely a diagnostic whose output is destroyed.

Suggested fix

Treat --check (and --exit-code, --quiet, --no-patch) as diagnostic/pass-through modes in the git diff filter: detect the flag and emit raw stdout. These modes are all cases where the output is either tiny or deliberately empty, so filtering has no upside.

Discovery context

Found while auditing ~14,700 real RTK_DISABLED=1 bypasses in local agent session history. git diff --check appeared as a case where an agent bypassed rtk after getting "(no output)" with exit 2 and being unable to explain the failure.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Rust git diff filter described in the issue and reproduce the command with trailing whitespace using the provided shell steps. Treat --check and the other listed diagnostic modes as the scope, and verify that raw stdout is preserved while the exit status remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, rust
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.