From: Phillip Wood <phillip.wood@talktalk.net>
To: Stefan Beller <sbeller@google.com>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH v1 8/9] diff --color-moved-ws: modify allow-indentation-change
Date: Sat, 17 Nov 2018 14:59:50 +0000 [thread overview]
Message-ID: <42818e32-8774-722d-b46d-9a23f4097315@talktalk.net> (raw)
In-Reply-To: <CAGZ79kb2fY+6xg=B+t=gSEBQ+u-wKAff++z5A=KiN2u0yYFF6g@mail.gmail.com>
Hi Stefan
On 16/11/2018 21:47, Stefan Beller wrote:
> On Fri, Nov 16, 2018 at 3:04 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
>>
>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>
>> Currently diff --color-moved-ws=allow-indentation-change does not
>> support indentation that contains a mix of tabs and spaces. For
>> example in commit 546f70f377 ("convert.h: drop 'extern' from function
>> declaration", 2018-06-30) the function parameters in the following
>> lines are not colored as moved [1].
>>
>> -extern int stream_filter(struct stream_filter *,
>> - const char *input, size_t *isize_p,
>> - char *output, size_t *osize_p);
>> +int stream_filter(struct stream_filter *,
>> + const char *input, size_t *isize_p,
>> + char *output, size_t *osize_p);
>>
>> This commit changes the way the indentation is handled to track the
>> visual size of the indentation rather than the characters in the
>> indentation. This has they benefit that any whitespace errors do not
>
> s/they/the/
Thanks, well spotted
>
>> interfer with the move detection (the whitespace errors will still be
>> highlighted according to --ws-error-highlight). During the discussion
>> of this feature there were concerns about the correct detection of
>> indentation for python. However those concerns apply whether or not
>> we're detecting moved lines so no attempt is made to determine if the
>> indentation is 'pythonic'.
>>
>> [1] Note that before the commit to fix the erroneous coloring of moved
>> lines each line was colored as a different block, since that commit
>> they are uncolored.
>>
>> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
>> ---
>>
>> Notes:
>> Changes since rfc:
>> - It now replaces the existing implementation rather than adding a new
>> mode.
>> - The indentation deltas are now calculated once for each line and
>> cached.
>> - Optimized the whitespace delta comparison to compare string lengths
>> before comparing the actual strings.
>> - Modified the calculation of tabs as suggested by Stefan.
>> - Split out the blank line handling into a separate commit as suggest
>> by Stefan.
>> - Fixed some comments pointed out by Stefan.
>>
>> diff.c | 130 +++++++++++++++++++++----------------
>> t/t4015-diff-whitespace.sh | 56 ++++++++++++++++
>> 2 files changed, 129 insertions(+), 57 deletions(-)
>>
>> diff --git a/diff.c b/diff.c
>> index c378ce3daf..89559293e7 100644
>> --- a/diff.c
>> +++ b/diff.c
>> @@ -750,6 +750,8 @@ struct emitted_diff_symbol {
>> const char *line;
>> int len;
>> int flags;
>> + int indent_off;
>> + int indent_width;
>
> So this is the trick how we compute the ws related
> data only once per line. :-)
>
> On the other hand, we do not save memory by disabling
> the ws detection, but I guess that is not a problem for now.
I did wonder about that, but decided the increase was small compared to
all the strings that are copied when creating the emitted_diff_symbols.
If we want to save memory then we should stop struct
emitted_diff_symbol() from carrying a copy of all the strings.
> Would it make sense to have the new variables be
> unsigned? (Also a comment on what they are, I
> needed to read the code to understand off to be
> offset into the line, where the content starts, and
> width to be the visual width, as I did not recall
> the RFC.)
Yes a comment would make sense. I don't think I have a strong preference
for signed/unsigned, I can change it if you want.
Thanks for looking at these so promptly
Best Wishes
Phillip
>> +static void fill_es_indent_data(struct emitted_diff_symbol *es)
>> [...]
>
>> + if (o->color_moved_ws_handling &
>> + COLOR_MOVED_WS_ALLOW_INDENTATION_CHANGE)
>> + fill_es_indent_data(&o->emitted_symbols->buf[n]);
>
> Nice.
>
> By reducing the information kept around to ints, we also do not need
> to alloc/free
> memory for each line.
>
>> +++ b/t/t4015-diff-whitespace.sh
>> @@ -1901,4 +1901,60 @@ test_expect_success 'compare whitespace delta incompatible with other space opti
>> test_i18ngrep allow-indentation-change err
>> '
>>
>> +test_expect_success 'compare mixed whitespace delta across moved blocks' '
>
> Looks good,
>
> Thanks!
> Stefan
>
next prev parent reply other threads:[~2018-11-17 14:59 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-24 10:06 [RFC PATCH 0/3] diff --color-moved-ws: allow mixed spaces and tabs in indentation change Phillip Wood
2018-09-24 10:06 ` [RFC PATCH 1/3] xdiff-interface: make xdl_blankline() available Phillip Wood
2018-09-24 23:19 ` Stefan Beller
2018-09-24 10:06 ` [RFC PATCH 2/3] diff.c: remove unused variables Phillip Wood
2018-09-24 10:06 ` [RFC PATCH 3/3] diff: add --color-moved-ws=allow-mixed-indentation-change Phillip Wood
2018-09-25 1:07 ` Stefan Beller
2018-10-09 9:50 ` Phillip Wood
2018-10-09 21:10 ` Stefan Beller
2018-10-10 15:26 ` Phillip Wood
2018-10-10 18:05 ` Stefan Beller
2018-09-24 11:03 ` [RFC PATCH 0/3] diff --color-moved-ws: allow mixed spaces and tabs in indentation change Phillip Wood
2018-11-16 11:03 ` [PATCH v1 0/9] diff --color-moved-ws fixes and enhancment Phillip Wood
2018-11-16 11:03 ` [PATCH v1 1/9] diff: document --no-color-moved Phillip Wood
2018-11-16 11:03 ` [PATCH v1 2/9] diff: use whitespace consistently Phillip Wood
2018-11-16 18:29 ` Stefan Beller
2018-11-16 11:03 ` [PATCH v1 3/9] diff: allow --no-color-moved-ws Phillip Wood
2018-11-16 11:03 ` [PATCH v1 4/9] diff --color-moved-ws: demonstrate false positives Phillip Wood
2018-11-16 11:03 ` [PATCH v1 5/9] diff --color-moved-ws: fix " Phillip Wood
2018-11-16 11:03 ` [PATCH v1 6/9] diff --color-moved=zebra: be stricter with color alternation Phillip Wood
2018-11-16 11:03 ` [PATCH v1 7/9] diff --color-moved-ws: optimize allow-indentation-change Phillip Wood
2018-11-16 20:40 ` Stefan Beller
2018-11-17 14:52 ` Phillip Wood
2018-11-16 11:03 ` [PATCH v1 8/9] diff --color-moved-ws: modify allow-indentation-change Phillip Wood
2018-11-16 21:47 ` Stefan Beller
2018-11-17 14:59 ` Phillip Wood [this message]
2018-11-16 11:03 ` [PATCH v1 9/9] diff --color-moved-ws: handle blank lines Phillip Wood
2018-11-20 18:05 ` Stefan Beller
2018-11-21 15:49 ` Phillip Wood
2018-11-23 11:16 ` [PATCH v2 0/9] diff --color-moved-ws fixes and enhancment Phillip Wood
2018-11-23 11:16 ` [PATCH v2 1/9] diff: document --no-color-moved Phillip Wood
2018-11-23 11:16 ` [PATCH v2 2/9] Use "whitespace" consistently Phillip Wood
2018-11-23 11:16 ` [PATCH v2 3/9] diff: allow --no-color-moved-ws Phillip Wood
2018-11-23 11:16 ` [PATCH v2 4/9] diff --color-moved-ws: demonstrate false positives Phillip Wood
2018-11-23 11:16 ` [PATCH v2 5/9] diff --color-moved-ws: fix " Phillip Wood
2018-11-23 11:16 ` [PATCH v2 6/9] diff --color-moved=zebra: be stricter with color alternation Phillip Wood
2018-11-23 11:16 ` [PATCH v2 7/9] diff --color-moved-ws: optimize allow-indentation-change Phillip Wood
2018-11-23 11:16 ` [PATCH v2 8/9] diff --color-moved-ws: modify allow-indentation-change Phillip Wood
2018-11-23 11:16 ` [PATCH v2 9/9] diff --color-moved-ws: handle blank lines Phillip Wood
2018-11-26 21:20 ` [PATCH v2 0/9] diff --color-moved-ws fixes and enhancment Stefan Beller
2018-11-27 20:52 ` Phillip Wood
2019-01-08 16:22 ` Phillip Wood
2019-01-08 18:31 ` Junio C Hamano
2019-01-10 0:37 ` Stefan Beller
2019-01-10 18:39 ` Junio C Hamano
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=42818e32-8774-722d-b46d-9a23f4097315@talktalk.net \
--to=phillip.wood@talktalk.net \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
--cc=sbeller@google.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.
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).