For next final code:
I want to see what is changed: git diff -b -w --ignore-blank-lines
the line of code $data = [ map{ { id => $_-> id, ip => $_->ip } } $firewall->all ];
is displayed as moved, but it is not moved.
with --ignore-blank-lines
option I expect next result:
$ git --version
git version 2.24.0
I get expected result only if I manually in source delete 688, 689 lines.
Why git do not ignore 688, 689 lines?
git diff
never promises to show you what you actually did, nor some particular way of achieving the result you achieved. It promises only to show some set of added and deleted lines (or in word-diff mode, words) that will achieve the same result.
That aside, with the various ignore-white-space-changes options, it seems odd that Git would choose to display a sequence that says "delete some lines, then put some of them back". Note that it also said to delete the original ### Change NAS Config
and then add back a new ### Change NAS Config
that visually (i.e., disregarding any white space changes such as tabs-vs-spaces) appears identical.
The way to debug and/or diagnose this would be to provide the actual before-and-after files, or some subset of them that continues to show the same git diff
behavior when running git diff --no-index options old-file new-file
, to someone who has the time and interest in figuring out why git diff
presented a diff that was at least visually sub-optimal.
The actual algorithm involved attempts to find a change that has the fewest possible instructions, which tends to preserve existing lines, but if it can preserve multiple existing (but visually-irrelevant) lines while deleting and then re-adding some other existing (visually-relevant) lines, it may choose the one that looks worse to humans, but is equally or more efficient with respect to the number-of-changes count.
The options
for ignoring white space are meant to make the result more visually-relevant, but in this case seem to be failing. Having actual input files that trigger this case is crucial to figuring out why. I have some interest in this area, but not enough time to work on it. In any case all we can say here on StackOverflow is that this is normal: diffs do not promise to be as useful to you as you might like.