From 82b6efc1d7c7b6c07857d2c727bfce286e9aa342 Mon Sep 17 00:00:00 2001 From: Owen Yamauchi Date: Fri, 30 Jan 2009 18:59:40 -0500 Subject: [PATCH] Fix ticket #84: disable commit view for bare repos --- PBGitRepository.h | 1 + PBGitRepository.m | 5 +++++ PBGitWindowController.m | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/PBGitRepository.h b/PBGitRepository.h index d3be75984..6f109d23e 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -38,6 +38,7 @@ extern NSString* PBGitRepositoryErrorDomain; - (NSString *)workingDirectory; - (NSString *)gitIgnoreFilename; +- (BOOL)isBareRepository; - (BOOL) reloadRefs; - (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params; diff --git a/PBGitRepository.m b/PBGitRepository.m index 72326ca38..e59b129aa 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -161,6 +161,11 @@ - (NSString*)gitIgnoreFilename return [[self workingDirectory] stringByAppendingPathComponent:@".gitignore"]; } +- (BOOL)isBareRepository +{ + return [PBGitRepository isBareRepository:[self fileURL].path]; +} + // Overridden to create our custom window controller - (void)makeWindowControllers { diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 4899ed074..c430ba6e8 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -41,6 +41,14 @@ - (void)windowWillClose:(NSNotification *)notification [commitViewController removeView]; } +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + if ([menuItem action] == @selector(showCommitView:) || [menuItem action] == @selector(showHistoryView:)) { + return ![repository isBareRepository]; + } + return YES; +} + - (void) setSelectedViewIndex: (int) i { selectedViewIndex = i; @@ -120,6 +128,7 @@ - (void) useToolbar:(NSToolbar *)toolbar } } [item bind:@"selectedIndex" toObject:self withKeyPath:@"selectedViewIndex" options:0]; + [item setEnabled: ![repository isBareRepository]]; [self.window setToolbar:toolbar]; }