Disable commit view for bare repos
Reported by Owen Yamauchi | January 30th, 2009 @ 05:10 AM
Commit view doesn't apply when viewing bare repositories, so it's probably best to hide it from users.
I've written a fix; I can attach a patch or push my branch, whichever you prefer.
Comments and changes to this ticket
Thanks for pointing this one out. Patches are best sent via email, though you can attach them here as well.
The other problem we're facing with a bare repository is that the index shows all files as deleted (because thats what git diff-index --cached says), which of course is not the case. gitk had the same problem and solved it by checking for a bare repo before doing anything on the display of staged/unstaged changes.
I'm still in the process of finding my way through the many similarly named Objective-C files, or I would have fixed it myself already.
I think the real problem is that GitX currently isn't really aware of any worktree / git tree. What I'd like to see is a change to PBGitRepository, where on load it tests if it's bare. Then there should be the possibility to ask for the git dir (which should be there in any case), the worktree (which might be NULL in case of a bare repository), the directory gitx cli was started in (so you can do 'gitx .' in a subdir) or the best possible match (subdir > worktree > git dir).
Now it just does some ugly stuff with repository.fileURL.path, which I don't like at all :)
@Johannes: The layout is actually pretty simple. There's a 'controller' map in XCode where all the controllers are in. General controllers are in the root, and controllers for specific views are in the submaps. There's a map for each view (history, commit and diff, which does the 'git diff | gitx' handling).
There's a 'master' controller for each view, usually called 'PBGit_View_Controller', e.g. PBGitHistoryController. Then, if there's a web controller, that one has the same name but with "Web" in it, eg PBWebHistoryController, though the naming might differ a bit. There might also be subcontrollers if there's a lot of code. For example, in the commit view, there is an IndexController to keep track of everything index-related.
The same structure is what you also see in the 'html' subdirectory .. the 'history' part is in 'html/views/history', etc. The PBWebHistoryController will automagically load in 'html/views/history/history.html', so by comparing names you can know what matches each other. This is also why the naming is similar sometimes.
I just got around the problem where all files show up as deleted by disabling the mode selector in the toolbar and the mode selection menu items when you're viewing a bare repo.
All I did to PBGitRepository was give it an instance method -isBareRepository, which just calls the class method. Is that OK?
P.S., who should I email the patch to?
Ok, I looked at your patches and they work fine. There is one problem though: When I open GitX in commit-view in a non-bare repo, close GitX with commit-view active and then start it on the bare repo it will start in commit-view and you're not able to switch back.
What do you mean? You merged all the relevant commits a while back:
- 2009-01-31 10:29:08 +0100 06f675b Johannes Gilger PBGitWindowController: Default to historyViewController for bare repo
- 2009-01-30 18:59:40 -0500 82b6efc Owen Yamauchi Fix ticket #84: disable commit view for bare repos
- 2009-01-29 23:19:00 -0500 64dfd99 Owen Yamauchi Make finding the history/commit selector more robust.
So, I think the ticket can be closed