All of lore.kernel.org
 help / color / mirror / Atom feed
From: Timothee Cour <thelastmammoth@gmail.com>
To: git@vger.kernel.org
Subject: `git diff` fails to detect large re-indented blocks even with --color-moved-ws=allow-indentation-change
Date: Sun, 23 Feb 2020 16:44:28 -0800	[thread overview]
Message-ID: <CANri+EzQZLg2djKvLxbPWh_8fr8oEqvaFF5BB1eAMCOYuB+4_w@mail.gmail.com> (raw)

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)

                 reply	other threads:[~2020-02-24  0:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANri+EzQZLg2djKvLxbPWh_8fr8oEqvaFF5BB1eAMCOYuB+4_w@mail.gmail.com \
    --to=thelastmammoth@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=timothee.cour2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.