Skip to content

rtk gh pr diff --name-only returns empty output — diff filter applied to non-diff data #730

Closed

Description

@cderv

rtk gh pr diff --name-only returns empty output. The --name-only flag changes gh pr diff output from a unified diff to a plain filename list, but the filter applies compact_diff() regardless — which expects diff --git headers, @@ hunks, and +/- lines. A plain filename list matches none of these patterns, so the filter produces empty output.

Reproduction

On any PR with changed files:

# Raw gh — lists 39 changed files
gh pr diff 1815 --repo quarto-dev/quarto-web --name-only

# Through rtk — empty output
rtk gh pr diff 1815 --repo quarto-dev/quarto-web --name-only

Claude Code with the rtk hook sees empty output and concludes "no changed files" or retries with different flags — all hitting the same empty result.

Cause

pr_diff passes --name-only through to gh (line 1125-1127), so the raw output is a filename list. But line 1144 unconditionally runs git::compact_diff(&raw, 500) on whatever comes back:

https://github.com/rtk-ai/rtk/blob/48e53cb4792e4ae8e9fb50f4e908b11a9c55a3b1/src/gh_cmd.rs#L1139-L1147

compact_diff only emits lines matching diff structure (diff --git, @@, +, -). Plain filenames match nothing, so result is empty.

Suggestion

Flags like --name-only, --stat, and --name-status change the output format away from unified diff. When any of these are present, passthrough unfiltered — the output is already compact (just filenames) and doesn't benefit from diff compaction.

Broader Pattern

This is the same class of bug as #720 — a filter that doesn't account for a flag silently produces wrong output, and the hook makes it invisible to the AI agent. The agent trusts the output and draws false conclusions.

Both could be mitigated by a general principle: when a filter produces empty output from non-empty input, emit a warning to stderr rather than silently returning nothing.

Related

Environment

  • rtk 0.30.1 (master, commit 48e53cb)
  • gh 2.74.1
  • Claude Code
  • Windows 11

Activity

  1. cderv commented on Mar 20, 2026

    @cderv
    Author

    Same workaround as #720 — we've excluded gh from the rtk hook via config.toml:

    [hooks]
    exclude_commands = ["gh"]

    gh pr diff --name-only works correctly when unproxied. The filter-level fix is still relevant — both for users without this config, and to allow re-enabling rtk's token savings on gh commands where filtering works correctly.

  2. added
    bug
    effort-small
    filter-quality
    good first issue
    on Mar 20, 2026
  3. pszymkowiak commented on Mar 20, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 95%

    Summary

    compact_diff filter unconditionally applied to gh pr diff output even when --name-only/--stat flags produce non-diff format, resulting in silent empty output; skip filtering when output format flags are present.

    💡 This looks like a simple fix that could be auto-resolved. Use /wshm fix to attempt it.

    📁 Relevant files
    • src/gh_cmd.rs

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

  4. added a commit that references this issue on Mar 21, 2026
    069a3b7
  5. mvanhorn commented on Mar 21, 2026

    @mvanhorn
    Contributor

    Implemented in #773 - added passthrough for --name-only, --stat, --name-status, --numstat, and --shortstat flags in pr_diff().

  6. added a commit that references this issue on Mar 22, 2026
    2ef0690
  7. aeppling commented on Mar 22, 2026

    @aeppling
    Contributor

    #773 merged, closing this issue, thanks for reporting & contribution !

    Will be available in next release, probably by tonight : #780

  8. added a commit that references this issue on Mar 29, 2026
    7951213
  9. added a commit that references this issue on Apr 10, 2026
    abcc6f2
  10. added 2 commits that reference this issue on May 14, 2026
    4a82327
    f4f4462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugeffort-smallfilter-qualitygood first issuepriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions