Avoid showing .git dirs in the recent documents menu.

Instead (for non-bare repos) add the directory above the .git dir.
This commit is contained in:
Ciarán Walsh
2008-08-18 22:13:51 +01:00
committed by Pieter de Bie
parent d320a4bc43
commit 12faa4a8f0
3 changed files with 21 additions and 0 deletions
+2
View File
@@ -29,6 +29,8 @@ extern NSString* PBGitRepositoryErrorDomain;
- (NSString*) parseReference:(NSString*) ref;
+ (NSURL*)gitDirForURL:(NSURL*)repositoryURL;
+ (NSURL*)baseDirForURL:(NSURL*)repositoryURL;
@property (readonly) PBGitRevList* revisionList;
@property (assign) NSArray* branches;
@property (assign) NSString* currentBranch;
+14
View File
@@ -76,6 +76,20 @@ static NSString* gitPath;
return gitDirURL;
}
// For a given path inside a repository, return either the .git dir
// (for a bare repo) or the directory above the .git dir otherwise
+ (NSURL*)baseDirForURL:(NSURL*)repositoryURL;
{
NSURL* gitDirURL = [self gitDirForURL:repositoryURL];
NSString* repositoryPath = [gitDirURL path];
if (![[PBEasyPipe outputForCommand:gitPath withArgs:[NSArray arrayWithObjects:@"rev-parse", @"--is-bare-repository", nil] inDir:repositoryPath] isEqualToString:@"true"]) {
repositoryURL = [NSURL fileURLWithPath:[[repositoryURL path] stringByDeletingLastPathComponent]];
}
return repositoryURL;
}
- (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError
{
BOOL success = NO;
+5
View File
@@ -24,4 +24,9 @@
{
return [super documentForURL:[PBGitRepository gitDirForURL:URL]];
}
- (void)noteNewRecentDocumentURL:(NSURL*)url
{
[super noteNewRecentDocumentURL:[PBGitRepository baseDirForURL:url]];
}
@end