Edit: Code available for both Subversion and Git here: https://github.com/suomela/gitwdiff
For diffing, I have successfully used the following approach. This is not Latex-aware, but it seems to work very well with Latex documents (and Bibtex files, too). I have used it both on Linux and Mac OS X.
It is word-based and hence does not care about line breaks. For example, you can have each paragraph as a very long line in your source code; even then, the diff output will be easy to read and concise. It uses a colour-coded output:
- white on red background: deleted
- bold black on yellow background: added.
It is designed for black-on-white terminals; customise the colour codes if needed.
If you have made very extensive changes, occasionally it is better to use the usual diff. Try it out and see what happens.
Usage:
Simply write svnwdiff
instead of svn diff
.
If you need a pager, pipe your output to less -R
instead of less
.
Examples:
- You can simply write
svnwdiff
and you will see all your local changes.
- You can use
svnwdiff -c6445 foo.tex
just like you can use svn diff -c6445 foo.tex
.
- Write
svnwdiff -c6445 foo.tex | less -R
if you need a pager.
Put the following shell scripts in your $PATH
:
svnwdiff:
#!/bin/sh
exec svn diff --diff-cmd="mywdiff" "$@"
mywdiff:
#!/bin/sh
# Ignore all flags
while getopts uL: flag; do true; done
shift $(($OPTIND - 1))
esc=`printf '\033['`
wdiff -n -w "${esc}41;97m" -x "${esc}m" -y "${esc}1;103m" -z "${esc}m" "$@" | fgrep -C2 "$esc"
Finally, you will also need the wdiff tool. If you are using Ubuntu or Debian, just install the "wdiff" package. On Mac OS X, "port install wdiff" should do the trick.
If you are having problems getting all this working, try the following:
- First make sure that something like "wdiff foo bar" works.
- Then make sure that "mywdiff foo bar" works.
- Only after that try to get "svnwdiff foo" working, too.
For merging, I have found out that the best solution is to not need to merge. I tend to use email, skype, etc. to coordinate who has got the write token on which parts of the document. If all coordination efforts fail, I use the above diff tool to figure out who has done what, and integrate manually.
git
supports word diffs, that is, not the entire line gets highlighted, only the portion of the line that has been changed. It might be an option if Subversion isn't mandatory.