Wednesday, April 16, 2008

Mac OS X quirks

Today, I roll into work around 10:30, free Starbucks Pike Place Blend in hand (yummy!), login to my workstation, and see the strangest thing. I do my customary git-status and see that I have made huge changes to one of our unit-tests, TestAccountant, last night. My checkout resides on my personal workstation, not a shared server, so how could one of my co-workers modified my local tree? I don't even have an ssh server enabled! The only logical conclusion is that I must have sleep-drove over, sleep-coded huge chunks of fairly logical looking tests, and sleep-drove back, all before I woke up this morning. And, I don't even feel tired!

Well, that probably didn't happen. So, what-the-dilly-yo?

Well, my first guess was that someone had accidentally cloned my repository and was now pushing their changes back to me.

Background: We use git, which is a distributed source control system like Bazaar or BitKeeper. This means that, if setup to do so, anybody can clone anybody else's repository, make changes and push those changes back-to 'origin'. This is very different from svn or cvs which are client-server based and require a single centralized master repository. Distributed source control is very powerful, but since I don't understand it all that well, I must admit, it makes me a little queasy to think of how many things could go wrong.

This theory, as it turned out, was wrong. What happened, you say? Case-insensitve filenames, that's what happened.

I've been using a Mac at work for the past couple of years now. I generally like it except that Macs tend to be so darn different:

/Users instead of /home
/Library instead of /usr/lib or /usr/local/lib.

And now, I've discovered, case-insensitive file names.

It turns out that we have two unit-tests, one named testAccountant and one named TestAccountant. You see where this is going. Only lower-case testAccountant is appearing in my local tree; my Mac has kindly decided to randomly pick which file I may work with :). However, this copy is being diffed against TestAccountant in my local repository. Two completely different files = massive differences.

Not a huge deal, but, let this be a reminder: Never rely on case alone to distinguish files. It ain't guaranteed to be respected across all systems and the bugs that do crop up can manifest themselves in some pretty strange ways.

Now, back to sleep-coding...

No comments: