rtk-ai / rtk-ai/rtk

rtk diff: line-ending and trailing-newline differences go unreported when a line change coexists

Open
#3,901 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 21h
Merged PRs (30d)
35

Description

Split out of #3268, where @KuSh found it during review. It is not a regression: develop gates on the same condition.

InvisibleDifference is reached only when the line-level diff is empty, so a CRLF or trailing-newline difference that coexists with a content change is never mentioned.

file1 = "alpha\nbeta\n"   file2 = "alpha\r\ngamma"

rtk:  ~   2 beta → gamma
GNU:  1,2c1,2   (line 1 differs too)  +  "\ No newline at end of file"

A reader concludes that line 1 is byte-identical and that both files end in a newline. Neither is true. The exit code is 1 either way, so this is narrower than the false-identity bug #3268 closes, but it is the same class: a difference str::lines() normalises away is not reported.

tests/diff_byte_accuracy_test.rs covers the pure-invisible case only.

Sketch: run the CRLF-position and trailing-newline checks in describe_invisible_difference on every comparison rather than only when the hunks are empty, and when the hunks are non-empty append the result as one indented note under the listing. The note is a few dozen bytes and fires only when such a difference exists, so never_worse should rarely see it, but that needs measuring on the 120-diff corpus before it ships.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with describe_invisible_difference and tests/diff_byte_accuracy_test.rs, which currently covers only the pure-invisible case. Trace how comparisons with non-empty hunks are formatted, then add coverage for the CRLF-position and trailing-newline cases described here. Check the never_worse result against the 120-diff corpus; done means the coexistence differences are reported without regressing that corpus.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.