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]; }