git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: sbeller@google.com
Cc: git@vger.kernel.org, jacob.keller@gmail.com,
	jonathantanmy@google.com, simon@ruderich.org, bmwill@google.com
Subject: [PATCH v4 0/9] Moved code detection: ignore space on uniform indentation
Date: Thu, 28 Jun 2018 17:19:49 -0700	[thread overview]
Message-ID: <20180629001958.85143-1-sbeller@google.com> (raw)
In-Reply-To: <20180622015725.219575-1-sbeller@google.com>

v4:
 * see range diff below
 * brought best practices to t4015 and have git not upstream of a pipe
   (new patch 3)
 * squashed in the SQUASH patches
 * fixed the translation as well.

v3:
 This is a complete rewrite of the actual patch, with slight modifications]
 on the refactoring how to decouple the white space treatment from the
 move detection. See range-diff below.
 https://public-inbox.org/git/20180622015725.219575-1-sbeller@google.com/

v2: https://public-inbox.org/git/20180424210330.87861-1-sbeller@google.com/

v1: https://public-inbox.org/git/20180402224854.86922-1-sbeller@google.com/

Stefan Beller (9):
  xdiff/xdiff.h: remove unused flags
  xdiff/xdiffi.c: remove unneeded function declarations
  t4015: avoid git as a pipe input
  diff.c: do not pass diff options as keydata to hashmap
  diff.c: adjust hash function signature to match hashmap expectation
  diff.c: add a blocks mode for moved code detection
  diff.c: decouple white space treatment from move detection algorithm
  diff.c: factor advance_or_nullify out of mark_color_as_moved
  diff.c: add white space mode to move detection that allows indent
    changes

 Documentation/diff-options.txt |  30 +++-
 diff.c                         | 253 +++++++++++++++++++++++++++++----
 diff.h                         |   9 +-
 t/t4015-diff-whitespace.sh     | 243 ++++++++++++++++++++++++++-----
 xdiff/xdiff.h                  |   8 --
 xdiff/xdiffi.c                 |  17 ---
 6 files changed, 472 insertions(+), 88 deletions(-)

-- 
2.18.0.399.gad0ab374a1-goog

1:  ace2dc2bc11 = 1:  ace2dc2bc11 xdiff/xdiff.h: remove unused flags
2:  53b3574564e = 2:  53b3574564e xdiff/xdiffi.c: remove unneeded function declarations
-:  ----------- > 3:  9b58621e0d8 t4015: avoid git as a pipe input
3:  34850b565df = 4:  be0ea0717e1 diff.c: do not pass diff options as keydata to hashmap
4:  8148e51178f = 5:  ff7e8721afa diff.c: adjust hash function signature to match hashmap expectation
5:  9d1de6a208e ! 6:  73c2801a5e3 diff.c: add a blocks mode for moved code detection
    @@ -19,7 +19,7 @@
      	moved line, but it is not very useful in a review to determine
      	if a block of code was moved without permutation.
     -zebra::
    -+blocks:
    ++blocks::
      	Blocks of moved text of at least 20 alphanumeric characters
      	are detected greedily. The detected blocks are
     -	painted using either the 'color.diff.{old,new}Moved' color or
    @@ -95,10 +95,8 @@
      	test_config color.diff.newMovedDimmed "normal cyan" &&
      	test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
      	test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
    -+
    -+	git diff HEAD --no-renames --color-moved=blocks --color |
    -+		grep -v "index" |
    -+		test_decode_color >actual &&
    ++	git diff HEAD --no-renames --color-moved=blocks --color >actual.raw &&
    ++	grep -v "index" actual.raw | test_decode_color >actual &&
     +	cat <<-\EOF >expected &&
     +	<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
     +	<BOLD>--- a/lines.txt<RESET>
    @@ -141,6 +139,16 @@
     +	test_config color.diff.newMovedDimmed "normal cyan" &&
     +	test_config color.diff.oldMovedAlternativeDimmed "normal blue" &&
     +	test_config color.diff.newMovedAlternativeDimmed "normal yellow" &&
    - 	git diff HEAD --no-renames --color-moved=dimmed_zebra --color |
    - 		grep -v "index" |
    - 		test_decode_color >actual &&
    + 	git diff HEAD --no-renames --color-moved=dimmed_zebra --color >actual.raw &&
    + 	grep -v "index" actual.raw | test_decode_color >actual &&
    + 	cat <<-\EOF >expected &&
    +@@
    + 	7charsA
    + 	EOF
    + 
    +-	git diff HEAD --color-moved=zebra --color --no-renames | grep -v "index" | test_decode_color >actual &&
    ++	git diff HEAD --color-moved=zebra --color --no-renames >actual.raw &&
    ++	grep -v "index" actual.raw | test_decode_color >actual &&
    + 	cat >expected <<-\EOF &&
    + 	<BOLD>diff --git a/bar b/bar<RESET>
    + 	<BOLD>--- a/bar<RESET>
