@@ -152,20 +152,22 @@ - (id) initWithURL: (NSURL*) path
152
152
153
153
// The fileURL the document keeps is to the .git dir, but that’s pretty
154
154
// useless for display in the window title bar, so we show the directory above
155
- - (NSString *)displayName
156
- {
157
- NSString * dirName = self.fileURL .path .lastPathComponent ;
158
- if ([dirName isEqualToString: @" .git" ])
159
- dirName = [self .fileURL.path stringByDeletingLastPathComponent ].lastPathComponent ;
160
- NSString * displayName;
161
- if (![[PBGitRef refFromString: [[self headRef ] simpleRef ]] type ]) {
162
- displayName = [NSString stringWithFormat: @" %@ (detached HEAD)" , dirName];
163
- } else {
164
- displayName = [NSString stringWithFormat: @" %@ (branch: %@ )" , dirName,
165
- [[self headRef ] description ]];
166
- }
155
+ - (NSString *) displayName
156
+ {
157
+ if (![[PBGitRef refFromString: [[self headRef ] simpleRef ]] type ])
158
+ return [NSString stringWithFormat: @" %@ (detached HEAD)" , [self projectName ]];
159
+
160
+ return [NSString stringWithFormat: @" %@ (branch: %@ )" , [self projectName ], [[self headRef ] description ]];
161
+ }
162
+
163
+ - (NSString *) projectName
164
+ {
165
+ NSString *projectPath = [[self fileURL ] path ];
166
+
167
+ if ([[projectPath lastPathComponent ] isEqualToString: @" .git" ])
168
+ projectPath = [projectPath stringByDeletingLastPathComponent ];
167
169
168
- return displayName ;
170
+ return [projectPath lastPathComponent ] ;
169
171
}
170
172
171
173
// Get the .gitignore file at the root of the repository
0 commit comments