Tuesday, 21 April 2009

Subversion, KDiff3, and Cygwin

Recently I've been doing work in a Windows environment, which is a bit of a culture shock for this Linux/Mac weenie.

As ever, I installed cygwin early on to make my life bearable. I'm not sure how I'd navigate without vim, grep and ctags. Are there actually any IDEs with genuinely useful code navigation?.

To make subversion usage the mirror of my Linux setup, I installed the excellent Windows port of kdiff3. My usual trick is to set a simple svn alias that involves kdiff3 when I need it. Something like:
alias sd="svn diff --diff-cmd kdiff3 -x ' -qall '"
(The nasty -x parameter is a workaround for some problematic kdiff3 invocations on Linux.)

However, the same trick did not always work under cygwin. From time to time, kdiff3 would complain that it could not find a file.

It turns out that this is a subtle problem where cygwin sometimes tries to convert filenames to DOS format before passing them to kdiff3.exe. When it does this, it fails and creates hybrid half-DOS/half-unix filenames. Handy.

The trick to make it work is to create a little kdiff3 wrapper script and use that, rather than kdiff3 directly. The magic rune you need to incant in the script is cygpath.


LEFT=`cygpath -d ${6}`
RIGHT=`cygpath -d ${7}`
/cygdrive/c/Program\ Files/KDiff3/kdiff3.exe $LEFT $RIGHT -L1 "$LEFT_NAME" -L2 "$RIGHT_NAME"


Unknown said...

I'm not sure how VS copes with C++, with C# and ReSharper, ctrl-click on an identifier goes to its declaration, right-click and you can show all usages and navigate to them, etc.

Actually a quick look on the Google suggests that navigation in C++ is a bit broken. Not too surprising for an unparsable language ;)

sinelaw said...
This comment has been removed by the author.
sinelaw said...

Good idea! I've expanded on it for cygwin git + kdiff3 and then to any windows program you may want to run from within cygwin with cygwin-style pathnames. See http://noamlewis.wordpress.com/2011/03/22/how-to-run-any-windows-program-from-cygwin-still-using-cygwin-style-path/

Anika said...

Thank you for the information you wrote. I read many posts in this website evert post is very nice.
Whatever accommodation you’re looking for