6:  e37bb7b1fc8 ! 7:  87a8919c260 diff.c: decouple white space treatment from move detection algorithm
    @@ -55,6 +55,7 @@
     +ignore-all-space::
     +	Ignore whitespace when comparing lines. This ignores differences
     +	even if one line has whitespace where the other line has none.
    ++--
     +
      --word-diff[=<mode>]::
      	Show a word diff, using the <mode> to delimit changed words.
    @@ -154,32 +155,32 @@
      	EOF
      	test_cmp expected actual &&
      
    --	git diff HEAD --no-renames -w --color-moved --color |
    +-	git diff HEAD --no-renames -w --color-moved --color >actual.raw &&
     +	git diff HEAD --no-renames --color-moved --color \
    -+		--color-moved-ws=ignore-all-space |
    - 		grep -v "index" |
    - 		test_decode_color >actual &&
    ++		--color-moved-ws=ignore-all-space >actual.raw &&
    + 	grep -v "index" actual.raw | test_decode_color >actual &&
      	cat <<-\EOF >expected &&
    + 	<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
     @@
      	EOF
      	test_cmp expected actual &&
      
    --	git diff HEAD --no-renames -b --color-moved --color |
    +-	git diff HEAD --no-renames -b --color-moved --color >actual.raw &&
     +	git diff HEAD --no-renames --color-moved --color \
    -+		--color-moved-ws=ignore-space-change |
    - 		grep -v "index" |
    - 		test_decode_color >actual &&
    ++		--color-moved-ws=ignore-space-change >actual.raw &&
    + 	grep -v "index" actual.raw | test_decode_color >actual &&
      	cat <<-\EOF >expected &&
    + 	<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
     @@
      	EOF
      	test_cmp expected actual &&
      
    --	git diff HEAD --no-renames --ignore-space-at-eol --color-moved --color |
    +-	git diff HEAD --no-renames --ignore-space-at-eol --color-moved --color >actual.raw &&
     +	git diff HEAD --no-renames --color-moved --color \
    -+		--color-moved-ws=ignore-space-at-eol |
    - 		grep -v "index" |
    - 		test_decode_color >actual &&
    ++		--color-moved-ws=ignore-space-at-eol >actual.raw &&
    + 	grep -v "index" actual.raw | test_decode_color >actual &&
      	cat <<-\EOF >expected &&
    + 	<BOLD>diff --git a/lines.txt b/lines.txt<RESET>
     @@
      
      	# nor did we mess with it another way
7:  a58e68b8880 = 8:  25279c42f25 diff.c: factor advance_or_nullify out of mark_color_as_moved
8:  f2d78d2c672 ! 9:  305f8b27589 diff.c: add white space mode to move detection that allows indent changes
    @@ -86,9 +86,9 @@
     +	group the moved code blocks only into a block if the change in
     +	whitespace is the same per line. This is incompatible with the
     +	other modes.
    + --
      
      --word-diff[=<mode>]::
    - 	Show a word diff, using the <mode> to delimit changed words.
     
     diff --git a/diff.c b/diff.c
     --- a/diff.c
    @@ -129,7 +129,7 @@
     + */
     +struct ws_delta {
     +	char *string;
    -+	int current_longer : 1;
    ++	unsigned int current_longer : 1;
      };
     +#define WS_DELTA_INIT { NULL, 0 }
     +
    @@ -339,6 +339,30 @@
     diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
     --- a/t/t4015-diff-whitespace.sh
     +++ b/t/t4015-diff-whitespace.sh
    +@@
    + 	EOF
    + 
    + 	# Make sure we get a different diff using -w
    +-	git diff --color --color-moved -w |
    +-		grep -v "index" |
    +-		test_decode_color >actual &&
    ++	git diff --color --color-moved -w >actual.raw &&
    ++	grep -v "index" actual.raw | test_decode_color >actual &&
    + 	q_to_tab <<-\EOF >expected &&
    + 	<BOLD>diff --git a/text.txt b/text.txt<RESET>
    + 	<BOLD>--- a/text.txt<RESET>
    +@@
    + 
    + 	# And now ignoring white space only in the move detection
    + 	git diff --color --color-moved \
    +-		--color-moved-ws=ignore-all-space,ignore-space-change,ignore-space-at-eol |
    +-		grep -v "index" |
    +-		test_decode_color >actual &&
    ++		--color-moved-ws=ignore-all-space,ignore-space-change,ignore-space-at-eol >actual.raw &&
    ++	grep -v "index" actual.raw | test_decode_color >actual &&
    + 	q_to_tab <<-\EOF >expected &&
    + 	<BOLD>diff --git a/text.txt b/text.txt<RESET>
    + 	<BOLD>--- a/text.txt<RESET>
     @@
      	test_cmp expected actual
      '
    @@ -383,9 +407,8 @@
     +	QQYetQAnotherQoutlier
     +	EOF
     +
    -+	git diff --color --color-moved --color-moved-ws=allow-indentation-change |
    -+		grep -v "index" |
    -+		test_decode_color >actual &&
    ++	git diff --color --color-moved --color-moved-ws=allow-indentation-change >actual.raw &&
    ++	grep -v "index" actual.raw | test_decode_color >actual &&
     +
     +	q_to_tab <<-\EOF >expected &&
     +		<BOLD>diff --git a/text.txt b/text.txt<RESET>
    @@ -429,8 +452,7 @@
     +	test_must_fail git diff \
     +		--color-moved-ws=allow-indentation-change,ignore-all-space \
     +		2>err &&
    -+	grep allow-indentation-change err
    ++	test_i18ngrep allow-indentation-change err
     +'
    -+
     +
      test_done
