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

Re: [PATCH 2/2] diff --word-diff: use non-whitespace regex by default

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Jan 12, 2012, 00:52 UTC
Message-ID
<CALUzUxo3DcKqC6sQFQ1Oi0vgASFSHCcmOgHAj2_4c3vEjy663w@mail.gmail.com>
In-Reply-To
<87lipexawp.fsf@thomas.inf.ethz.ch>
Hi,
Thomas, first off, thanks for looking through this.
On Thu, Jan 12, 2012 at 4:05 AM, Thomas Rast <trast@student.ethz.ch> wrote:
Show 13 quoted lines
> Tay Ray Chuan <rctay89@gmail.com> writes:
>
>> Factor out the comprehensive non-whitespace regex in use by PATTERNS and
>> IPATTERN and use it as the word-diff regex for the default diff driver.
>
> Why?
>
> I seem to recall that the motivation for keeping the original code as-is
> instead of just emulating its behavior with a default regex was that it
> is faster.  So disabling the default mode should at least have an
> advantage?
>
> </devils-advocate>
If you're talking about speed, yeah, that's probably true.

But I think it's worthwhile to trade-off performance for a sensible default. Something like

  matrix[a,b,c]
  matrix[d,b,c]
gives
  matrix[[-a-]{+d+},b,c]
and when we have
  ImagineALanguageLikeFoo
  ImagineALanguageLikeBar
we get
  ImagineALanguageLike[-Foo-]{+Bar+}

(But I cheated. Foo and Bar have no common characters in common; if they did, the word diff would be messy.)

Both of which seem sensible. From a usability/effectiveness standpoint, I think it's more useful than what the current word-diff defaults to - the whole line is taken as a "word", with the pre-image shown as deleted and the post-image as added; we don't even try to run LCS on it.

Examples are lifted from: [1] http://article.gmane.org/gmane.comp.version-control.git/105896 [2] http://article.gmane.org/gmane.comp.version-control.git/105237

-- 
Cheers,
Ray Chuan
Previous: Thomas RastNext: Thomas Rast
Message 4 of 8 in “t4034-diff-words: replace regex for diff driver”
  1. 1/2 t4034-diff-words: replace regex for diff driverTay Ray Chuan, Jan 11, 2012
  2. 2/2 diff --word-diff: use non-whitespace regex by defaultTay Ray Chuan, Jan 11, 2012
  3. Thomas RastJan 11, 2012
  4. Tay Ray ChuanJan 12, 2012
  5. Thomas RastJan 12, 2012
  6. Tay Ray ChuanJan 18, 2012
  7. Thomas RastJan 19, 2012
  8. Tay Ray ChuanJan 20, 2012

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.