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

Re: A case where diff.colorMoved=plain is more sensible than diff.colorMoved=zebra & others

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Dec 10, 2018, 14:43 UTC
Message-ID
<70f4fab1-9352-49ac-f911-da3e5a0ca172@talktalk.net>
In-Reply-To
<CAGZ79kZVfMNELXuir+t9U8bSg2PVF=oX8aya-OqmRaP0gHRgFw@mail.gmail.com>
On 06/12/2018 18:11, Stefan Beller wrote:
Show 34 quoted lines
> On Thu, Dec 6, 2018 at 6:58 AM Phillip Wood <phillip.wood@talktalk.net> wrote:
> 
>>> So is there some "must be at least two consecutive lines" condition for
>>> not-plain, or is something else going on here?
>>
>> To be considered a block has to have 20 alphanumeric characters - see
>> commit f0b8fb6e59 ("diff: define block by number of alphanumeric chars",
>> 2017-08-15). This stops things like random '}' lines being marked as
>> moved on their own.
> 
> This is spot on.
> 
> All but the "plain" mode use the concept of "blocks" of code
> (there is even one mode called "blocks", which adds to the confusion).
> 
>> It might be better to use some kind of frequency
>> information (a bit like python's difflib junk parameter) instead so that
>> (fairly) unique short lines also get marked properly.
> 
> Yes that is what I was initially thinking about. However to have good
> information, you'd need to index a whole lot (the whole repository,
> i.e. all text blobs in existence?) to get an accurate picture of frequency
> information, which I'd prefer to call entropy as I come from a background
> familiar with https://en.wikipedia.org/wiki/Information_theory, I am not
> sure where 'frequency information' comes from -- it sounds like the
> same concept.
> 
> Of course it is too expensive to run an operation O(repository size)
> just for this diff, so maybe we could get away with some smaller
> corpus to build up this information on what is sufficient for coloring.
> 
> When only looking at the given diff, I would imagine that each line
> would not carry a whole lot of information as its characters occur
> rather frequently compared to the rest of the diff.

I was thinking of using lines rather than characters as the unit of information (if that's the right phrase). I was hoping that seeing how often a given line occurs within the set of files being diffed would be good enough to tell is if it is an "interesting" move or not. In the mean time I wonder if decreasing the block limit to 10 alphanumeric characters would be enough to prevent too much noise in the output without suppressing matches that it would be useful to highlight.

Best Wishes
Phillip
> 
> Best,
> Stefan
> 
Previous: Stefan BellerNext: Stefan Beller
Message 4 of 5 in “A case where diff.colorMoved=plain is more sensible than diff.colorMoved=zebra & others”
  1. Ævar Arnfjörð BjarmasonDec 6, 2018
  2. Phillip WoodDec 6, 2018
  3. Stefan BellerDec 6, 2018
  4. Phillip WoodDec 10, 2018
  5. Stefan BellerDec 11, 2018

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.