Skip to content

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

@t4w4n3

Description

@t4w4n3

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeffort-smallQuelques heures, 1 fichierfilter-qualityFilter produces incorrect/truncated signalgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions