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

Using --word-diff breaks --color-moved

From
JHjames harvey <jamespharvey20@gmail.com>
Date
Oct 31, 2018, 02:05 UTC
Message-ID
<CA+X5Wn76N34oBhRZvXKOwP0L_pF=LYbT6ugTgtPYSvnHg=MZVw@mail.gmail.com>

If you use both "--word-diff" and "--color-moved", regardless of the order of arguments, "--word-diff" takes precedence and "--color-moved" isn't allowed to do anything.

I think "--color-moved" should have precedence over "--word-diff". I cannot think of a scenario where a user would supply both options, and actually want "--word-diff" to take precedence. If I'm not thinking of a scenario where this wouldn't be desired, perhaps whichever is first as an argument could take precedence.

(The same behavior happens if 4+ lines are moved and "--color-moved{default=zebra}" is used, but below "--color-moved=plain" is used to be a smaller testcase.)

Given the following setup:
$ cat << EOF > file
> a
> b
> c
> EOF

$ git add file $ git commit -m "Added file." $ cat << EOF > file

> b
> c
> a
> EOF

You can have moved lines colorization: $ git diff --color-moved=plain ... [oldMovedColor]-a b c [newMovedColor]+a

You can diff based on words: $ git diff --word-diff ... [oldColor][-a-] b c [newColor][+a+}

But, you cannot diff based on words, and have moved lines colorization: $ git diff --color-moved=plain --word-diff $ git diff --word-diff ... [oldColor][-a-] b c [newColor][+a+}

Next: Junio C Hamano
Message 1 of 7 in “Using --word-diff breaks --color-moved”
  1. james harveyOct 31, 2018
  2. Junio C HamanoOct 31, 2018
  3. james harveyOct 31, 2018
  4. Stefan BellerOct 31, 2018
  5. Stefan BellerOct 31, 2018
  6. james harveyNov 2, 2018
  7. Stefan BellerNov 2, 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.