Skip to content

Commit

Permalink
Add Merge.
Browse files Browse the repository at this point in the history
- PBGitRepository: add merge with branch and commit
- Add merge to contextual menus for refs and commits
- Add Merge toolbar item with drop down menu
- Add Merge icon (created by Nathan Kinsinger but based on the Add Remote icon by Kim Does)
- Modified the default toolbar icon set, replaced Rebase with Merge
  • Loading branch information
brotherbard committed Dec 3, 2009
1 parent ee59a68 commit 86ebf68
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 17 deletions.
4 changes: 4 additions & 0 deletions GitX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
93CB42C20EAB7B2200530609 /* PBGitDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB42C10EAB7B2200530609 /* PBGitDefaults.m */; };
93F7857F0EA3ABF100C1F443 /* PBCommitMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */; };
D26DC6450E782C9000C777B2 /* gitx.icns in Resources */ = {isa = PBXBuildFile; fileRef = D26DC6440E782C9000C777B2 /* gitx.icns */; };
D8342DDC10C77561009A00F8 /* MergePopUpTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = D8342DDB10C77561009A00F8 /* MergePopUpTemplate.png */; };
D8701E0E10ADFED70073689C /* ScriptingBridge.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8701E0D10ADFED70073689C /* ScriptingBridge.framework */; };
D8701E8D10AE24340073689C /* FetchPopUpTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = D8701E8C10AE24340073689C /* FetchPopUpTemplate.png */; };
D8701EDE10AE393B0073689C /* CheckoutPopUpTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = D8701EDD10AE393B0073689C /* CheckoutPopUpTemplate.png */; };
Expand Down Expand Up @@ -236,6 +237,7 @@
93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommitMessageView.m; sourceTree = "<group>"; };
93FCCBA80EA8AF450061B02B /* PBGitConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitConfig.m; sourceTree = "<group>"; };
D26DC6440E782C9000C777B2 /* gitx.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = gitx.icns; sourceTree = "<group>"; };
D8342DDB10C77561009A00F8 /* MergePopUpTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = MergePopUpTemplate.png; path = Images/MergePopUpTemplate.png; sourceTree = "<group>"; };
D8701DF810ADF7410073689C /* Terminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Terminal.h; sourceTree = "<group>"; };
D8701E0D10ADFED70073689C /* ScriptingBridge.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScriptingBridge.framework; path = /System/Library/Frameworks/ScriptingBridge.framework; sourceTree = "<absolute>"; };
D8701E8C10AE24340073689C /* FetchPopUpTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = FetchPopUpTemplate.png; path = Images/FetchPopUpTemplate.png; sourceTree = "<group>"; };
Expand Down Expand Up @@ -463,6 +465,7 @@
652C162410A94D0800B80380 /* PullPopUpTemplate.png */,
652C162510A94D0800B80380 /* PushPopUpTemplate.png */,
652C162610A94D0800B80380 /* RebasePopUpTemplate.png */,
D8342DDB10C77561009A00F8 /* MergePopUpTemplate.png */,
653D94A4109C42A500B26705 /* CloneRepositoryTemplate.png */,
3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */,
3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */,
Expand Down Expand Up @@ -899,6 +902,7 @@
652C162910A94D0800B80380 /* RebasePopUpTemplate.png in Resources */,
D8701E8D10AE24340073689C /* FetchPopUpTemplate.png in Resources */,
D8701EDE10AE393B0073689C /* CheckoutPopUpTemplate.png in Resources */,
D8342DDC10C77561009A00F8 /* MergePopUpTemplate.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Binary file added Images/MergePopUpTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 121 additions & 13 deletions PBGitHistoryView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@
</object>
<object class="NSToolbar" id="931038723">
<object class="NSMutableString" key="NSToolbarIdentifier">
<characters key="NS.bytes">3DC1ECE8-C325-4A32-9225-3937FE1462A0</characters>
<characters key="NS.bytes">E3ABA551-98DB-4A92-9F72-54F4CDA33699</characters>
</object>
<nil key="NSToolbarDelegate"/>
<bool key="NSToolbarPrefersToBeShown">YES</bool>
Expand All @@ -946,6 +946,7 @@
<string>86360841-A2B1-4802-845A-AE424521FE99</string>
<string>99C2C9EB-AE16-42A9-BE52-46CE903E9AF9</string>
<string>A1AE204D-2CE3-4713-8514-824202042440</string>
<string>A476B356-2DD9-460C-82B2-0536A41E67F9</string>
<string>AF4D111F-4FE6-4D6A-8B1E-827F7A419C11</string>
<string>C034B3AD-2E7F-4D76-BCB7-E8332F007018</string>
<string>EB7863DB-808B-46C2-8B61-65D6C40F796C</string>
Expand Down Expand Up @@ -1351,7 +1352,49 @@
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{25, 25}</string>
<string key="NSToolbarItemMaxSize">{42, 25}</string>
<string key="NSToolbarItemMaxSize">{35, 25}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">0</int>
<bool key="NSToolbarIsUserRemovable">YES</bool>
<int key="NSToolbarItemVisibilityPriority">0</int>
</object>
<object class="NSToolbarItem" id="677544345">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">A476B356-2DD9-460C-82B2-0536A41E67F9</characters>
</object>
<string key="NSToolbarItemLabel">Merge</string>
<string key="NSToolbarItemPaletteLabel">Merge</string>
<string key="NSToolbarItemToolTip"/>
<object class="NSButton" key="NSToolbarItemView" id="94822105">
<reference key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{2, 14}, {38, 25}}</string>
<reference key="NSSuperview"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="864578243">
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="924107556"/>
<reference key="NSControlView" ref="94822105"/>
<int key="NSButtonFlags">-2033434369</int>
<int key="NSButtonFlags2">163</int>
<object class="NSCustomResource" key="NSNormalImage" id="75109982">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">MergePopUpTemplate</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
</object>
<reference key="NSToolbarItemImage" ref="75109982"/>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{25, 25}</string>
<string key="NSToolbarItemMaxSize">{35, 25}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">0</int>
Expand Down Expand Up @@ -1463,7 +1506,7 @@
<reference key="NSControlView" ref="166309462"/>
<int key="NSButtonFlags">-2033434369</int>
<int key="NSButtonFlags2">163</int>
<object class="NSCustomResource" key="NSNormalImage" id="994310630">
<object class="NSCustomResource" key="NSNormalImage" id="1059478942">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">RebasePopUpTemplate</string>
</object>
Expand All @@ -1473,11 +1516,11 @@
<int key="NSPeriodicInterval">75</int>
</object>
</object>
<reference key="NSToolbarItemImage" ref="994310630"/>
<reference key="NSToolbarItemImage" ref="1059478942"/>
<nil key="NSToolbarItemTarget"/>
<nil key="NSToolbarItemAction"/>
<string key="NSToolbarItemMinSize">{25, 25}</string>
<string key="NSToolbarItemMaxSize">{42, 25}</string>
<string key="NSToolbarItemMaxSize">{35, 25}</string>
<bool key="NSToolbarItemEnabled">YES</bool>
<bool key="NSToolbarItemAutovalidates">YES</bool>
<int key="NSToolbarItemTag">0</int>
Expand Down Expand Up @@ -1656,17 +1699,18 @@
<reference ref="774449010"/>
<reference ref="131368024"/>
<reference ref="520297562"/>
<reference ref="77495503"/>
<reference ref="995733896"/>
<reference ref="77495503"/>
<reference ref="587605996"/>
<reference ref="740642631"/>
<reference ref="677544345"/>
<reference ref="1033703265"/>
<reference ref="840575537"/>
<reference ref="412717087"/>
<reference ref="1033703265"/>
<reference ref="425122427"/>
<reference ref="587605996"/>
<reference ref="1046415447"/>
<reference ref="974113713"/>
<reference ref="773751720"/>
<reference ref="1046415447"/>
<reference ref="348901587"/>
</object>
<object class="NSMutableArray" key="NSToolbarIBDefaultItems">
Expand All @@ -1677,8 +1721,8 @@
<reference ref="520297562"/>
<reference ref="1046415447"/>
<reference ref="740642631"/>
<reference ref="412717087"/>
<reference ref="1033703265"/>
<reference ref="677544345"/>
<reference ref="840575537"/>
<reference ref="425122427"/>
<reference ref="773751720"/>
<reference ref="348901587"/>
Expand Down Expand Up @@ -3136,6 +3180,14 @@
</object>
<int key="connectionID">556</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">mergeItem</string>
<reference key="source" ref="892732705"/>
<reference key="destination" ref="677544345"/>
</object>
<int key="connectionID">563</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -3930,6 +3982,7 @@
<reference ref="840575537"/>
<reference ref="740642631"/>
<reference ref="974113713"/>
<reference ref="677544345"/>
</object>
<reference key="parent" ref="0"/>
<string key="objectName">History Toolbar</string>
Expand Down Expand Up @@ -4057,6 +4110,29 @@
<reference key="object" ref="974113713"/>
<reference key="parent" ref="931038723"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">559</int>
<reference key="object" ref="677544345"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="94822105"/>
</object>
<reference key="parent" ref="931038723"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">560</int>
<reference key="object" ref="94822105"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="864578243"/>
</object>
<reference key="parent" ref="677544345"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">561</int>
<reference key="object" ref="864578243"/>
<reference key="parent" ref="94822105"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">526</int>
<reference key="object" ref="491543627"/>
Expand Down Expand Up @@ -4469,6 +4545,13 @@
<string>526.IBPluginDependency</string>
<string>527.CustomClassName</string>
<string>527.IBPluginDependency</string>
<string>559.CustomClassName</string>
<string>559.IBPluginDependency</string>
<string>560.CustomClassName</string>
<string>560.IBAttributePlaceholdersKey</string>
<string>560.IBPluginDependency</string>
<string>561.CustomClassName</string>
<string>561.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
Expand Down Expand Up @@ -4547,7 +4630,7 @@
<string>PBGitRevisionCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{1003, 658}, {616, 285}}</string>
<string>{{74, 892}, {616, 285}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{132, 614}, {616, 0}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -4789,6 +4872,23 @@ IGhpc3Rvcnkgdmlldy4</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>KBDelayedPopUpButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>KBPopUpToolbarItem</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>KBDelayedPopUpButton</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">ToolTip</string>
<object class="IBToolTipAttribute" key="NS.object.0">
<string key="name">ToolTip</string>
<reference key="object" ref="94822105"/>
<string type="base64-UTF8" key="toolTip">Z2l0IG1lcmdlIDxicmFuY2ggcmVtb3RlIG9yIHRhZz4KClRoaXMgd2lsbCBtZXJnZSB0aGUgY3VyZW50
bHkgY2hlY2tlZCBvdXQgaGVhZCB3aXRoIHRoZSBzZWxlY3RlZCBicmFuY2gsIHJlbW90ZSBvciB0YWcu
CgpDaG9vc2UgYSByZW1vdGUgb3IgbG9jYWwgYnJhbmNoIGZyb20gdGhlIHBvcHVwIG1lbnUgb3Igcmln
aHQgY2xpY2sgb24gYSBicmFuY2gsIHJlbW90ZSBvciB0YWcgaW4gdGhlIGhpc3Rvcnkgdmlldy4</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>KBDelayedPopUpButtonCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand All @@ -4811,7 +4911,7 @@ IGhpc3Rvcnkgdmlldy4</string>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">558</int>
<int key="maxID">569</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -5004,6 +5104,9 @@ IGhpc3Rvcnkgdmlldy4</string>
<string>createBranchHere:</string>
<string>fetchCurrentRemote:</string>
<string>fetchFromRemote:</string>
<string>mergeWithBranch:</string>
<string>mergeWithCommit:</string>
<string>mergeWithRef:</string>
<string>pullCurrentRemote:</string>
<string>pullFromRemote:</string>
<string>pullRemoteForRef:</string>
Expand Down Expand Up @@ -5035,6 +5138,9 @@ IGhpc3Rvcnkgdmlldy4</string>
<string>PBRefMenuItem</string>
<string>id</string>
<string>NSMenuItem</string>
<string>NSMenuItem</string>
<string>PBRefMenuItem</string>
<string>PBRefMenuItem</string>
<string>id</string>
<string>NSMenuItem</string>
<string>PBRefMenuItem</string>
Expand Down Expand Up @@ -5069,6 +5175,7 @@ IGhpc3Rvcnkgdmlldy4</string>
<string>errorMessage</string>
<string>fetchItem</string>
<string>historyController</string>
<string>mergeItem</string>
<string>newBranchName</string>
<string>newBranchSheet</string>
<string>newTagCommit</string>
Expand All @@ -5095,6 +5202,7 @@ IGhpc3Rvcnkgdmlldy4</string>
<string>NSTextField</string>
<string>KBPopUpToolbarItem</string>
<string>PBGitHistoryController</string>
<string>KBPopUpToolbarItem</string>
<string>NSTextField</string>
<string>NSWindow</string>
<string>NSTextField</string>
Expand Down
2 changes: 2 additions & 0 deletions PBGitRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- (BOOL) fetchRemote:(PBGitRevSpecifier *)rev presentError:(BOOL)shouldPresentError;
- (BOOL) pullRemote:(PBGitRevSpecifier *)rev presentError:(BOOL)shouldPresentError;
- (BOOL) pushRemote:(PBGitRevSpecifier *)rev presentError:(BOOL)shouldPresentError;
- (BOOL) mergeWithBranch:(PBGitRevSpecifier *)branch presentError:(BOOL)shouldPresentError;
- (BOOL) mergeWithCommit:(PBGitCommit *)commit presentError:(BOOL)shouldPresentError;
- (BOOL) checkoutRefName:(NSString *)refName presentError:(BOOL)shouldPresentError;
- (BOOL) cherryPickCommit:(PBGitCommit *)commit presentError:(BOOL)shouldPresentError;
- (BOOL) rebaseBranch:(PBGitRevSpecifier *)branch onUpstream:(PBGitRevSpecifier *)upstream presentError:(BOOL)shouldPresentError;
Expand Down
53 changes: 53 additions & 0 deletions PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,59 @@ - (BOOL) pushRemote:(PBGitRevSpecifier *)rev presentError:(BOOL)shouldPresentErr
return YES;
}

- (BOOL) mergeWithBranch:(PBGitRevSpecifier *)branch presentError:(BOOL)shouldPresentError
{
NSString *branchName = [branch refName];

int ret = 1;
NSArray *args = [NSArray arrayWithObjects:@"merge", branchName, nil];
NSString *command = [args componentsJoinedByString:@" "];
NSLog(@"%s %@", _cmd, command);
NSString *rval = [self outputInWorkdirForArguments:args retValue:&ret];
if (ret) {
if (shouldPresentError) {
NSString *description = [NSString stringWithFormat:@"Merge failed for %@.", branchName];
NSString *info = [NSString stringWithFormat:@"There was an error merging %@ with %@.\n\ncommand: git %@\n%d\n%@", [[self headRef] refName], branchName, command, ret, rval];
NSError *error = [NSError errorWithDomain:PBGitXErrorDomain code:PBGitMergeErrorCode
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
description, NSLocalizedDescriptionKey,
info, NSLocalizedRecoverySuggestionErrorKey,
nil]];
[self.windowController showErrorSheet:error];
}
return NO;
}
[self reloadRefs];
return YES;
}

- (BOOL) mergeWithCommit:(PBGitCommit *)commit presentError:(BOOL)shouldPresentError
{
NSString *commitSHA = [commit realSha];

int ret = 1;
NSArray *args = [NSArray arrayWithObjects:@"merge", commitSHA, nil];
NSString *command = [args componentsJoinedByString:@" "];
NSLog(@"%s %@", _cmd, command);
NSString *rval = [self outputInWorkdirForArguments:args retValue:&ret];
if (ret) {
if (shouldPresentError) {
NSString *shortSHA = [commitSHA substringToIndex:8];
NSString *description = [NSString stringWithFormat:@"Merge failed for %@.", shortSHA];
NSString *info = [NSString stringWithFormat:@"There was an error merging %@ with %@.\n\ncommand: git %@\n%d\n%@", [[self headRef] refName], shortSHA, command, ret, rval];
NSError *error = [NSError errorWithDomain:PBGitXErrorDomain code:PBGitMergeErrorCode
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
description, NSLocalizedDescriptionKey,
info, NSLocalizedRecoverySuggestionErrorKey,
nil]];
[self.windowController showErrorSheet:error];
}
return NO;
}
[self reloadRefs];
return YES;
}

- (BOOL) checkoutRefName:(NSString *)refName presentError:(BOOL)shouldPresentError
{
int ret = 1;
Expand Down
2 changes: 1 addition & 1 deletion PBGitXErrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ OBJC_EXTERN const NSInteger PBGitRebaseErrorCode;
OBJC_EXTERN const NSInteger PBGitCreateBranchErrorCode;
OBJC_EXTERN const NSInteger PBGitAddTagErrorCode;
OBJC_EXTERN const NSInteger PBGitAddRemoteErrorCode;

OBJC_EXTERN const NSInteger PBGitMergeErrorCode;
2 changes: 1 addition & 1 deletion PBGitXErrors.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
const NSInteger PBGitCreateBranchErrorCode = 11;
const NSInteger PBGitAddTagErrorCode = 12;
const NSInteger PBGitAddRemoteErrorCode = 13;

const NSInteger PBGitMergeErrorCode = 14;
Loading

0 comments on commit 86ebf68

Please sign in to comment.