diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index ea765bb..65ea4fa 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -21,6 +21,8 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 02B41A5E123E307200DFC531 /* PBCommitHookFailedSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 02B41A5D123E307200DFC531 /* PBCommitHookFailedSheet.m */; }; + 02B41A60123E307F00DFC531 /* PBCommitHookFailedSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */; }; 056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; }; 310DC1D81240599E0017A0F7 /* GLFileView.m in Sources */ = {isa = PBXBuildFile; fileRef = 310DC1D71240599E0017A0F7 /* GLFileView.m */; }; 31460CD2124185BA00B90AED /* MGRecessedPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 31460CA7124185BA00B90AED /* MGRecessedPopUpButtonCell.m */; }; @@ -243,6 +245,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 02B41A5C123E307200DFC531 /* PBCommitHookFailedSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCommitHookFailedSheet.h; sourceTree = ""; }; + 02B41A5D123E307200DFC531 /* PBCommitHookFailedSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommitHookFailedSheet.m; sourceTree = ""; }; + 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PBCommitHookFailedSheet.xib; sourceTree = ""; }; 056438B60ED0C40B00985397 /* DetailViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DetailViewTemplate.png; path = Images/DetailViewTemplate.png; sourceTree = ""; }; 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; @@ -637,6 +642,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 02B41A5F123E307F00DFC531 /* PBCommitHookFailedSheet.xib */, F5F7D0641062E7940072C81C /* UpdateKey.pem */, F50A41130EBB872D00208746 /* Widgets */, 47DBDB920E94F47200671A1E /* Preference Icons */, @@ -733,6 +739,8 @@ D82F435F111B9C6D00A25A39 /* Sheets */ = { isa = PBXGroup; children = ( + 02B41A5C123E307200DFC531 /* PBCommitHookFailedSheet.h */, + 02B41A5D123E307200DFC531 /* PBCommitHookFailedSheet.m */, D854948410D5C01B0083B917 /* PBCreateBranchSheet.h */, D854948510D5C01B0083B917 /* PBCreateBranchSheet.m */, D8E3B34B10DCA958001096A3 /* PBCreateTagSheet.h */, @@ -1219,6 +1227,7 @@ 31460CD4124185BA00B90AED /* ReadMe.txt in Resources */, 31460CD5124185BA00B90AED /* Source Code License.rtf in Resources */, 31460CD6124185BA00B90AED /* TODO in Resources */, + 02B41A60123E307F00DFC531 /* PBCommitHookFailedSheet.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1371,6 +1380,7 @@ 310DC1D81240599E0017A0F7 /* GLFileView.m in Sources */, 31460CD2124185BA00B90AED /* MGRecessedPopUpButtonCell.m in Sources */, 31460CD3124185BA00B90AED /* MGScopeBar.m in Sources */, + 02B41A5E123E307200DFC531 /* PBCommitHookFailedSheet.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBCommitHookFailedSheet.h b/PBCommitHookFailedSheet.h new file mode 100644 index 0000000..869d196 --- /dev/null +++ b/PBCommitHookFailedSheet.h @@ -0,0 +1,25 @@ +// +// PBCommitHookFailedSheet.h +// GitX +// +// Created by Sebastian Staudt on 9/12/10. +// Copyright 2010 Sebastian Staudt. All rights reserved. +// + +#import + +#import "PBGitCommitController.h" +#import "PBGitXMessageSheet.h" + + +@interface PBCommitHookFailedSheet : PBGitXMessageSheet +{ + PBGitCommitController *commitController; +} + ++ (void)beginMessageSheetForWindow:(NSWindow *)parentWindow withMessageText:(NSString *)message infoText:(NSString *)info commitController:(PBGitCommitController *)controller; + +- (id)initWithWindowNibName:(NSString *)windowNibName andController:(PBGitCommitController *)controller; +- (IBAction)forceCommit:(id)sender; + +@end \ No newline at end of file diff --git a/PBCommitHookFailedSheet.m b/PBCommitHookFailedSheet.m new file mode 100644 index 0000000..907d85a --- /dev/null +++ b/PBCommitHookFailedSheet.m @@ -0,0 +1,38 @@ +// +// PBCommitHookFailedSheet.m +// GitX +// +// Created by Sebastian Staudt on 9/12/10. +// Copyright 2010 Sebastian Staudt. All rights reserved. +// + +#import "PBCommitHookFailedSheet.h" +#import "PBGitWindowController.h" + + +@implementation PBCommitHookFailedSheet + +#pragma mark - +#pragma mark PBCommitHookFailedSheet + ++ (void)beginMessageSheetForWindow:(NSWindow *)parentWindow withMessageText:(NSString *)message infoText:(NSString *)info commitController:(PBGitCommitController *)controller +{ + PBCommitHookFailedSheet *sheet = [[self alloc] initWithWindowNibName:@"PBCommitHookFailedSheet" andController:controller]; + [sheet beginMessageSheetForWindow:parentWindow withMessageText:message infoText:info]; +} + +- (id)initWithWindowNibName:(NSString *)windowNibName andController:(PBGitCommitController *)controller; +{ + self = [self initWithWindowNibName:windowNibName]; + commitController = controller; + + return self; +} + +- (IBAction)forceCommit:(id)sender +{ + [self closeMessageSheet:self]; + [commitController forceCommit:sender]; +} + +@end diff --git a/PBCommitHookFailedSheet.xib b/PBCommitHookFailedSheet.xib new file mode 100644 index 0000000..60e58b1 --- /dev/null +++ b/PBCommitHookFailedSheet.xib @@ -0,0 +1,1288 @@ + + + + 1050 + 10F569 + 788 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 788 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + PBCommitHookFailedSheet + + + FirstResponder + + + NSApplication + + + 1 + 2 + {{196, 331}, {540, 179}} + 544736256 + Window + NSWindow + + {1.79769e+308, 1.79769e+308} + + + 256 + + YES + + + 289 + {{430, 12}, {96, 32}} + + YES + + 67239424 + 134217728 + OK + + LucidaGrande + 13 + 1044 + + + -2038284033 + 129 + + DQ + 200 + 25 + + + + + 268 + + YES + + YES + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple PNG pasteboard type + NSFilenamesPboardType + NeXT Encapsulated PostScript v1.2 pasteboard type + NeXT TIFF v4.0 pasteboard type + + + {{17, 98}, {64, 64}} + + YES + + 130560 + 33554432 + + NSImage + NSApplicationIcon + + 0 + 0 + 0 + NO + + YES + + + + 266 + {{99, 142}, {424, 17}} + + YES + + 67239424 + 272629760 + <message> + + LucidaGrande-Bold + 13 + 16 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + + 274 + + YES + + + 2304 + + YES + + + 2322 + {423, 14} + + + + + + PGluZm8+A + + + YES + + YES + NSFont + NSParagraphStyle + + + YES + + Helvetica + 12 + 16 + + + 4 + + + + + + + + YES + + + 134 + + + + 423 + 1 + + + 2049 + 0 + + + 3 + MQA + + + YES + + YES + NSBackgroundColor + NSColor + + + YES + + 6 + System + selectedTextBackgroundColor + + + + 6 + System + selectedTextColor + + + + + + + YES + + YES + NSColor + NSCursor + NSUnderline + + + YES + + 1 + MCAwIDEAA + + + {8, -8} + 13 + + + + + + + 6 + {423, 1e+07} + {223, 0} + + + + {422, 72} + + + + + + {4, -5} + 1 + + 2 + + + + -2147483392 + {{386, 1}, {15, 163}} + + + _doScroller: + 1 + 0.85256409645080566 + + + + -2147483392 + {{-100, -100}, {87, 18}} + + YES + 1 + + _doScroller: + 1 + 0.94565218687057495 + + + {{98, 60}, {422, 72}} + + + 656 + + + + + + + 289 + {{289, 12}, {129, 32}} + + YES + + 67239424 + 134217728 + Force Commit + + + -2038284033 + 129 + + DQ + 200 + 25 + + + + {540, 179} + + + {{0, 0}, {1680, 1028}} + {1.79769e+308, 1.79769e+308} + + + + + YES + + + iconView + + + + 15 + + + + infoView + + + + 16 + + + + messageField + + + + 17 + + + + window + + + + 18 + + + + closeMessageSheet: + + + + 19 + + + + scrollView + + + + 20 + + + + forceCommit: + + + + 24 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + 2 + + + YES + + + + + + + + + + 3 + + + YES + + + + + + 4 + + + + + 7 + + + YES + + + + + + 8 + + + + + 9 + + + YES + + + + + + 10 + + + + + 11 + + + YES + + + + + + + + 12 + + + + + 13 + + + + + 14 + + + + + 21 + + + YES + + + + + + 22 + + + + + + + YES + + YES + -1.IBPluginDependency + -2.IBPluginDependency + -3.IBPluginDependency + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.IBWindowTemplateEditedContentRect + 1.NSWindowTemplate.visibleAtLaunch + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 10.IBPluginDependency + 11.IBPluginDependency + 12.IBPluginDependency + 13.IBPluginDependency + 14.IBPluginDependency + 2.IBPluginDependency + 2.IBUserGuides + 21.IBPluginDependency + 22.IBPluginDependency + 3.IBPluginDependency + 4.IBPluginDependency + 7.IBPluginDependency + 8.IBPluginDependency + 9.IBPluginDependency + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{279, 244}, {540, 179}} + com.apple.InterfaceBuilder.CocoaPlugin + {{279, 244}, {540, 179}} + + {196, 240} + {{357, 418}, {480, 270}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + YES + + + 103 + 0 + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 24 + + + + YES + + PBCommitHookFailedSheet + PBGitXMessageSheet + + forceCommit: + id + + + forceCommit: + + forceCommit: + id + + + + IBProjectSource + PBCommitHookFailedSheet.h + + + + PBGitXMessageSheet + NSWindowController + + closeMessageSheet: + id + + + closeMessageSheet: + + closeMessageSheet: + id + + + + YES + + YES + iconView + infoView + messageField + scrollView + + + YES + NSImageView + NSTextView + NSTextField + NSScrollView + + + + YES + + YES + iconView + infoView + messageField + scrollView + + + YES + + iconView + NSImageView + + + infoView + NSTextView + + + messageField + NSTextField + + + scrollView + NSScrollView + + + + + IBProjectSource + PBGitXMessageSheet.h + + + + + YES + + NSActionCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSActionCell.h + + + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + + + NSButton + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSButton.h + + + + NSButtonCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSButtonCell.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSImageCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSImageCell.h + + + + NSImageView + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSImageView.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUAppcast.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUUpdater.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebDownload.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebEditingDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebFrameLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebJavaPlugIn.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPlugin.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPluginContainer.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPolicyDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebResourceLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebScriptObject.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebUIDelegate.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSScrollView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSScrollView.h + + + + NSScroller + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSScroller.h + + + + NSText + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSText.h + + + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSTextFieldCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSTextFieldCell.h + + + + NSTextView + NSText + + IBFrameworkSource + AppKit.framework/Headers/NSTextView.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSWindow + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSWindowScripting.h + + + + NSWindowController + NSResponder + + showWindow: + id + + + showWindow: + + showWindow: + id + + + + IBFrameworkSource + AppKit.framework/Headers/NSWindowController.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + GitX.xcodeproj + 3 + + NSApplicationIcon + {128, 128} + + + diff --git a/PBCreateBranchSheet.m b/PBCreateBranchSheet.m index ebd2643..0eb8d2a 100644 --- a/PBCreateBranchSheet.m +++ b/PBCreateBranchSheet.m @@ -51,6 +51,16 @@ [self.errorMessageField setStringValue:@""]; self.shouldCheckoutBranch = [PBGitDefaults shouldCheckoutBranch]; + // when creating a local branch tracking a remote branch preset the branch name to the name of the remote branch + if ([self.startRefish refishType] == kGitXRemoteBranchType) { + NSMutableArray *components = [[[self.startRefish shortName] componentsSeparatedByString:@"/"] mutableCopy]; + if ([components count] > 1) { + [components removeObjectAtIndex:0]; + NSString *branchName = [components componentsJoinedByString:@"/"]; + [self.branchNameField setStringValue:branchName]; + } + } + [NSApp beginSheet:[self window] modalForWindow:[self.repository.windowController window] modalDelegate:self didEndSelector:nil contextInfo:NULL]; } diff --git a/PBDiffWindowController.m b/PBDiffWindowController.m index 496c850..06403d5 100644 --- a/PBDiffWindowController.m +++ b/PBDiffWindowController.m @@ -9,6 +9,7 @@ #import "PBDiffWindowController.h" #import "PBGitRepository.h" #import "PBGitCommit.h" +#import "PBGitDefaults.h" @implementation PBDiffWindowController @@ -34,6 +35,10 @@ NSString *commitSelector = [NSString stringWithFormat:@"%@..%@", [startCommit realSha], [diffCommit realSha]]; NSMutableArray *arguments = [NSMutableArray arrayWithObjects:@"diff", commitSelector, nil]; + + if (![PBGitDefaults showWhitespaceDifferences]) + [arguments insertObject:@"-w" atIndex:1]; + if (filePaths) { [arguments addObject:@"--"]; [arguments addObjectsFromArray:filePaths]; diff --git a/PBGitCommitController.h b/PBGitCommitController.h index 0b39f05..ac852a3 100644 --- a/PBGitCommitController.h +++ b/PBGitCommitController.h @@ -29,5 +29,6 @@ - (IBAction) refresh:(id) sender; - (IBAction) commit:(id) sender; +- (IBAction) forceCommit:(id) sender; - (IBAction)signOff:(id)sender; @end diff --git a/PBGitCommitController.m b/PBGitCommitController.m index 02d74e1..9f0eca1 100644 --- a/PBGitCommitController.m +++ b/PBGitCommitController.m @@ -14,9 +14,11 @@ @interface PBGitCommitController () - (void)refreshFinished:(NSNotification *)notification; +- (void)commitWithVerification:(BOOL) doVerify; - (void)commitStatusUpdated:(NSNotification *)notification; - (void)commitFinished:(NSNotification *)notification; - (void)commitFailed:(NSNotification *)notification; +- (void)commitHookFailed:(NSNotification *)notification; - (void)amendCommit:(NSNotification *)notification; - (void)indexChanged:(NSNotification *)notification; - (void)indexOperationFailed:(NSNotification *)notification; @@ -38,6 +40,7 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitStatusUpdated:) name:PBGitIndexCommitStatus object:index]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitFinished:) name:PBGitIndexFinishedCommit object:index]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitFailed:) name:PBGitIndexCommitFailed object:index]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(commitHookFailed:) name:PBGitIndexCommitHookFailed object:index]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(amendCommit:) name:PBGitIndexAmendMessageAvailable object:index]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(indexChanged:) name:PBGitIndexIndexUpdated object:index]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(indexOperationFailed:) name:PBGitIndexOperationFailed object:index]; @@ -106,6 +109,16 @@ } - (IBAction) commit:(id) sender +{ + [self commitWithVerification:YES]; +} + +- (IBAction) forceCommit:(id) sender +{ + [self commitWithVerification:NO]; +} + +- (void) commitWithVerification:(BOOL) doVerify { 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."]; @@ -129,7 +142,7 @@ self.isBusy = YES; [commitMessageView setEditable:NO]; - [index commitWithMessage:commitMessage]; + [index commitWithMessage:commitMessage andVerify:doVerify]; } @@ -161,6 +174,15 @@ [[repository windowController] showMessageSheet:@"Commit failed" infoText:reason]; } +- (void)commitHookFailed:(NSNotification *)notification +{ + self.isBusy = NO; + NSString *reason = [[notification userInfo] objectForKey:@"description"]; + self.status = [@"Commit hook failed: " stringByAppendingString:reason]; + [commitMessageView setEditable:YES]; + [[repository windowController] showCommitHookFailedSheet:@"Commit hook failed" infoText:reason commitController:self]; +} + - (void)amendCommit:(NSNotification *)notification { // Replace commit message with the old one if it's less than 3 characters long. diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index 1693689..dd024d9 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -672,10 +672,8 @@ - (IBAction) rebase:(id)sender { - if (selectedCommit) { - PBGitRef *headRef = [[repository headRef] ref]; - [repository rebaseBranch:headRef onRefish:selectedCommit]; - } + if (selectedCommit) + [repository rebaseBranch:nil onRefish:selectedCommit]; } #pragma mark - diff --git a/PBGitIndex.h b/PBGitIndex.h index 7ca1db7..dee0651 100644 --- a/PBGitIndex.h +++ b/PBGitIndex.h @@ -26,6 +26,7 @@ extern NSString *PBGitIndexIndexUpdated; // Committing files extern NSString *PBGitIndexCommitStatus; extern NSString *PBGitIndexCommitFailed; +extern NSString *PBGitIndexCommitHookFailed; extern NSString *PBGitIndexFinishedCommit; // Changing to amend @@ -66,7 +67,7 @@ extern NSString *PBGitIndexOperationFailed; // Refresh the index - (void)refresh; -- (void)commitWithMessage:(NSString *)commitMessage; +- (void)commitWithMessage:(NSString *)commitMessage andVerify:(BOOL) doVerify; // Inter-file changes: - (BOOL)stageFiles:(NSArray *)stageFiles; diff --git a/PBGitIndex.m b/PBGitIndex.m index ae954fa..e41e5e5 100644 --- a/PBGitIndex.m +++ b/PBGitIndex.m @@ -21,6 +21,7 @@ NSString *PBGitIndexIndexUpdated = @"GBGitIndexIndexUpdated"; NSString *PBGitIndexCommitStatus = @"PBGitIndexCommitStatus"; NSString *PBGitIndexCommitFailed = @"PBGitIndexCommitFailed"; +NSString *PBGitIndexCommitHookFailed = @"PBGitIndexCommitHookFailed"; NSString *PBGitIndexFinishedCommit = @"PBGitIndexFinishedCommit"; NSString *PBGitIndexAmendMessageAvailable = @"PBGitIndexAmendMessageAvailable"; @@ -48,6 +49,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; - (NSString *) parentTree; - (void)postCommitUpdate:(NSString *)update; - (void)postCommitFailure:(NSString *)reason; +- (void)postCommitHookFailure:(NSString *)reason; - (void)postIndexChange; - (void)postOperationFailed:(NSString *)description; @end @@ -145,7 +147,7 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; } // TODO: make Asynchronous -- (void)commitWithMessage:(NSString *)commitMessage +- (void)commitWithMessage:(NSString *)commitMessage andVerify:(BOOL) doVerify { NSMutableString *commitSubject = [@"commit: " mutableCopy]; NSRange newLine = [commitMessage rangeOfString:@"\n"]; @@ -176,12 +178,26 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; [self postCommitUpdate:@"Creating commit"]; int ret = 1; - [self postCommitUpdate:@"Running hooks"]; - if (![repository executeHook:@"pre-commit" output:nil]) - return [self postCommitFailure:@"Pre-commit hook failed"]; - - if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil]) - return [self postCommitFailure:@"Commit-msg hook failed"]; + if (doVerify) { + [self postCommitUpdate:@"Running hooks"]; + NSString *hookFailureMessage = nil; + NSString *hookOutput = nil; + if (![repository executeHook:@"pre-commit" output:&hookOutput]) { + hookFailureMessage = [NSString stringWithFormat:@"Pre-commit hook failed%@%@", + [hookOutput length] > 0 ? @":\n" : @"", + hookOutput]; + } + + if (![repository executeHook:@"commit-msg" withArgs:[NSArray arrayWithObject:commitMessageFile] output:nil]) { + hookFailureMessage = [NSString stringWithFormat:@"Commit-msg hook failed%@%@", + [hookOutput length] > 0 ? @":\n" : @"", + hookOutput]; + } + + if (hookFailureMessage != nil) { + return [self postCommitHookFailure:hookFailureMessage]; + } + } commitMessage = [NSString stringWithContentsOfFile:commitMessageFile encoding:NSUTF8StringEncoding error:nil]; @@ -242,6 +258,13 @@ NSString *PBGitIndexOperationFailed = @"PBGitIndexOperationFailed"; userInfo:[NSDictionary dictionaryWithObject:reason forKey:@"description"]]; } +- (void)postCommitHookFailure:(NSString *)reason +{ + [[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexCommitHookFailed + object:self + userInfo:[NSDictionary dictionaryWithObject:reason forKey:@"description"]]; +} + - (void)postOperationFailed:(NSString *)description { [[NSNotificationCenter defaultCenter] postNotificationName:PBGitIndexOperationFailed diff --git a/PBGitRepository.m b/PBGitRepository.m index 9d7862c..3d4489b 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -625,24 +625,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; NSString *remoteName = [remoteRef remoteName]; [arguments addObject:remoteName]; - NSString *branchName = nil; - NSString *refSpec = nil; - if ([ref isRemoteBranch]) { - branchName = [ref shortName]; - refSpec = [ref remoteBranchName]; - } - else if ([ref isRemote] || !ref) { - branchName = @"all tracking branches"; - } - else { - branchName = [ref shortName]; - refSpec = [NSString stringWithFormat:@"%@:%@", branchName, branchName]; - } - if (refSpec) - [arguments addObject:refSpec]; - - NSString *headRefName = [[[self headRef] ref] shortName]; - NSString *description = [NSString stringWithFormat:@"Pulling %@ from %@ and updating %@", branchName, remoteName, headRefName]; + NSString *description = [NSString stringWithFormat:@"Pulling all tracking branches from %@", remoteName]; NSString *title = @"Pulling from remote"; [PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self]; } @@ -905,7 +888,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; #pragma mark GitX Scripting -- (void)handleRevListArguments:(NSArray *)arguments +- (void)handleRevListArguments:(NSArray *)arguments inWorkingDirectory:(NSURL *)workingDirectory { if (![arguments count]) return; @@ -915,19 +898,23 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; // the argument may be a branch or tag name but will probably not be the full reference if ([arguments count] == 1) { PBGitRef *refArgument = [self refForName:[arguments lastObject]]; - if (refArgument) + if (refArgument) { revListSpecifier = [[PBGitRevSpecifier alloc] initWithRef:refArgument]; + revListSpecifier.workingDirectory = workingDirectory; + } } - if (!revListSpecifier) + if (!revListSpecifier) { revListSpecifier = [[PBGitRevSpecifier alloc] initWithParameters:arguments]; + revListSpecifier.workingDirectory = workingDirectory; + } self.currentBranch = [self addBranch:revListSpecifier]; [PBGitDefaults setShowStageView:NO]; [self.windowController showHistoryView:self]; } -- (void)handleBranchFilterEventForFilter:(PBGitXBranchFilterType)filter additionalArguments:(NSMutableArray *)arguments +- (void)handleBranchFilterEventForFilter:(PBGitXBranchFilterType)filter additionalArguments:(NSMutableArray *)arguments inWorkingDirectory:(NSURL *)workingDirectory { self.currentBranchFilter = filter; [PBGitDefaults setShowStageView:NO]; @@ -936,11 +923,11 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; // treat any additional arguments as a rev-list specifier if ([arguments count] > 1) { [arguments removeObjectAtIndex:0]; - [self handleRevListArguments:arguments]; + [self handleRevListArguments:arguments inWorkingDirectory:workingDirectory]; } } -- (void)handleGitXScriptingArguments:(NSAppleEventDescriptor *)argumentsList +- (void)handleGitXScriptingArguments:(NSAppleEventDescriptor *)argumentsList inWorkingDirectory:(NSURL *)workingDirectory { NSMutableArray *arguments = [NSMutableArray array]; uint argumentsIndex = 1; // AppleEvent list descriptor's are one based @@ -964,22 +951,22 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; } if ([firstArgument isEqualToString:@"--all"]) { - [self handleBranchFilterEventForFilter:kGitXAllBranchesFilter additionalArguments:arguments]; + [self handleBranchFilterEventForFilter:kGitXAllBranchesFilter additionalArguments:arguments inWorkingDirectory:workingDirectory]; return; } if ([firstArgument isEqualToString:@"--local"]) { - [self handleBranchFilterEventForFilter:kGitXLocalRemoteBranchesFilter additionalArguments:arguments]; + [self handleBranchFilterEventForFilter:kGitXLocalRemoteBranchesFilter additionalArguments:arguments inWorkingDirectory:workingDirectory]; return; } if ([firstArgument isEqualToString:@"--branch"]) { - [self handleBranchFilterEventForFilter:kGitXSelectedBranchFilter additionalArguments:arguments]; + [self handleBranchFilterEventForFilter:kGitXSelectedBranchFilter additionalArguments:arguments inWorkingDirectory:workingDirectory]; return; } // if the argument is not a known command then treat it as a rev-list specifier - [self handleRevListArguments:arguments]; + [self handleRevListArguments:arguments inWorkingDirectory:workingDirectory]; } // see if the current appleEvent has the command line arguments from the gitx cli @@ -996,9 +983,10 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; // on app launch there may be many repositories opening, so double check that this is the right repo NSString *path = [[eventRecord paramDescriptorForKeyword:typeFileURL] stringValue]; if (path) { - if ([[PBGitRepository gitDirForURL:[NSURL URLWithString:path]] isEqual:[self fileURL]]) { + NSURL *workingDirectory = [NSURL URLWithString:path]; + if ([[PBGitRepository gitDirForURL:workingDirectory] isEqual:[self fileURL]]) { NSAppleEventDescriptor *argumentsList = [eventRecord paramDescriptorForKeyword:kGitXAEKeyArgumentsList]; - [self handleGitXScriptingArguments:argumentsList]; + [self handleGitXScriptingArguments:argumentsList inWorkingDirectory:workingDirectory]; // showWindows may be called more than once during app launch so remove the CLI data after we handle the event [currentAppleEvent removeDescriptorWithKeyword:keyAEPropData]; diff --git a/PBGitRevList.mm b/PBGitRevList.mm index 851d6ed..8ab64e1 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -102,7 +102,7 @@ using namespace std; std::map encodingMap; NSThread *currentThread = [NSThread currentThread]; - NSString *formatString = @"--pretty=format:%H\01%e\01%an\01%cn\01%s\01%P\01%at"; + NSString *formatString = @"--pretty=format:%H\01%e\01%aN\01%cN\01%s\01%P\01%at"; BOOL showSign = [rev hasLeftRight]; if (showSign) diff --git a/PBGitWindowController.h b/PBGitWindowController.h index 29f5245..0f38e22 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -9,7 +9,7 @@ #import #import "PBGitRepository.h" -@class PBViewController, PBGitSidebarController; +@class PBViewController, PBGitSidebarController, PBGitCommitController; @interface PBGitWindowController : NSWindowController { __weak PBGitRepository* repository; @@ -37,6 +37,7 @@ - (void)changeContentController:(PBViewController *)controller; +- (void)showCommitHookFailedSheet:(NSString *)messageText infoText:(NSString *)infoText commitController:(PBGitCommitController *)controller; - (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText; - (void)showErrorSheet:(NSError *)error; - (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 1968c48..9fb9c13 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -11,6 +11,7 @@ #import "PBGitCommitController.h" #import "Terminal.h" #import "PBCloneRepsitoryToSheet.h" +#import "PBCommitHookFailedSheet.h" #import "PBGitXMessageSheet.h" #import "PBGitSidebarController.h" @@ -109,6 +110,11 @@ [sidebarController selectCurrentBranch]; } +- (void)showCommitHookFailedSheet:(NSString *)messageText infoText:(NSString *)infoText commitController:(PBGitCommitController *)controller +{ + [PBCommitHookFailedSheet beginMessageSheetForWindow:[self window] withMessageText:messageText infoText:infoText commitController:controller]; +} + - (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText { [PBGitXMessageSheet beginMessageSheetForWindow:[self window] withMessageText:messageText infoText:infoText]; diff --git a/PBGitXMessageSheet.h b/PBGitXMessageSheet.h index 440cf01..60cd3c7 100644 --- a/PBGitXMessageSheet.h +++ b/PBGitXMessageSheet.h @@ -21,6 +21,7 @@ + (void)beginMessageSheetForWindow:(NSWindow *)parentWindow withError:(NSError *)error; +- (void)beginMessageSheetForWindow:(NSWindow *)parentWindow withMessageText:(NSString *)message infoText:(NSString *)info; - (IBAction)closeMessageSheet:(id)sender; diff --git a/PBGitXMessageSheet.m b/PBGitXMessageSheet.m index 5c8441c..783cc94 100644 --- a/PBGitXMessageSheet.m +++ b/PBGitXMessageSheet.m @@ -14,8 +14,6 @@ @interface PBGitXMessageSheet () -- (void)beginMessageSheetForWindow:(NSWindow *)parentWindow withMessageText:(NSString *)message infoText:(NSString *)info; - - (void)setInfoString:(NSString *)info; - (void)resizeWindow; diff --git a/PBRefController.m b/PBRefController.m index 1b07f00..c9b8c2e 100644 --- a/PBRefController.m +++ b/PBRefController.m @@ -147,9 +147,8 @@ - (void) rebaseHeadBranch:(PBRefMenuItem *)sender { id refish = [sender refish]; - PBGitRef *headRef = [[historyController.repository headRef] ref]; - [historyController.repository rebaseBranch:headRef onRefish:refish]; + [historyController.repository rebaseBranch:nil onRefish:refish]; } diff --git a/PBRefMenuItem.m b/PBRefMenuItem.m index 4b47fdc..083de7b 100644 --- a/PBRefMenuItem.m +++ b/PBRefMenuItem.m @@ -59,7 +59,8 @@ [items addObject:[PBRefMenuItem separatorItem]]; // create branch - [items addObject:[PBRefMenuItem itemWithTitle:@"Create branch…" action:@selector(createBranch:) enabled:YES]]; + NSString *createBranchTitle = [ref isRemoteBranch] ? [NSString stringWithFormat:@"Create branch that tracks %@…", targetRefName] : @"Create branch…"; + [items addObject:[PBRefMenuItem itemWithTitle:createBranchTitle action:@selector(createBranch:) enabled:YES]]; // create tag [items addObject:[PBRefMenuItem itemWithTitle:@"Create Tag…" action:@selector(createTag:) enabled:YES]]; @@ -89,8 +90,7 @@ [items addObject:[PBRefMenuItem itemWithTitle:fetchTitle action:@selector(fetchRemote:) enabled:hasRemote]]; // pull - NSString *pullRemoteName = [ref isRemoteBranch] ? [ref shortName] : remoteName; - NSString *pullTitle = hasRemote ? [NSString stringWithFormat:@"Pull %@ and update %@", pullRemoteName, headRefName] : @"Pull"; + NSString *pullTitle = hasRemote ? [NSString stringWithFormat:@"Pull %@ and update %@", remoteName, headRefName] : @"Pull"; [items addObject:[PBRefMenuItem itemWithTitle:pullTitle action:@selector(pullRemote:) enabled:hasRemote]]; // push diff --git a/gitx.m b/gitx.m index 05f2aa8..3230d01 100644 --- a/gitx.m +++ b/gitx.m @@ -120,9 +120,8 @@ void handleSTDINDiff() if (diff && [diff length] > 0) { GitXApplication *gitXApp = [SBApplication applicationWithBundleIdentifier:kGitXBundleIdentifier]; [gitXApp showDiff:diff]; + exit(0); } - - exit(0); } void handleDiffWithArguments(NSURL *repositoryURL, NSMutableArray *arguments) diff --git a/html/views/history/history.css b/html/views/history/history.css index 21e939c..7d855aa 100644 --- a/html/views/history/history.css +++ b/html/views/history/history.css @@ -26,12 +26,21 @@ body { float: left; } -#gist { - -webkit-appearance: button; - font: 13px bold 'Lucida Grande'; - width: 80px; - height: 23px; - margin-right: 5px; +a.servicebutton { + display: block; + width: 80px; + padding: 2px; + margin-bottom: 4px; + + border: 1px solid #3465a4; + background-color: #cce5ff; + color: #204a87; + + font-size: 65%; + text-decoration: none; + text-align: center; + + -webkit-border-radius: 2px; } .gravatar { @@ -130,7 +139,7 @@ a.showdiff { font-size: 9px; font-family: Helvetica; border: 1px solid black; - margin-right: 5px; + margin-right: 2px; padding: 1px 3px 1px 3px; -webkit-border-radius: 2px; } diff --git a/html/views/history/history.js b/html/views/history/history.js index ca970fb..c0ac4c6 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -161,7 +161,7 @@ var showRefs = function() { refs.innerHTML = ""; for (var i = 0; i < commit.refs.length; i++) { var ref = commit.refs[i]; - refs.innerHTML += '' + ref.shortName() + ''; + refs.innerHTML += '' + ref.shortName() + ' '; } } else refs.parentNode.style.display = "none"; @@ -219,6 +219,8 @@ var loadCommit = function(commitObject, currentRef) { var showDiff = function() { + $("files").innerHTML = ""; + // Callback for the diff highlighter. Used to generate a filelist var newfile = function(name1, name2, id, mode_change, old_mode, new_mode) { var img = document.createElement("img"); diff --git a/html/views/history/index.html b/html/views/history/index.html index 20b3cd5..cc8d4a2 100644 --- a/html/views/history/index.html +++ b/html/views/history/index.html @@ -14,7 +14,9 @@
- + + Gist it +