9:  76db2b1328f < -:  ----------- SQUASH????? Documentation breakage emergency fix
10:  d484589fad1 < -:  ----------- SQUASH??? t/4015 GETTEXT_POISON emergency fix
11:  fceb91fc99d < -:  ----------- diff: fix a sparse 'dubious one-bit signed bitfield' error

  parent reply	other threads:[~2018-06-29  0:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22  1:57 [PATCH v3 0/8] Moved code detection: ignore space on uniform indentation Stefan Beller
2018-06-22  1:57 ` [PATCH v3 1/8] xdiff/xdiff.h: remove unused flags Stefan Beller
2018-06-22  1:57 ` [PATCH v3 2/8] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2018-06-22  1:57 ` [PATCH v3 3/8] diff.c: do not pass diff options as keydata to hashmap Stefan Beller
2018-06-22  1:57 ` [PATCH v3 4/8] diff.c: adjust hash function signature to match hashmap expectation Stefan Beller
2018-06-22  1:57 ` [PATCH v3 5/8] diff.c: add a blocks mode for moved code detection Stefan Beller
2018-06-22  1:57 ` [PATCH v3 6/8] diff.c: decouple white space treatment from move detection algorithm Stefan Beller
2018-06-22  1:57 ` [PATCH v3 7/8] diff.c: factor advance_or_nullify out of mark_color_as_moved Stefan Beller
2018-06-22  1:57 ` [PATCH v3 8/8] diff.c: add white space mode to move detection that allows indent changes Stefan Beller
2018-06-23 16:52   ` SZEDER Gábor
2018-06-22 22:37 ` [PATCH v3 0/8] Moved code detection: ignore space on uniform indentation Junio C Hamano
2018-06-29  0:19 ` Stefan Beller [this message]
2018-06-29  0:19   ` [PATCH v4 1/9] xdiff/xdiff.h: remove unused flags Stefan Beller
2018-06-29  0:19   ` [PATCH v4 2/9] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2018-06-29  0:19   ` [PATCH v4 3/9] t4015: avoid git as a pipe input Stefan Beller
2018-06-29  0:19   ` [PATCH v4 4/9] diff.c: do not pass diff options as keydata to hashmap Stefan Beller
2018-06-29  0:19   ` [PATCH v4 5/9] diff.c: adjust hash function signature to match hashmap expectation Stefan Beller
2018-06-29  0:19   ` [PATCH v4 6/9] diff.c: add a blocks mode for moved code detection Stefan Beller
2018-07-02 17:18     ` Brandon Williams
2018-06-29  0:19   ` [PATCH v4 7/9] diff.c: decouple white space treatment from move detection algorithm Stefan Beller
2018-07-02 17:22     ` Brandon Williams
2018-06-29  0:19   ` [PATCH v4 8/9] diff.c: factor advance_or_nullify out of mark_color_as_moved Stefan Beller
2018-06-29  0:19   ` [PATCH v4 9/9] diff.c: add white space mode to move detection that allows indent changes Stefan Beller
2018-07-02 17:36     ` Brandon Williams
2018-07-02 18: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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20180629001958.85143-1-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.keller@gmail.com \
    --cc=jonathantanmy@google.com \
    --cc=simon@ruderich.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).