14

Is it possible to do a case insensitive git diff while also doing git diff --color-words? Or do I need to use an external diff program while doing git diff --color-words?

( note: if all you want is git diff case insensitive please go to this question How to perform case insensitive diff in Git )

Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
  • 5
    The fact that the word "case" does not appear in the manpage in that context doesn't bode well for you... – Cascabel Feb 14 '11 at 23:20
  • 1
    possible duplicate of [How to perform case insensitive diff in Git](http://stackoverflow.com/questions/17380029/how-to-perform-case-insensitive-diff-in-git) – Anto Aug 28 '14 at 13:43
  • 1
    @Anto: possible but this question is 2 years older... – MensSana May 31 '16 at 18:16

2 Answers2

11
GIT_EXTERNAL_DIFF='diff -ipu "$2" "$5" #' git diff --ext-diff

Or, in a nicer fashion without the # hack I used there:

echo 'diff -ipu "$2" "$5"' >myscript; chmod a+x myscript;
GIT_EXTERNAL_DIFF='./myscript' git diff --ext-diff

I agree it would be nicest if git-diff would just have an -i option...

user611775
  • 1,323
  • 7
  • 11
  • This doesn't get you color, or a word-diff... wdiff would get you the later, but not in the colored form. – Cascabel Feb 15 '11 at 02:29
  • 1
    Hook it up with a script that calls wdiff, and applies color, such as [cwdiff](http://www.google.de/search?q="cwdiff"+"hxtools") – user611775 Feb 15 '11 at 15:12
  • This looks promising, but if there is a binary file in the repositiory, it fails with `fatal: the external diff application disapeared` and does not display any output. – Lorenz Meyer Mar 01 '16 at 13:51
  • 4
    In msysgit I'm getting `fatal: external diff died, stopping at path/to/file.txt` after first file. – Jonas Byström Mar 15 '16 at 14:56
  • You can add a trailing `| cat` at the end of the script to avoid the failure message, as explained in [http://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-a-visual-diff-program] – Cyrille May 09 '17 at 09:39
  • 1
    you can add the argument `--color=always` to the diff command to force colors, e.g. `echo 'diff --color=always -ipu "$2" "$5"' >myscript` – morloch Sep 05 '18 at 01:31
0

I figured out a way to perform case-insensitive diff, although not with the --color-word option as the OP asked for. See my answer to my own question.

Community
  • 1
  • 1
Gurjeet Singh
  • 2,635
  • 2
  • 27
  • 22