Commit mode doesn't work when core.bare isn't set
Reported by Jeff Hamilton | May 14th, 2009 @ 09:09 AM
When syncing down and Android source tree using the repo tool you end up with roughly 125 different git repositories all managed by repo (see http://source.android.com/download/using-repo). Repo has its own copy of the .git directories for the various projects and symlinks the contents of the .git repositories scattered around the Android to its copies. For example, the code for the contacts application lives in its own git repository at:
but the contents of .git look like this:
-rw-r--r-- 1 jham eng 41 May 7 20:40 HEAD lrwxr-xr-x 1 jham eng 60 May 7 20:40 config -> ../../../../.repo/projects/packages/apps/Contacts.git/config
lrwxr-xr-x 1 jham eng 65 May 7 20:40 description -> ../../../../.repo/projects/packages/apps/Contacts.git/description
lrwxr-xr-x 1 jham eng 59 May 7 20:40 hooks -> ../../../../.repo/projects/packages/apps/Contacts.git/hooks
-rw-r--r-- 1 jham eng 21038 May 7 20:40 index lrwxr-xr-x 1 jham eng 58 May 7 20:40 info -> ../../../../.repo/projects/packages/apps/Contacts.git/info
lrwxr-xr-x 1 jham eng 58 May 7 20:40 logs -> ../../../../.repo/projects/packages/apps/Contacts.git/logs
lrwxr-xr-x 1 jham eng 61 May 7 20:40 objects -> ../../../../.repo/projects/packages/apps/Contacts.git/objects
lrwxr-xr-x 1 jham eng 65 May 7 20:40 packed-refs -> ../../../../.repo/projects/packages/apps/Contacts.git/packed-refs
lrwxr-xr-x 1 jham eng 58 May 7 20:40 refs -> ../../../../.repo/projects/packages/apps/Contacts.git/refs
lrwxr-xr-x 1 jham eng 62 May 7 20:40 rr-cache -> ../../../../.repo/projects/packages/apps/Contacts.git/rr-cache
lrwxr-xr-x 1 jham eng 57 May 7 20:40 svn -> ../../../../.repo/projects/packages/apps/Contacts.git/svn
This setup works fine with the command line git, but causes the GitX commit mode to fail. Note that history mode works fine.
I'm using GitX 0.6.2, git 220.127.116.11, OS X 10.5.6, and repo 18.104.22.168.
Comments and changes to this ticket
I don't know ObjC so haven't been able to track down the problem very well, but after some poking I discovered that forcing PBGitRepository isBareRepository to return NO gets commit mode to work on these symlinked repositories. Running "git rev-parse --is-bare-repository" from the command line does return false as would be expected.
- Title changed from Commit mode doesn't like symlinks in .git to Commit mode doesn't work when core.bare isn't set
I talked to Shawn Pearce about this a bit and he pointed out that when using repo to manage the git repositories .git/config ends up not having core.bare set, which he guessed could cause the problem. I verified that was the case by manually setting it in the config file, and things worked as expected. Repo does some interesting things and can't set the bare property for real since the copy that is symlinked to is an actual bare repository and commands get run in both places.
Ok, for displaying repos without the core.bare in their config I've written a patch. It's short, still took me some time to figure out the problem (which hopefully I clarified in the commit-message). The commit is in my bugfixes-branch: http://github.com/heipei/gitx/commits/bugfixes
Please comment if you've got a better idea to do this (right now we can handle the cases of bare repos, non-bare repos with/without core.bare, non-bare repos with core.bare = true. The only case that still breaks gitx (though this is pathological) is setting "core.bare = false" in a bare repo.