Thread (10 messages) 10 messages, 3 authors, 2016-06-15

Re: [PATCH 0/4] refactor the --color-words to make it more hackable

From: Santi Béjar <hidden>
Date: 2016-06-15 22:45:57

2009/1/11 Johannes Schindelin [off-list ref]:
[...]
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help