Skip to content

Commit

Permalink
Fix ticket #84: disable commit view for bare repos
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamauchi authored and heipei committed Feb 6, 2009
1 parent 64dfd99 commit 82b6efc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions PBGitRepository.h
Expand Up @@ -38,6 +38,7 @@ extern NSString* PBGitRepositoryErrorDomain;

- (NSString *)workingDirectory;
- (NSString *)gitIgnoreFilename;
- (BOOL)isBareRepository;

- (BOOL) reloadRefs;
- (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params;
Expand Down
5 changes: 5 additions & 0 deletions PBGitRepository.m
Expand Up @@ -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
{
Expand Down
9 changes: 9 additions & 0 deletions PBGitWindowController.m
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}
Expand Down

0 comments on commit 82b6efc

Please sign in to comment.