rtk-ai/rtk

rtk git diff prepends diffstat, breaking git apply

Open

#1,081 建立於 2026年4月8日

在 GitHub 查看
 (4 留言) (2 反應) (0 負責人)Rust (48,085 star) (2,914 fork)batch import
bugeffort-smallfilter-qualitygood first issue

描述

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

貢獻者指南