Skip to content

Commit 6aa8df8

Browse files
committed
Add DiffMerge tool support
Changes come from original PR #481 made by @akantsevoi. Fixes #59.
1 parent d3d7a12 commit 6aa8df8

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

GitUp/Application/Base.lproj/MainMenu.xib

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ You must close and reopen any opened repositories in GitUp after changing this s
356356
<menuItem title="Kaleidoscope" id="EDr-i6-aAh"/>
357357
<menuItem title="Beyond Compare" id="cip-D6-GZD"/>
358358
<menuItem title="P4Merge" id="RNS-uQ-WHF"/>
359+
<menuItem title="DiffMerge" id="yH0-Kd-hsv"/>
359360
<menuItem isSeparatorItem="YES" id="XvM-0Z-bmM"/>
360361
<menuItem title="Git Tool" id="iEl-zc-obP"/>
361362
</items>
@@ -392,6 +393,7 @@ You must close and reopen any opened repositories in GitUp after changing this s
392393
<menuItem title="Kaleidoscope" id="pqO-7b-B5J"/>
393394
<menuItem title="Beyond Compare" id="AaP-5A-YVD"/>
394395
<menuItem title="P4Merge" id="Uq1-pA-HzR"/>
396+
<menuItem title="DiffMerge" id="AXz-pD-fZY"/>
395397
<menuItem isSeparatorItem="YES" id="opM-b3-5YC"/>
396398
<menuItem title="Git Tool" id="yyO-2T-uYr"/>
397399
</items>

GitUpKit/Utilities/GIViewController+Utilities.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern NSString* const GIViewControllerTool_Kaleidoscope;
2222
extern NSString* const GIViewControllerTool_BeyondCompare;
2323
extern NSString* const GIViewControllerTool_P4Merge;
2424
extern NSString* const GIViewControllerTool_GitTool;
25+
extern NSString* const GIViewControllerTool_DiffMerge;
2526

2627
extern NSString* const GIViewController_DiffTool;
2728
extern NSString* const GIViewController_MergeTool;

GitUpKit/Utilities/GIViewController+Utilities.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
#define kKSDiffPath @"/usr/local/bin/ksdiff"
3131
#define kBComparePath @"/usr/local/bin/bcompare"
3232
#define kP4MergePath @"/Applications/p4merge.app/Contents/Resources/launchp4merge"
33+
#define kDiffMergePath @"/Applications/DiffMerge.app/Contents/Resources/diffmerge.sh"
3334

3435
NSString* const GIViewControllerTool_FileMerge = @"FileMerge";
3536
NSString* const GIViewControllerTool_Kaleidoscope = @"Kaleidoscope";
3637
NSString* const GIViewControllerTool_BeyondCompare = @"Beyond Compare";
3738
NSString* const GIViewControllerTool_P4Merge = @"P4Merge";
3839
NSString* const GIViewControllerTool_GitTool = @"Git Tool";
40+
NSString* const GIViewControllerTool_DiffMerge = @"DiffMerge";
3941

4042
NSString* const GIViewController_DiffTool = @"GIViewController_DiffTool";
4143
NSString* const GIViewController_MergeTool = @"GIViewController_MergeTool";
@@ -395,6 +397,14 @@ - (void)_runDiffGitToolForFile:(NSString*)file withOldPath:(NSString*)oldPath ne
395397
}
396398
}
397399

400+
- (void)_runDiffMergeToolWithArguments:(NSArray*)arguments {
401+
if (([[NSFileManager defaultManager] isExecutableFileAtPath:kDiffMergePath])) {
402+
[self _runTaskWithPath:kDiffMergePath arguments:arguments variables:nil waitUntilExit:NO reportErrors:NO]; // launch diff merge
403+
} else {
404+
[self presentAlertWithType:kGIAlertType_Stop title:NSLocalizedString(@"DiffMerge is not available!", nil) message:NSLocalizedString(@"P4Merge app doesn't appear to be installed.", nil)];
405+
}
406+
}
407+
398408
// http://git-scm.com/docs/git-mergetool
399409
- (void)_runMergeGitToolForFile:(NSString*)file withOldPath:(NSString*)oldPath newPath:(NSString*)newPath basePath:(NSString*)basePath {
400410
NSString* tool = [[self.repository readConfigOptionForVariable:@"merge.tool" error:NULL] value];
@@ -455,6 +465,8 @@ - (void)viewDeltasInDiffTool:(NSArray*)deltas {
455465
[self _runP4MergeWithArguments:@[ @"-nl", oldTitle, @"-nr", newTitle, oldPath, newPath ]];
456466
} else if ([identifier isEqualToString:GIViewControllerTool_GitTool]) {
457467
[self _runDiffGitToolForFile:delta.canonicalPath withOldPath:oldPath newPath:newPath];
468+
} else if ([identifier isEqualToString:GIViewControllerTool_DiffMerge]) {
469+
[self _runDiffMergeToolWithArguments:@[ [NSString stringWithFormat:@"-t1=%@", oldTitle], [NSString stringWithFormat:@"-t2=%@", newTitle], oldPath, newPath ]];
458470
} else {
459471
XLOG_DEBUG_UNREACHABLE();
460472
}
@@ -571,6 +583,15 @@ - (void)resolveConflictInMergeTool:(GCIndexConflict*)conflict {
571583
[self _runP4MergeWithArguments:arguments];
572584
} else if ([identifier isEqualToString:GIViewControllerTool_GitTool]) {
573585
[self _runMergeGitToolForFile:mergePath withOldPath:ourPath newPath:theirPath basePath:ancestorPath];
586+
} else if ([identifier isEqualToString:GIViewControllerTool_DiffMerge]) {
587+
[arguments addObject:[NSString stringWithFormat:@"-r=%@", mergePath]];
588+
[arguments addObject:[NSString stringWithFormat:@"-t1=%@", ourTitle]];
589+
[arguments addObject:[NSString stringWithFormat:@"-t2=%@", ancestorTitle]];
590+
[arguments addObject:[NSString stringWithFormat:@"-t3=%@", theirTitle]];
591+
[arguments addObject:ourPath];
592+
[arguments addObject:ancestorPath];
593+
[arguments addObject:theirPath];
594+
[self _runDiffMergeToolWithArguments:arguments];
574595
} else {
575596
XLOG_DEBUG_UNREACHABLE();
576597
}
@@ -840,6 +861,8 @@ - (void)launchDiffToolWithCommit:(GCCommit*)commit otherCommit:(GCCommit*)otherC
840861
[self _runBeyondCompareWithArguments:@[ [NSString stringWithFormat:@"-title1=%@", oldTitle], [NSString stringWithFormat:@"-title2=%@", newTitle], oldPath, newPath ]];
841862
} else if ([identifier isEqualToString:GIViewControllerTool_P4Merge] || [identifier isEqualToString:GIViewControllerTool_GitTool]) {
842863
; // Handled above
864+
} else if ([identifier isEqualToString:GIViewControllerTool_DiffMerge]) {
865+
[self _runDiffMergeToolWithArguments:@[ [NSString stringWithFormat:@"-t1=%@", oldTitle], [NSString stringWithFormat:@"-t2=%@", newTitle], oldPath, newPath ]];
843866
} else {
844867
XLOG_DEBUG_UNREACHABLE();
845868
}

0 commit comments

Comments
 (0)