{ Hi! I'm Mike }
I'm a core developer with The Horde Project and a founding parter of Horde LLC - the company behind the world's most flexible groupware platform. This is my personal blog full of random thoughts about development and life in general.
August 14, 2011

git case sensitivity madness

I do most of my development work on my MacBook. The Mac, by default, uses a case preserving, but insensitive filesystem. This is, by far, by biggest gripe about the OS. Combine this with Git, this leads to a lot of havoc, since git is case sensitive. Since Horde uses Git, this can bite anyone who develops on a similar filesystem. It was a huge issue back when we were refactoring like mad for Horde 4 since there was a lot of file renaming going on.

Nowadays, I rarely run into this issue, but it does still creep up from time to time (like today!), usually during a merge. I used to jump through all kinds of hoops involving setting/unsetting the ignore-case switch in git's config (very bad idea). Now, I've found the following to be a much better way of dealing with it.

$ git pull --rebase

remote: Counting objects: 203, done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 143 (delta 81), reused 81 (delta 39)
Receiving objects: 100% (143/143), 49.49 KiB, done.
Resolving deltas: 100% (81/81), completed with 21 local objects.
First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
	passwd/lib/Driver/Adsi.php

Please move or remove them before you can switch branches.
Aborting

# As you can see, the file is present, but as the wrong case.
$ ls passwd/lib/Driver/
adsi.php

# To fix, we have to git mv the file to a different name,
# then git mv it back to the correct name
$ git mv adsi.php adsi.phpX
$ git mv adsi.phpX Adsi.php
$ git commit

# once all are taken care of, pull and rebase
# at this point there might be conflicts,
# but you can --ignore them during the rebase process.
$ git pull --rebase

CONFLICT (rename/delete): Rename passwd/lib/Driver/ldap.php->passwd/lib/Driver/Ldap.php in Fix case sensitivity issues on mac during merge and deleted in HEAD
CONFLICT (rename/delete): Rename whups/lib/Driver/sql.php->whups/lib/Driver/Sql.php in Fix case sensitivity issues on mac during merge and deleted in HEAD
Failed to merge in the changes.
Patch failed at 0001 Fix case sensitivity issues on mac during merge

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

$ git rebase --skip

Hope this helps!

November 25, 2008

The Cocoa Diaries Part I

I've been slowly plugging away at a new iPhoto export plugin for exporting photos to an Ansel server.  This was really my first Cocoa project and my first C related project in quite a number of years.

 I found picking up the basics of objective C  not that difficult, but I was stumped trying to do something that should have been fairly easy.  For this plugin, I am using the Cocoa XML-RPC Framework to manage (surprisingly enough) a xml-rpc connection to the Horde server.  During development, I just had it linked against the framework in my Library/Frameworks directory - which obviously won't work on someone else's machine.  So, time to move the framework into the bundle for the plugin.

I decided I wanted to include the source for the framework in the same project as the plugin. This makes debugging easier and also makes distributed development with other developers easier.  Sure, no problem,  just add the source, add a new framework target, copy files etc... but no dice.  For the life of me, I could not figure out why this would not work. Googled, hacked, googled some more.  Then it hits me - this is a plugin, not a standalone application.  When setting the Installation Path build property for the framework target in Xcode, I was using @application_path and not @loader_path. Duh. 

So, seeing how that particular problem cost me so much time, I thought I'd document this in the hopes it will help someone else avoid the same mistake. Here are the steps required to add the source code for a framework into an existing Xcode project for a plugin. (These are all basically the same steps as an adding it to an application, except for the setting of the Installaion Directory property).

  • Import the framework's source tree using the Import Existing Files command
  • Create a new target for the framework. Obviously, this should be a Cocoa Framework target.
  • Open the Build tab of the Inspector for the framework target, and set the Installation Directory property of the target to be: @loader_path/../Frameworks
  • Open the target for the plugin so you can see the build phases - drag your framework product (not the target) to the Link Binary with Libraries build phase.
  • Add a new Copy Files build phase and drag your framework product to the it. Open an inspector and set the Destination of the build phase to Frameworks.
  • Select the application target, open an inspector and add your framework as a dependency. This will assure that the framework is built before the plugin so that it's available to link against.  This allows you to keep the target of the Xcode project set to your plugin.

Yep, probably all simple stuff for an experienced x coder, and it actually is mostly pretty simple stuff...except for the fact that I forgot that I could not use @application_path as the Installation Directory.

September 11, 2008

iTunes, a network share, and Applescript

I've been slowly getting into Applescript lately since I've moved back to Mac for the majority of my work. I recently went through the process of moving the iTunes library file from my PC desktop to my Mac. After all, you can't have a Mac and use iTunes on your PC!

Anyway, I keep all the actual media files on a network share to ease with backup chores and to allow accessing the files with other players etc...  This hasn't posed any problems in the past, but now that I use a Macbook Pro to interact with iTunes, the network share is not always present.  I wrote a small Applescript to check for the existence of the share and then mount it if it's not there before opening iTunes. Since it seems that catching an error from a failed SMB mounting operation is difficult to do in Applescript, I attempt to grab the computer's IP address and only attempt the mount if it contains a value indicating I'm connected to my home network.

Yes, there is probably a better way to do this, and if anyone knows of one, feel free to drop me a line.

The code:

--Avoid undefined errors probably a better way set check_network to "" set check_wireless to "" try set check_network to do shell script ¬ "ipconfig getifaddr en0" on error set check_wireless to do shell script ¬ "ipconfig getifaddr en1" end try if check_network contains "192.168" or ¬ check_wireless contains "192.168" then tell application "Finder" if not (exists disk "music") then open location ¬ "smb://user:pass@server/music" end if repeat until (list disks) contains "music" end repeat launch application "iTunes" tell application "iTunes" activate end tell end tell end if

July 28, 2008

A Return to the Mac

I've always been a fan of Apple products. I love the design, the technology, the packaging. I was one of those "Mac guys", taking every opportunity to preach how Macs were better than PCs etc... However, once more and more of my paid consulting work was based on Microsoft technology, I had to stop replacing my aging machines with new Macs. The last new Mac I purchased was the blue and white "Yosemite" G3. Yea, a while ago.

These days, just about all my current development work is done in PHP. I also gave up on trying to maintain a desktop system in addition to my laptop, as it became a royal pain the ass to keep things synchronized between my machines. For at least the the last two years I've been using my XPS laptop as my primary, non-server, machine...and it's time for a new one. I've been obsessing over the MacBook Pro 17" for the last few months and now there is one in transit to my home as we speak. I've not used OS X to any extent (the G3 shipped with OS 9) so it will be an interesting journey getting used to the new os. I'm very familiar with *nix systems, so it shouldn't be too much of an issue.

My biggest concern, and to some extent, what I'm looking forward to the most, is finding that perfect mix of daily tools and utilities.  I plan on using VMWare Fusion to run the occasional Windows application, or for testing things in IE.  Although, I'll probably install Windows on a Boot Camp partition, just in case.

I'll continue to post my observations as I get more into the process...stay tuned!