Repository navigation
fix(diff): report modified lines instead of "Files are identical" - #1144
Closed
ousamabenyounes wants to merge 1 commit into
Closed
ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
This was referenced May 13, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
run()checkeddiff.added == 0 && diff.removed == 0but ignoreddiff.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. Withmodified=1, added=0, removed=0the old guard fell through to"[ok] Files are identical".&& diff.modified == 0to the identical guard — one character change.Minimal repro (from the issue)
Test plan
test_identical_check_requires_zero_modified— DiffResult withmodified=1must not be identicaltest_modified_lines_not_reported_as_identical—"abcd"vs"abce"→modified=1test_modified_line_with_common_prefix—"foo bar"vs"foo baz"→modified=1test_compute_diff_*andtest_similarity_*tests passcargo 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)