Wednesday, May 25, 2011

git avert disaster

Let me start by saying I hate hg. I should like it, since it is fundamentally the same as git. I want to like it, but it just is unlikeable.
  1. It is too complicated. In git there are commits (patches, content) and heads (names). Mercurial has versions, patches (in mq), branches, tags, bookmarks. Maybe more.
  2. It is disjointed. In git, everything is integrated. In hg, everything is an extension. The extensions work fine, one at a time. But bringing multiple extensions together doesn't always work well. Also, the tab completion only supports some things.
  3. It keeps messing up. This is the really scary part. I haven't lost anything, but twice now all my subrepos have gone into a "disconnected head" state (once after a crash, but once all by itself). I also sometimes get weird "unknown version" errors. It generally just requires "hg onsub 'hg up'", but sometimes greater voodoo is required.
That said, I encountered my first git problem recently.
  1. Install Cygwin git on Windows
  2. Intall Linux dual boot, boot in Linux, install git
  3. Mount the NTFS under Linux (hmm, maybe not a good idea here!)
  4. Use Linux git to manipulate the Cygwin repo (playing with fire!)
  5. Rebase the repo
  6. Boom
Yea, maybe I was asking for this one. The problem is that under Cygwin all the files have 644 permission, while Linux mounts NTFS with 755. Git stores the permissions flag under version control, so it is seeing every file change all the time. Rebasing causes massive conflicts all the time (since the history is all 644, but the mount point won't allow anything but 755).

So, here I am in some disconnected head state, with all my patches gone from the rebase. What to do?

I forgot what I did, but I got most of my patches applied. Except one fell on the floor, and didn't show up in the history anymore (well, the commit was there with the log message, but the patch was empty).

Fortunately, there is a file in .git called "ORIG_HEAD" or something similar. Cat it, and "git checkout". Cp the bad files off to a separate space and "git checkout" back. Diff and patch, commit. All fixed!

Yea git!

No comments: