rtk-ai/rtk
在 GitHub 查看`diff` reports "Files are identical" when lines differ by only a few characters
Open
#781 建立於 2026年3月22日
bugeffort-smallfilter-qualitygood first issue
描述
Description
rtk diff incorrectly reports files as identical when modified lines share a long common prefix. The underlying /usr/bin/diff correctly detects the differences.
Version
Built from source at commit 97b6878
Minimal reproduction
# FAILS — reports identical (4+ char common prefix)
printf "abcd\n" > /tmp/a.txt
printf "abce\n" > /tmp/b.txt
rtk diff /tmp/a.txt /tmp/b.txt
# → [ok] Files are identical
# WORKS — correctly detects difference (3 char prefix)
printf "abc\n" > /tmp/a.txt
printf "abd\n" > /tmp/b.txt
rtk diff /tmp/a.txt /tmp/b.txt
# → +1 added, -1 removed
# Verification with system diff
/usr/bin/diff /tmp/a.txt /tmp/b.txt
# → 1c1 < abcd --- > abce
Additional examples
# Also fails with multi-word lines
printf "foo bar\n" > /tmp/a.txt
printf "foo baz\n" > /tmp/b.txt
rtk diff /tmp/a.txt /tmp/b.txt
# → [ok] Files are identical
# Also fails with longer content
printf "abc def\n" > /tmp/a.txt
printf "abc deg\n" > /tmp/b.txt
rtk diff /tmp/a.txt /tmp/b.txt
# → [ok] Files are identical
Expected behavior
rtk diff should report the differences, consistent with /usr/bin/diff.
Suspected cause
A similarity threshold in rtk's diff filtering appears to treat lines that are "close enough" as identical, when it should only filter output formatting — not discard actual differences.