git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>
Subject: [PATCH 2/2] diff.c: ignore all white space changes by default in the move detection
Date: Wed, 25 Oct 2017 15:46:20 -0700	[thread overview]
Message-ID: <20171025224620.27657-3-sbeller@google.com> (raw)
In-Reply-To: <20171025224620.27657-1-sbeller@google.com>

The coloring of moved lines is currently only related to the presentation,
as there are no options to export the move detection information into
the patch format. Hence we can be very loose about the default, so let's
ignore any white space change for the move detection. If a user really
cares about move detection detecting only lines moved byte-for-byte,
they can exercise the --color-moved-no-ignore-* options.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Documentation/diff-options.txt | 4 +++-
 diff.c                         | 1 +
 t/t4015-diff-whitespace.sh     | 6 ++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 1000b53b84..fdf40cbefc 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -269,14 +269,16 @@ dimmed_zebra::
 	Ignore whitespace when comparing lines when performing the move
 	detection for --color-moved.  This ignores differences even if
 	one line has whitespace where the other line has none.
+	This is on by default.
 --color-moved-[no-]ignore-space-change::
 	Ignore changes in amount of whitespace when performing the move
 	detection for --color-moved.  This ignores whitespace
 	at line end, and considers all other sequences of one or
 	more whitespace characters to be equivalent.
+	This is on by default.
 --color-moved-[no-]ignore-space-at-eol::
 	Ignore changes in whitespace at EOL when performing the move
-	detection for --color-moved.
+	detection for --color-moved. This is on by default.
 
 --word-diff[=<mode>]::
 	Show a word diff, using the <mode> to delimit changed words.
diff --git a/diff.c b/diff.c
index 2580315ab9..fef4874169 100644
--- a/diff.c
+++ b/diff.c
@@ -4105,6 +4105,7 @@ void diff_setup(struct diff_options *options)
 	}
 
 	options->color_moved = diff_color_moved_default;
+	options->color_moved_ignore_space = XDF_WHITESPACE_FLAGS;
 }
 
 void diff_setup_done(struct diff_options *options)
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 4ef4d6934a..a4ffc84f41 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -1813,6 +1813,12 @@ test_expect_success 'move detection only ignores white spaces' '
 	 Qbar();<RESET>
 	 Q// more unrelated stuff<RESET>
 	EOF
+	test_cmp expected actual &&
+
+	# test that this is the default:
+	git diff --color --color-moved |
+		grep -v "index" |
+		test_decode_color >actual &&
 	test_cmp expected actual
 '
 
-- 
2.15.0.rc2.6.g953226eb5f


  parent reply	other threads:[~2017-10-25 22:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 22:46 [PATCH 0/2] color-moved: ignore all space changes by default Stefan Beller
2017-10-25 22:46 ` [PATCH 1/2] diff: decouple white space treatment for move detection from generic option Stefan Beller
2017-10-25 22:46 ` Stefan Beller [this message]
2017-10-26  7:22 ` [PATCH 0/2] color-moved: ignore all space changes by default Simon Ruderich
2017-10-26  8:42   ` Jacob Keller
2017-10-26 17:59     ` Stefan Beller

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=20171025224620.27657-3-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    /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 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).