diff --git a/PBGitCommitController.m b/PBGitCommitController.m index e11c24d..11ee9f2 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -108,7 +108,7 @@ - (IBAction) commit:(id) sender { - if ([[NSFileManager defaultManager] fileExistsAtPath:[repository.fileURL.path stringByAppendingPathComponent:@"MERGE_HEAD"]]) { + if ([[NSFileManager defaultManager] fileExistsAtPath:[[[repository fileURL] path] stringByAppendingPathComponent:@"MERGE_HEAD"]]) { [[repository windowController] showMessageSheet:@"Cannot commit merges" infoText:@"GitX cannot commit merges yet. Please commit your changes from the command line."]; return; } diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index ad106e2..7e93924 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -26,6 +26,7 @@ + YES @@ -170,7 +171,7 @@ 256 - {852, 228} + {852, 308} YES @@ -354,7 +355,7 @@ 0 - {{0, 17}, {852, 228}} + {{0, 17}, {852, 308}} @@ -368,18 +369,18 @@ _doScroller: - 37 - 0.19473679999999999 + 0.95129870129870131 -2147483392 - {{0, 196}, {837, 15}} + {{0, 310}, {852, 15}} + YES 1 _doScroller: - 0.21932109999999999 + 0.9988276670574443 @@ -397,10 +398,10 @@ - {852, 245} + {852, 325} - 560 + 688 @@ -411,7 +412,7 @@ 274 - {{0, 246}, {852, 152}} + {{0, 326}, {852, 72}} YES @@ -509,7 +510,7 @@ 256 - {124, 152} + {124, 72} YES @@ -563,7 +564,7 @@ 0 - {{1, 1}, {124, 152}} + {{1, 1}, {124, 72}} @@ -573,11 +574,11 @@ 256 - {{125, 1}, {15, 152}} + {{125, 1}, {15, 72}} _doScroller: - 0.94736842105263153 + 0.73684210526315785 @@ -591,7 +592,7 @@ 0.99801189999999995 - {141, 154} + {141, 74} 18 @@ -805,7 +806,7 @@ - {{1, 1}, {693, 152}} + {{1, 1}, {693, 72}} @@ -819,11 +820,12 @@ 256 - {{694, 1}, {15, 152}} + {{694, 1}, {15, 72}} + YES _doScroller: - 0.96938775510204078 + 0.73469387755102045 @@ -837,22 +839,22 @@ 0.94565220000000005 - {{142, 0}, {710, 154}} + {{142, 0}, {710, 74}} - 18 + 82 - {852, 154} + {852, 74} YES 2 - {852, 152} + {852, 72} Tree diff --git a/PBGitIndex.m b/PBGitIndex.m index bd9bd56..5f2cdf2 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -155,7 +155,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; [commitSubject appendString:[commitMessage substringToIndex:newLine.location]]; NSString *commitMessageFile; - commitMessageFile = [repository.fileURL.path stringByAppendingPathComponent:@"COMMIT_EDITMSG"]; + commitMessageFile = [[[repository fileURL] path] stringByAppendingPathComponent:@"COMMIT_EDITMSG"]; [commitMessage writeToFile:commitMessageFile atomically:YES encoding:NSUTF8StringEncoding error:nil]; diff --git a/PBGitRevList.mm b/PBGitRevList.mm index a849de6..dc08df6 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -87,10 +87,10 @@ using namespace std; else [arguments addObjectsFromArray:[rev parameters]]; - NSString *directory = rev.workingDirectory ? rev.workingDirectory.path : repository.fileURL.path; + NSString *directory = rev.workingDirectory ? [rev.workingDirectory path] : [[repository fileURL] path]; NSTask *task = [PBEasyPipe taskForCommand:[PBGitBinary path] withArgs:arguments inDir:directory]; [task launch]; - NSFileHandle* handle = [task.standardOutput fileHandleForReading]; + NSFileHandle* handle = [[task standardOutput] fileHandleForReading]; int fd = [handle fileDescriptor]; __gnu_cxx::stdio_filebuf buf(fd, std::ios::in); diff --git a/PBPrefsWindowController.m b/PBPrefsWindowController.m index 254adc4..7e9ee1a 100644 --- a/PBPrefsWindowController.m +++ b/PBPrefsWindowController.m @@ -44,7 +44,7 @@ [openPanel setAllowsMultipleSelection:NO]; [openPanel setTreatsFilePackagesAsDirectories:YES]; [openPanel setAccessoryView:gitPathOpenAccessory]; - //[[openPanel _navView] setShowsHiddenFiles:YES]; + //[openPanel setShowsHiddenFiles:YES]; gitPathOpenPanel = openPanel; } @@ -54,9 +54,10 @@ - (IBAction) showHideAllFiles: sender { - /* FIXME: This uses undocumented OpenPanel features to show hidden files! */ - NSNumber *showHidden = [NSNumber numberWithBool:[sender state] == NSOnState]; - [[gitPathOpenPanel valueForKey:@"_navView"] setValue:showHidden forKey:@"showsHiddenFiles"]; + //NSNumber *showHidden = [NSNumber numberWithBool:[sender state] == NSOnState]; + //[[gitPathOpenPanel valueForKey:@"_navView"] setValue:showHidden forKey:@"showsHiddenFiles"]; + BOOL showHidden = ([sender state] == NSOnState); + [gitPathOpenPanel setShowsHiddenFiles:showHidden]; } @end diff --git a/PBRefController.h b/PBRefController.h index 1031807..1d7aefe 100644 --- a/PBRefController.h +++ b/PBRefController.h @@ -68,6 +68,7 @@ - (BOOL) addRemoteImplWithName:(NSString *)remoteName forURL:(NSString *)remoteURL; - (void) showMessageSheet:(NSString *)title message:(NSString *)msg; +- (void) toggleToolbarItems:(NSToolbar *)tb matchingLabels:(NSArray *)labels enabledState:(BOOL)state; @end diff --git a/PBRefController.m b/PBRefController.m index 45cbdbe..b690005 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -47,6 +47,7 @@ [historyController.repository removeBranch:[[PBGitRevSpecifier alloc] initWithRef:[refMenuItem ref]]]; [[refMenuItem commit] removeRef:[refMenuItem ref]]; [commitController rearrangeObjects]; + [self updateBranchMenu]; } } @@ -134,7 +135,8 @@ [self showMessageSheet:@"Pull from Remote" message:PBMissingRemoteErrorMessage]; return success; } - NSString *rval = [historyController.repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"pull", remote, refName, nil] retValue: &ret]; + NSArray * args = [NSArray arrayWithObjects:@"pull", remote, refName, nil]; + NSString *rval = [historyController.repository outputInWorkdirForArguments:args retValue: &ret]; if (ret) { NSString *info = [NSString stringWithFormat:@"There was an error pulling from the remote repository.\n\n%d\n%@", ret, rval]; [[historyController.repository windowController] showMessageSheet:@"Pulling from remote failed" infoText:info]; @@ -152,7 +154,7 @@ BOOL success = NO; NSString *remote = [[[historyController repository] config] valueForKeyPath:[NSString stringWithFormat:@"branch.%@.remote", refName]]; if (!remote) { - [self showMessageSheet:@"Pull Rebase from Remote" message:PBMissingRemoteErrorMessage]; + [self showMessageSheet:@"Pull from Remote and Rebase" message:PBMissingRemoteErrorMessage]; return success; } NSString *rval = [[historyController repository] outputInWorkdirForArguments:[NSArray arrayWithObjects:@"pull", @"--rebase", remote, refName, nil] retValue: &ret]; @@ -204,6 +206,25 @@ return success; } +- (void) toggleToolbarItems:(NSToolbar *)tb matchingLabels:(NSArray *)labels enabledState:(BOOL)state { + NSArray * tbItems = [tb items]; + + /* if labels is nil, assume all toolbar items */ + if (!labels) { + for (NSToolbarItem * curItem in tbItems) { + [curItem setEnabled:state]; + } + } else { + for (NSToolbarItem * curItem in tbItems) { + for (NSString * curLabel in labels) { + if ([[curItem label] isEqualToString:curLabel]) { + [curItem setEnabled:state]; + } + } + } + } +} + # pragma mark Tableview delegate methods - (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard @@ -286,6 +307,8 @@ } # pragma mark Add ref methods + + -(void)addRef:(id)sender { [errorMessage setStringValue:@""]; @@ -296,21 +319,7 @@ contextInfo:NULL]; } -- (void) showMessageSheet:(NSString *)title message:(NSString *)msg { - - [[NSAlert alertWithMessageText:title - defaultButton:@"OK" - alternateButton:nil - otherButton:nil - informativeTextWithFormat:msg] - beginSheetModalForWindow:[[historyController view] window] - modalDelegate:self - didEndSelector:nil - contextInfo:nil]; - - return; -} - +// MARK: Buttons -(void)rebaseButton:(id)sender { NSString *refName = [[[[historyController repository] currentBranch] simpleRef] refForSpec]; @@ -357,6 +366,23 @@ // NSLog([NSString stringWithFormat:@"Fetch hit for %@!", refName]); } +// MARK: Sheets + +- (void) showMessageSheet:(NSString *)title message:(NSString *)msg { + + [[NSAlert alertWithMessageText:title + defaultButton:@"OK" + alternateButton:nil + otherButton:nil + informativeTextWithFormat:msg] + beginSheetModalForWindow:[[historyController view] window] + modalDelegate:self + didEndSelector:nil + contextInfo:nil]; + + return; +} + -(void)saveSheet:(id) sender { NSString *branchName = [@"refs/heads/" stringByAppendingString:[newBranchName stringValue]]; @@ -632,8 +658,23 @@ - (void) selectCurrentBranch { PBGitRevSpecifier *rev = historyController.repository.currentBranch; - if (rev) - [branchPopUp setTitle:[rev description]]; + NSToolbar * tb = historyController.viewToolbar; + NSArray * tbLabels = [NSArray arrayWithObjects:@"Push", @"Pull", @"Rebase", nil]; + + if (rev) { + [branchPopUp setTitle:[rev description]]; + + if ([[rev description] isEqualToString:@"All branches"] || + [[rev description] isEqualToString:@"Local branches"]) + { + [self toggleToolbarItems:tb matchingLabels:tbLabels enabledState:NO]; + } else { + [self toggleToolbarItems:tb matchingLabels:tbLabels enabledState:YES]; + } + } else { + /* just in case, re-enable all toolbar buttons */ + [self toggleToolbarItems:tb matchingLabels:nil enabledState:YES]; + } } @end diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index 1934b73..e8638be 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -112,7 +112,7 @@ contextMenuItemsForElement:(NSDictionary *)element // Every ref has a class name of 'refs' and some other class. We check on that to see if we pressed on a ref. if ([[node className] hasPrefix:@"refs "]) { NSString *selectedRefString = [[[node childNodes] item:0] textContent]; - for (PBGitRef *ref in historyController.webCommit.refs) + for (PBGitRef *ref in [historyController.webCommit refs]) { if ([[ref shortName] isEqualToString:selectedRefString]) return [contextMenuDelegate menuItemsForRef:ref commit:historyController.webCommit]; diff --git a/RepositoryWindow.xib b/RepositoryWindow.xib index c8a5253..aa09779 100644 --- a/RepositoryWindow.xib +++ b/RepositoryWindow.xib @@ -81,9 +81,11 @@ View selector - + 268 {{0, 14}, {87, 25}} + + 3 YES @@ -141,9 +143,11 @@ Clone Clone a repository - + 268 {{1, 14}, {36, 25}} + + YES -2080244224 @@ -184,9 +188,11 @@ - + 265 {{0, 14}, {183, 22}} + + YES 343014976 @@ -279,9 +285,11 @@ Create Branch - + 268 {{21, 14}, {40, 25}} + + YES -2080244224 @@ -320,9 +328,11 @@ Branch - + 268 {{0, 14}, {134, 26}} + + YES -2076049856 @@ -411,9 +421,11 @@ ZW1vdGUgY29uZmlndXJlZCBmb3IgdGhlIGN1cnJlbnRseSBzZWxlY3RlZCBicmFuY2ggZnJvbSB0aGUg YnJhbmNoIHBvcHVwIG1lbnUuIAoKTm90ZTogdGhlIGJyYW5jaCBoYXMgdG8gYmUgc3BlY2lmaWMuIAon QWxsIGJyYW5jaGVzJyBvciAnTG9jYWwgYnJhbmNoZXMnIHdpbGwgbm90IHdvcmsuA - + 268 {{0, 14}, {35, 25}} + + YES -2080244224 @@ -456,9 +468,11 @@ bGVjdGVkIGJyYW5jaCBmcm9tIHRoZSBicmFuY2ggcG9wdXAgbWVudQoKTm90ZTogdGhlIGJyYW5jaCBo YXMgdG8gYmUgc3BlY2lmaWMuIAonQWxsIGJyYW5jaGVzJyBvciAnTG9jYWwgYnJhbmNoZXMnIHdpbGwg bm90IHdvcms - + 268 {{0, 14}, {35, 25}} + + YES -2080244224 @@ -505,9 +519,11 @@ ZXMgdGhhdCBpbmZvcm1hdGlvbiB0byBhdm9pZCByZWJhc2luZyBub24tbG9jYWwgY2hhbmdlcwoKTm90 ZTogdGhlIGxvY2FsIGJyYW5jaCBoYXMgdG8gYmUgc3BlY2lmaWMuIAonQWxsIGJyYW5jaGVzJyBvciAn TG9jYWwgYnJhbmNoZXMnIHdpbGwgbm90IHdvcmsuA - + 268 {{5, 14}, {35, 25}} + + YES -2080244224 @@ -1006,9 +1022,9 @@ TG9jYWwgYnJhbmNoZXMnIHdpbGwgbm90IHdvcmsuA YES com.apple.InterfaceBuilder.CocoaPlugin - {{180, 303}, {850, 550}} + {{519, 294}, {850, 550}} com.apple.InterfaceBuilder.CocoaPlugin - {{180, 303}, {850, 550}} + {{519, 294}, {850, 550}} {{15, 196}, {850, 418}} @@ -1016,7 +1032,7 @@ TG9jYWwgYnJhbmNoZXMnIHdpbGwgbm90IHdvcmsuA {3.40282e+38, 3.40282e+38} {213, 107} - {{297, 853}, {616, 0}} + {{636, 844}, {616, 0}} com.apple.InterfaceBuilder.CocoaPlugin {{132, 614}, {616, 0}} com.apple.InterfaceBuilder.CocoaPlugin