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
Stefan Beller <sbeller@google.com>
Date
Jun 28, 2017, 20:36 UTC
Message-ID
<CAGZ79kbsAi95+ZgjMem+MViKiXby7gZnGyg4Hbua5xw6TaPz_w@mail.gmail.com>
In-Reply-To
<xmqq37akya3j.fsf@gitster.mtv.corp.google.com>
On Tue, Jun 27, 2017 at 10:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> 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.
>
> This probably deserves a bit more illustration of how I envision the
> code should evolve.
>
> In the longer term, I would prefer to see emitted_symbol_cmp_no_ws()
> to go and instead emitted_symbol_cmp() to take the diff options
> so
> that it can change the behaviour of the comparison function based on
> the -w/-b/--ignore-space-at-eol/etc. settings.  And compare two strings
> in place.

ok, in-place is no problem. But passing down the diff options into the compare function is a bit hard.

Originally I wanted to do that, see prep work in [1], but Jeff explained that the additional pointer in the compare function is **not** supposed to be a additional payload (such as the diff options specifying the white space options.)

[1] https://public-inbox.org/git/20170512200244.25245-1-sbeller@google.com/

However as we no settled on the struct emitted_diff_symbol, that has a 'flags' field in there, which ought to contain everything we know about whitespace settings, we should be able to do that from there.

>         emitted_symbol_eqv(struct emitted_diff_symbol *a,
>                            struct emitted_diff_symbol *b,
>                            const void *keydata) {
>                 struct diff_options *diffopt = keydata;

The prep work mentioned, would allow for this, as keydata would be passed through as-is in all calls of the hashmap API, such that the user can decide if they use it as the actual 'keydata' or rather as an additional payload.

Thanks for outlining the idea in code, but maybe we need to reconsider the hashmap API before that.

By not considering the change in the hashmap API, the current implementation tried to get away by having different compare functions.

Thanks, Stefan

Previous: Junio C HamanoNext: Junio C Hamano
Message 15 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.