git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 6/6] diff.c: detect blocks despite whitespace changes

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 28, 2017, 03:41 UTC
Message-ID
<xmqqshikye0o.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170628005651.8110-7-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 24 quoted lines
> Reuse the compare function from the hash map instead of calling the
> compare function directly. Then we pick the correct compare function
> when told to compare ignoring white space.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  diff.c                     |  3 +--
>  t/t4015-diff-whitespace.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+), 2 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 1d93e98e3a..4bcf938e3a 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -903,8 +903,7 @@ static void mark_color_as_moved(struct diff_options *o,
>  			struct moved_entry *p = pmb[i];
>  			struct moved_entry *pnext = (p && p->next_line) ?
>  					p->next_line : NULL;
> -			if (pnext &&
> -			    !emitted_symbol_cmp(pnext->es, l, o)) {
> +			if (pnext && !hm->cmpfn(pnext, match, NULL)) {
>  				pmb[i] = p->next_line;
>  			} else {
>  				pmb[i] = NULL;

I presume that this makes the use of emitted_symbol_cmp() vs emitted_symbol_cmp_no_ws() consistent with the remainder of the file.

Looking at the implementation of get_ws_cleaned_string() that is the workhorse of emitted_symbol_cmp_no_ws(), it seems to be doing wrong things for various "ignore whitespace" options (i.e. there is only one implementation, while "git diff" family takes things like "ignore space change", "ignore all whitespace", etc.), though.

Previous: Stefan BellerNext: Junio C Hamano
Message 13 of 18 in “Fixing up sb/diff-color-moved”
  1. 0/6 Fixing up sb/diff-color-movedStefan Beller, Jun 28, 2017
  2. 1/6 diff.c: factor out shrinking of potential moved line blocksStefan Beller, Jun 28, 2017
  3. 2/6 diff.c: change the default for move coloring to zebraStefan Beller, Jun 28, 2017
  4. Junio C HamanoJun 28, 2017
  5. Stefan BellerJun 28, 2017
  6. 3/6 diff.c: better reporting on color.moved bogus configurationStefan Beller, Jun 28, 2017
  7. 4/6 Documentation/diff: reword color movedStefan Beller, Jun 28, 2017
  8. Junio C HamanoJun 28, 2017
  9. 5/6 diff.c: omit uninteresting moved linesStefan Beller, Jun 28, 2017
  10. Junio C HamanoJun 28, 2017
  11. Stefan BellerJun 28, 2017
  12. 6/6 diff.c: detect blocks despite whitespace changesStefan Beller, Jun 28, 2017
  13. Junio C HamanoJun 28, 2017
  14. Junio C HamanoJun 28, 2017
  15. Stefan BellerJun 28, 2017
  16. Junio C HamanoJun 28, 2017
  17. Stefan BellerJun 29, 2017
  18. Junio C HamanoJun 29, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.