threads / discuss / 28165

git diff --word-diff=plain

Subject: git diff --word-diff=plain

## tl;dr

One message between Aug 19, 2011 and Aug 19, 2011.

replies: 0people: 1as markdown or json

Elias Pipping· Aug 19, 2011, 19:16 UTC · lore
Hello,

I mean to use `git --no-pager diff --word-diff=plain --no-index` as a `wdiff`-replacement. I'm not sure if I should call it a bug but I've come across a situation in which the output of GNU wdiff is by far more helpful than that of the aforementioned git command.

I've attached the two files less and BSD-2. Here are the differences that wdiff reveals:

% wdiff less BSD-2
                          [-Less License-]
[-                          -------------]
[--]
[-Less-]Copyright [-(C) 1984-2005  Mark Nudelman-] {+(c) <YEAR>, <OWNER>+}
{+All rights reserved.+}

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   [-notice-]
   {+notice, this list of conditions and the following disclaimer+} in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE [-AUTHOR ``AS IS''-] {+COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+} AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE [-AUTHOR-] {+COPYRIGHT OWNER OR CONTRIBUTORS+} BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %

That's hardly any difference. Note that the file BSD-2 has an empty line just before the first bullet point. This will cause git to treat anything after that line as different for some reason. The resulting diff is thus hardly useful:

% git --no-pager diff --word-diff=plain --no-index less BSD-2
diff --git a/licences/less b/licences/BSD-2
index 7e4887b..a995d54 100644
--- a/licences/less
+++ b/licences/BSD-2
@@ -1,27 +1,23 @@
[-Less License-]
[-                          -------------]

[-Less-]Copyright [-(C) 1984-2005  Mark Nudelman-]{+(c) <YEAR>, <OWNER>+}
{+All rights reserved.+}

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:[-1. Redistributions of source code must retain the above copyright-]
[-   notice, this list of conditions and the following disclaimer.-]
[-2. Redistributions in binary form must reproduce the above copyright-]
[-   notice in the documentation and/or other materials provided with -]
[-   the distribution.-]

[-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY-]
[-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-]
[-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -]
[-PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE-]
[-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -]
[-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -]
[-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -]
[-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -]
[-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -]
[-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -]
[-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.-]{+1. Redistributions of source code must retain the above copyright notice,+}
{+   this list of conditions and the following disclaimer.+}
{+2. Redistributions in binary form must reproduce the above copyright+}
{+   notice, this list of conditions and the following disclaimer in the+}
{+   documentation and/or other materials provided with the distribution.+}

{+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+}
{+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+}
{+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+}
{+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE+}
{+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR+}
{+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF+}
{+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS+}
{+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN+}
{+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)+}
{+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE+}
{+POSSIBILITY OF SUCH DAMAGE.+}
%


Best regards,

Elias Pipping


Copyright (c) <YEAR>, <OWNER>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.


                          Less License
                          ------------

Less
Copyright (C) 1984-2005  Mark Nudelman

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice in the documentation and/or other materials provided with 
   the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

← back to recent threads