Re: [BUG] `git diff` treats an unchanged line as modified
Hao Lee
Junio C Hamano
See Also
2019-12-24 19:34:43 UTC
Hao Lee <> writes:

> I think the latter is correct because the fifth line is not changed
> and it's still a line which only contains a whitespace.

As long as lines that begin with "-" and " " match what the 'old'
file has, and replacing them with lines that begin with " " and
"+" in the 'old' file yields the 'new' file, any patch is "correct".

IOW, there is no *single* diff output that is correct.

Among many "correct" diff output, there are ones that readers find
them easier to understand and those that look suboptimal.  The
differences are often personal tastes.

"git diff" has options to tweak heuristics it uses to choose among
many "correct" diff outputs, like --patience, --histogram, etc.
Perhaps using one of them would produce one that match your taste