Summary
rtk git diff <branch> silently produces no output when the branch name contains a forward slash (e.g. feature/user-auth, main...feature/user-auth). Native git diff works correctly. Exit code is 0, so there is no error signal.
Root Cause
normalize_diff_args uses a string heuristic to decide whether to inject -- before positional arguments:
fn looks_like_path(arg: &str) -> bool {
arg.contains('/') || arg.contains('\\') || arg.starts_with('.') || arg.starts_with('~')
}
Any argument containing / is treated as a file path. This causes rtk git diff feature/user-auth to be silently rewritten as git diff -- feature/user-auth, which tells git to treat the branch name as a pathspec — no matching file exists, so output is empty.
Reproduction
# Setup a fresh repo
mkdir /tmp/rtk-repro && cd /tmp/rtk-repro
git init
git commit --allow-empty -m "initial commit"
git checkout -b feature/user-auth
echo 'export function login(user, pass) { return auth(user, pass); }' > auth.js
echo 'export function logout() { clearSession(); }' >> auth.js
git add auth.js && git commit -m "add user auth module"
git checkout main
# Branch name with slash — native works, rtk empty
$ git diff feature/user-auth
diff --git a/auth.js b/auth.js
deleted file mode 100644
index 3f362f7..0000000
--- a/auth.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export function login(user, pass) { return auth(user, pass); }
-export function logout() { clearSession(); }
$ rtk git diff feature/user-auth
(no output, exit code 0)
# Range syntax with slash — native works, rtk empty
$ git diff main...feature/user-auth
diff --git a/auth.js b/auth.js
new file mode 100644
index 0000000..3f362f7
--- /dev/null
+++ b/auth.js
@@ -0,0 +1,2 @@
+export function login(user, pass) { return auth(user, pass); }
+export function logout() { clearSession(); }
$ rtk git diff main...feature/user-auth
(no output, exit code 0)
Expected Behavior
rtk git diff feature/user-auth and rtk git diff main...feature/user-auth should produce the same output as their native git diff equivalents.
Workaround
Use a commit hash instead of a branch name:
rtk git diff $(git rev-parse feature/user-auth)
Environment
- rtk: 0.37.1
- OS: macOS (Apple Silicon)
- Shell: zsh
Investigated and reproduced with the assistance of Claude (claude-sonnet-4-6).
Summary
rtk git diff <branch>silently produces no output when the branch name contains a forward slash (e.g.feature/user-auth,main...feature/user-auth). Nativegit diffworks correctly. Exit code is 0, so there is no error signal.Root Cause
normalize_diff_argsuses a string heuristic to decide whether to inject--before positional arguments:Any argument containing
/is treated as a file path. This causesrtk git diff feature/user-authto be silently rewritten asgit diff -- feature/user-auth, which tells git to treat the branch name as a pathspec — no matching file exists, so output is empty.Reproduction
Expected Behavior
rtk git diff feature/user-authandrtk git diff main...feature/user-authshould produce the same output as their nativegit diffequivalents.Workaround
Use a commit hash instead of a branch name:
rtk git diff $(git rev-parse feature/user-auth)Environment
Investigated and reproduced with the assistance of Claude (claude-sonnet-4-6).