Re: [PATCH 0/4] refactor the --color-words to make it more hackable
- From
- Santi Béjar <santi@agolina.net>
- Date
- Jan 14, 2009, 13:00 UTC
- Message-ID
- <adf1fd3d0901140500j10556a1as6370d40d766f1899@mail.gmail.com>
- In-Reply-To
- <alpine.DEB.1.00.0901112057300.3586@pacific.mpi-cbg.de>
2009/1/11 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
>
[...]
Show 7 quoted lines
> The basic idea is to decouple the original text from the text that is > passed to libxdiff to find the word differences. > > To that end, the words of the pre and post texts are put into two lists that > are fed to libxdiff. While the words are extracted, an array is created which > contains pointers back to the word boundaries in the original text. >
Thanks. With this I will no longer need to add some spurious spaces in my latex files :-)
I've tested and it seems to work, but there are some corner cases that it does not handle well. If you have this two files:
---8<--- pre h(4)
a = b + c ---8<--- post h(4),hh[44]
a = b + c
aa = a
aeff = aeff * ( aaa ) ---8<---
The "git diff" is okay, but not the "git diff --color-words", the addition of "aeff = ..." is not shown.
Additionally with "git diff --no-index --color-words='^[A-Za-z0-9]*' the ']' character is not shown as an addition, and instead of the "aeff" line you get a ")" in green, as:
h(4),{GREEN}hh[44{ENDGREEN}]a = b + c
{GREEN}aa = a
){ENDGREEN}Also if the lost text is at the end the next "diff --git" line is printed in read:
--8<--- #!/bin/bash git init cat > file <<EOF a
aa EOF cat > gfile <<EOF a EOF git add . git commit -m "Initial import" git rm file cat > gfile <<EOF b EOF git add gfile git commit -m "changes" git show --color-words ---8<---
Thanks, Santi
P.D.: I've test the version that is in 'pu', it does not have the patch to fix the segfault but I've also tested with it.