Saturday, September 5, 2009

Wasting Time with Git on Windows

It's quite easy actually: use Git to clone a certain repository to a Window$ machine and then attempt to build it.

I did just that with an autoconf based project. The machine at hand has Cygwin installed on it, so all I needed to do, in theory, was
git clone <git://address/of/repository.git>
cd <repository>
./configure
make
and have a binary to test.

I used PortableGit from msysgit, which seemed like a good idea at the time (instead of installing Cygwin-based Git).

Git clone worked like a charm. Luckily, that repository contained no symlinks and/or files whose names differ only in case (e.g. File.txt and file.txt).

But I couldn't run ./configure - I got a bunch of weird syntax error messages, which made no sense. The script looked fine (well, apart from being ridiculously long...).

It took an embarrassing half an hour before I figured it out, and even that was by chance. I opened the configure script for editing with emacs and noticed the text (DOS) at the status bar. Oh, so this is a Newline problem!

I tried
dos2unix configure
and I now got syntax errors in other files. Definitely a Newline problem.

I cloned the same project to my Debian box, and it looked OK - none of the scripts seemed to have CRLF newlines. So it had to be Git auto-convetring those text files between platforms.

A quick Net search later and I had a fix:
git config --global core.autocrlf false
I cloned the repository again, and this time everything worked nicely.

To be fair, I've been hit by Window$ specific problems with other SCMs, both free and commercial, with or without implied warranty, whenever I needed interoperability of some sort between Window$ and Linux.

If anything, I should've seen it coming.

No comments:

Post a Comment