Subject: Re: [bug-diffutils] bug#78213: should produce a diff with similar lines grouped together if possible

From: Robert Webb <[email-masked]>
Date: Sat, 3 May 2025 01:12:44 -0700

The diff to create file-bad.diff was with the '-u' option.
I used diff v3.6 with identical results.

The only lines that match between the file1 and file2 are empty ones.
This bash command shows only an empty line in common:
  comm -12 -- <(sort -u file1) <(sort -u file2)

Note: The line terminator on the provided files is CRLF.
      Long lines - Use 'less -S'  :-)

On Fri, May 2, 2025 at 7:19 AM Vincent Lefevre <[email-masked]> wrote:
>
> "diff" should produce a diff with similar lines grouped together if
> possible, so that it can be more easily readable and be word-diff
> friendly.
>
> Issues can occur on text files with paragraphs separated by a blank
> line (like in wiki source files and LaTeX files), where a modification
> consists in
>   * some paragraph being split, and
>   * some of the following paragraphs being slightly modified.
>
> In such a case, a shift of the slightly modified lines can occur,
> which makes the diff hardly readable and breaks word-diff (e.g.
> when one opens the diff file with GNU Emacs).
>
> I've attached an example:
>   * file1 and file2: the files to be diff'ed (file2 is similar to
>     file1, with the first paragraph split).
>   * file-bad.diff: the diff produced by diff 3.10.
>   * file-ok.diff: the diff I would expect.
>
> --
> Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)