Skip to content

fix(git): pass through diff diagnostic modes like --check unfiltered (#3984) - #3989

Closed
anujsingh-cse wants to merge 1 commit into
rtk-ai:developfrom
anujsingh-cse:fix/diff-check-passthrough
Closed

anujsingh-cse wants to merge 1 commit into
rtk-ai:developfrom
anujsingh-cse:fix/diff-check-passthrough

Conversation

@anujsingh-cse

Copy link
Copy Markdown

Closes #3984

Problem

rtk git diff --check emits no output at all — it silently discards every whitespace diagnostic. git diff --check is a diagnostic mode whose entire value is its stdout (one line per whitespace error, exit code 2). Under rtk, stdout was empty while exit 2 was preserved, so an agent or pre-commit script sees a failure with no reason attached.

Repro:

git --no-pager diff --check   # 4 lines of diagnostics, exit 2
rtk git diff --check          # 0 bytes, exit 2

Fix

Treat --check (plus the sibling diagnostic modes --exit-code, --quiet, --no-patch) as pass-through modes in the git diff filter. A wants_diagnostic_output helper detects these flags, and run_diff routes them to a raw pass-through branch that emits stdout and stderr verbatim and preserves the exit code — no --stat rewrite and no compaction.

Tests

  • test_wants_diagnostic_output_detects_diff_modes — all four flags detected
  • test_wants_diagnostic_output_ignores_normal_diff_args — --stat, --numstat, a path, and empty args are not diagnostic

cargo fmt --check and cargo clippy --all-targets clean; 478 git tests pass. Verified end-to-end: rtk git diff --check now prints the trailing-whitespace diagnostics and preserves exit code 2.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working git labels Sep 12, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes rtk git diff --check (and sibling diagnostic flags --exit-code, --quiet, --no-patch) so they pass through stdout/stderr and exit code unfiltered instead of being silently discarded by rtk's diff compaction logic. Adds a wants_diagnostic_output helper and a raw pass-through branch in run_diff, with unit tests covering detection of the flags.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #3984


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh

KuSh commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix and the repro. The same behaviour landed on develop through #3681 (merged 2026-09-12, commit 7931993): --check, --exit-code and --quiet are classified by the tokenizer as raw-shape flags and go straight through with git's stdout, stderr and exit code, and -s/--no-patch skip compaction since there is no body to compact. Verified on current develop with git 2.53: rtk git diff --check prints the whitespace report and exits 2, and the combined forms match raw git byte for byte. Closing as already fixed; if a diagnostic mode still comes back empty for you on develop, please comment here and it can be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working git

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants