Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ - (id) initWithURL: (NSURL*) path
// We don't want the window controller to display anything yet..
// We'll leave that to the caller of this method.
#ifndef CLI
if (![self workingDirectory]) { // If we couldn't find the working directory, assume it's the place we were opened from.
workingDirectory = [[path absoluteURL] path];
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just copypasted this from line 169 -readFromURL:ofType:error:

[self addWindowController:[[PBGitWindowController alloc] initWithRepository:self displayDefault:NO]];
#endif

Expand Down Expand Up @@ -926,8 +929,19 @@ - (NSString *) workingDirectory
if(!workingDirectory) {
if ([self.fileURL.path hasSuffix:@"/.git"])
workingDirectory = [self.fileURL.path substringToIndex:[self.fileURL.path length] - 5];
else if ([[self outputForCommand:@"rev-parse --is-inside-work-tree"] isEqualToString:@"true"])
workingDirectory = [PBGitBinary path];
else {
NSRange range = [self.fileURL.path rangeOfString: @"/.git/modules/"];
if (range.location != NSNotFound) {
NSString *relativeModulePath = [self.fileURL.path substringFromIndex: range.location + range.length ];
NSString *supermodulePath = [self.fileURL.path substringToIndex: range.location];
workingDirectory = [supermodulePath stringByAppendingPathComponent: relativeModulePath];
}
else if ([[self outputForCommand:@"rev-parse --is-inside-work-tree"] isEqualToString:@"true"])
workingDirectory = [PBGitBinary path];
else
workingDirectory = self.fileURL.path;
}

}

return workingDirectory;
Expand Down