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

Re: Understanding and improving --word-diff

From
Wincent Colaiuta <win@wincent.com>
Date
Nov 8, 2010, 17:35 UTC
Message-ID
<857393A7-596D-4848-A002-6AC06FF6B2EA@wincent.com>
In-Reply-To
<20101108151601.GF22067@login.drsnuggles.stderr.nl>
On 08/11/2010, at 16:16, Matthijs Kooijman wrote:
Show 6 quoted lines
> Hi folks,
> 
> I recently discovered --word-diff (or rather, --color-words and found
> --word-diff when I started to hack on the git master version) and I had
> hoped it would make the unified diffs generated by git-diff more
> readable.
[snip]
Show 12 quoted lines
> Inexact output
> --------------
> Secondly, the --word-diff output currently never displays any changes to
> the non-word (whitespace) parts of a file. This makes sense for the
> LaTeX case, but sometimes you might want to get exact diff output
> instead. At first glance this seems possible by specifiying a word-regex
> of "." or something similar (i.e., make sure that the word regex matches
> everything). But this is problematic for newlines. The documentation
> states that stuff gets silently ignored if a newline ends up inside a
> word. For the --word-diff=color format, this is probably a fixed
> limitation of the otput format: you can't give a color to a newline (or
> a space, for that matter).
[snip]
Show 10 quoted lines
> Porcelain format
> ----------------
> Lastly, the "porcelain" word-diff format seems a bit weird to me. Is
> the format specified somewhere, or are there any programs that use it
> currently? I couldn't find any users inside the git.git tree itself?
> 
> Looking at the format itself, it's a bit unclear to me what the ~ lines
> mean exactly. Commit 882749, which introduced the format says the mean
> "newlines in the input", but I'm not sure if this means the old file,
> new file or both.
I posted along similar lines back in September:
  http://article.gmane.org/gmane.comp.version-control.git/156375
I found I couldn't really use the porcelain format due to information loss and ended up having to roll my own, parse the normal diff output and using that.

Cheers, Wincent

Previous: Thomas RastNext: Thomas Rast
Message 5 of 10 in “Understanding and improving --word-diff”
  1. Matthijs KooijmanNov 8, 2010
  2. Matthieu MoyNov 8, 2010
  3. Matthijs KooijmanNov 8, 2010
  4. Thomas RastNov 8, 2010
  5. Wincent ColaiutaNov 8, 2010
  6. Thomas RastNov 8, 2010
  7. Jeff KingNov 9, 2010
  8. Johannes SchindelinNov 10, 2010
  9. Jeff KingNov 10, 2010
  10. Jeff KingNov 18, 2010

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.