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

Re: A better git diff --word-diff (--word-diff-regex) ?

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Mar 19, 2012, 16:54 UTC
Message-ID
<CAA01CsqcDsK2-n6npQiiO2=ux0JdUU-Sq6ceHrc0A9q2hjQC3w@mail.gmail.com>
In-Reply-To
<vpqvcm0exc4.fsf@bauges.imag.fr>

On Mon, Mar 19, 2012 at 10:47 AM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

Show 13 quoted lines
> Piotr Krukowiecki <piotr.krukowiecki@gmail.com> writes:
>
>> Hi,
>>
>> is there a way to configure --word-diff to be a more programming
>> language friendly?
>
> I often use this:
>
>  git diff --color-words=.
>
> It's rather bad on plain text, since it will try to diff within words,
> but works well on source code.
Hi,

thanks for the idea, it's surely useful in many cases, but it can look confusing on source code too. For example on git b3256eb8b in path.c one part of the diff is

-                       if (!access(used_path, F_OK)) {
+                       if (!stat(used_path, &st) &&
+                           (S_ISREG(st.st_mode) ||
+                           (S_ISDIR(st.st_mode) &&
is_git_directory(used_path)))) {
and "git diff --word-diff-regex=." shows
                        if (![-acces-]s{+tat+}(used_path, [-F-]{+&st) &&+}
{+                          (S+}_[-OK-]{+ISREG(st.st_mode) ||+}
{+                          (S_ISDIR(st.st_mode) &&
is_git_directory(used_path))+})) {
-- 
Piotr Krukowiecki
Previous: Matthieu MoyNext: Thomas Rast
Message 3 of 7 in “A better git diff --word-diff (--word-diff-regex) ?”
  1. Piotr KrukowieckiMar 19, 2012
  2. Matthieu MoyMar 19, 2012
  3. Piotr KrukowieckiMar 19, 2012
  4. Thomas RastMar 19, 2012
  5. Piotr KrukowieckiMar 19, 2012
  6. Johannes SixtMar 19, 2012
  7. Jeff KingMar 19, 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.