# `git diff` fails to detect large re-indented blocks even with --color-moved-ws=allow-indentation-change

1 messages from 2020-02-24 to 2020-02-24. Participants: Timothee Cour.
Thread: https://gitlist.dev/t/52875

## Timothee Cour, 2020-02-24 00:44

Subject: `git diff` fails to detect large re-indented blocks even with --color-moved-ws=allow-indentation-change
Message-ID: <CANri+EzQZLg2djKvLxbPWh_8fr8oEqvaFF5BB1eAMCOYuB+4_w@mail.gmail.com>
URL: https://gitlist.dev/e/CANri%2BEzQZLg2djKvLxbPWh_8fr8oEqvaFF5BB1eAMCOYuB%2B4_w%40mail.gmail.com

```
see https://github.com/timotheecour/Nim/pull/37 for a self-contained
minimal example

the actual diff contains a single large re-indented block (re-indented
by 2 spaces); and a single re-indented line within that large block:
## * getTempDir proc <#getTempDir>_

none of the tools I know of helps viewing the diff in this case:

* problem 1: https://github.com/timotheecour/Nim/pull/37/files?w=1
completely ignores the re-indented single line within the block
* problem 2: https://github.com/timotheecour/Nim/pull/37/files shows a
large complex diff composed of multiple diff blocks, hard to spot
whether code was changed or whether it's just re-indent
* git diff --color-moved-ws=allow-indentation-change --color-moved=blocks HEAD^
this suffers from problem 1 and problem 2: the diff is complex and
shows multiple blocks
* git diff --color-moved-ws=allow-indentation-change --color-moved
HEAD^ does not suffer from problem 1 but suffers from problem 2: the
diff is complex and shows multiple blocks; see comment below

* even without reasoning about moved code (eg `--color-moved`), there
is no `git diff` option I know of that correctly identifies blocks of
text that were merely re-indented UNIFORMLY.

I've show the `git diff` output in that PR.  It makes it really hard
to review diffs that are composed of essentially re-indentation; and
to identify deviations from uniform re-indentation within re-indented
blocks. Uniform re-indentation is important for correctness in
whitespace sensitive languages such as python, nim, where a spurious
re-indentation could introduce a subtle behavior change; this should
be visible, not ignored.

## expected git diff output
perhaps an option `--color-moved-ws=smart-indentation-change` should
be introduced which would group code by uniform re-indentation level,
and would show how much each block was re-indented by (positive or
negative). In example from that PR, it should show a large re-indented
block in 1 color, and show in another color the re-indented single
line


(ref: D20200223T154500)

```
