git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* `git diff` fails to detect large re-indented blocks even with --color-moved-ws=allow-indentation-change
@ 2020-02-24  0:44 Timothee Cour
  0 siblings, 0 replies; only message in thread
From: Timothee Cour @ 2020-02-24  0:44 UTC (permalink / raw)
  To: git

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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-24  0:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24  0:44 `git diff` fails to detect large re-indented blocks even with --color-moved-ws=allow-indentation-change Timothee Cour

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).