diff --git a/PBGitRepository.h b/PBGitRepository.h index d3be759..6f109d2 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 72326ca..e59b129 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -161,6 +161,11 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; 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 4899ed0..c430ba6 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -41,6 +41,14 @@ [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 @@ } } [item bind:@"selectedIndex" toObject:self withKeyPath:@"selectedViewIndex" options:0]; + [item setEnabled: ![repository isBareRepository]]; [self.window setToolbar:toolbar]; }