rtk-ai/rtk

rtk git diff prepends diffstat, breaking git apply

Open

#1 081 ouverte le 8 avr. 2026

Voir sur GitHub
 (4 commentaires) (2 réactions) (0 assignés)Rust (2 914 forks)batch import
area:clibugeffort-smallfilter-qualitygood first issueplatform:macospriority:medium

Métriques du dépôt

Stars
 (48 085 stars)
Métriques de merge PR
 (Merge moyen 11j 1h) (45 PRs mergées en 30 j)

Description

Problem

rtk git diff prepends a diffstat summary before the actual diff output. This breaks git apply because the diffstat lines are not valid patch format.

Example output:

CLAUDE.local.md   | 11 +++++++++++
 src/lib/badges.ts | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/CLAUDE.local.md b/CLAUDE.local.md
index 15f4045..b9901bd 100644
...

The first 3 lines (file stats + summary) are not part of the unified diff format. When piping to git apply, it fails to parse.

Impact

This is particularly problematic when using Claude Code agents in worktrees. The typical workflow is:

  1. Spawn an agent in a worktree
  2. Extract its changes with git diff
  3. Apply the patch to the main worktree with git apply

Step 3 fails because of the prepended diffstat. The current workaround is:

git diff --no-color -U3 2>/dev/null | sed -n '/^diff --git/,$p' > /tmp/patch.patch

Expected behavior

rtk git diff should output a clean unified diff without prepending a diffstat, so the output remains compatible with git apply, git am, and other tools that consume patches.

Alternatively, the diffstat could be sent to stderr instead of stdout.

Environment

  • rtk 0.35.0
  • Hook version: 3 (freshly updated via rtk init -g)
  • macOS (Apple Silicon)
  • Claude Code

Guide contributeur