rtk-ai/rtk

`diff` reports "Files are identical" when lines differ by only a few characters

Open

#781 aberto em 22 de mar. de 2026

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Rust (2.914 forks)batch import
area:clibugeffort-smallfilter-qualitygood first issueneeds-reproductionpriority:medium

Métricas do repositório

Stars
 (48.085 stars)
Métricas de merge de PR
 (Mesclagem média 11d 1h) (45 fundiu PRs em 30d)

Description

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.

Guia do colaborador