Skip to content

fix(diff): report modified lines instead of "Files are identical" - #1144

Closed
ousamabenyounes wants to merge 1 commit into
rtk-ai:developfrom
ousamabenyounes:fix/issue-781
Closed

ousamabenyounes wants to merge 1 commit into
rtk-ai:developfrom
ousamabenyounes:fix/issue-781

Conversation

@ousamabenyounes

@ousamabenyounes ousamabenyounes commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Root cause: run() checked diff.added == 0 && diff.removed == 0 but ignored diff.modified. When two lines share a common prefix (e.g. "abcd" vs "abce"), the Jaccard character-set similarity is 0.6 > 0.5 — classified as Modified, not Added/Removed. With modified=1, added=0, removed=0 the old guard fell through to "[ok] Files are identical".
  • Fix: Added && diff.modified == 0 to the identical guard — one character change.

Minimal repro (from the issue)

# Before fix — incorrectly reports identical:
printf "abcd\n" > /tmp/a.txt && printf "abce\n" > /tmp/b.txt
rtk diff /tmp/a.txt /tmp/b.txt
# → [ok] Files are identical  ← WRONG

# After fix:
# → /tmp/a.txt → /tmp/b.txt
#    +0 added, -0 removed, ~1 modified
# ~   1 abcd → abce

Test plan

  • test_identical_check_requires_zero_modified — DiffResult with modified=1 must not be identical
  • test_modified_lines_not_reported_as_identical — "abcd" vs "abce" → modified=1
  • test_modified_line_with_common_prefix — "foo bar" vs "foo baz" → modified=1
  • All existing test_compute_diff_* and test_similarity_* tests pass
  • cargo fmt --all && cargo clippy --all-targets && cargo test --all ✅

Fixes #781

🤖 Generated with Ora Studio


Vibe Coded by Ousama Ben Younes
Developed With Ora Studio (Claude Code)

@CLAassistant

CLAassistant commented Apr 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

The identical check in `run()` only tested `added == 0 && removed == 0`,
ignoring `modified`. When two lines share a long common prefix (e.g.
"abcd" vs "abce"), `similarity()` returns > 0.5 so `compute_diff`
classifies them as Modified (not Added/Removed). With `modified > 0`
but `added == 0` and `removed == 0`, the old guard incorrectly fell
through to the "[ok] Files are identical" branch.

Fix: add `&& diff.modified == 0` to the identical guard.

Repro from the issue report:
  printf "abcd\n" > /tmp/a.txt && printf "abce\n" > /tmp/b.txt
  rtk diff /tmp/a.txt /tmp/b.txt  # now correctly shows ~1 modified

Fixes #781

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ousamabenyounes ousamabenyounes closed this by deleting the head repository May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants