Skip to content

Commit cbcba80

Browse files
committed
Rewire diff context menu item
1 parent 08c77bd commit cbcba80

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

Classes/Controllers/PBGitHistoryController.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,10 @@ - (NSArray *)menuItemsForPaths:(NSArray *)paths
648648
{
649649
if ([sender isKindOfClass:[PBRefMenuItem class]]) {
650650
id <PBGitRefish> refish = [[(PBRefMenuItem *)sender refishs] firstObject];
651-
return refish;
651+
652+
if (!types || [types indexOfObject:[refish refishType]] != NSNotFound)
653+
return refish;
654+
return nil;
652655
}
653656

654657
if ([types indexOfObject:kGitXCommitType] == NSNotFound)
@@ -810,6 +813,19 @@ - (IBAction)showDeleteRefSheet:(PBRefMenuItem *)sender
810813
}];
811814
}
812815

816+
- (IBAction)diffWithHEAD:(id)sender
817+
{
818+
id <PBGitRefish> refish = [self refishForSender:sender refishTypes:nil];
819+
if (!refish)
820+
return;
821+
822+
PBGitCommit *commit = [self.repository commitForRef:refish];
823+
824+
NSString *diff = [self.repository performDiff:commit against:nil forFiles:nil];
825+
826+
[PBDiffWindowController showDiff:diff];
827+
}
828+
813829
#pragma mark -
814830
#pragma mark Quick Look
815831

Classes/Controllers/PBRefController.m

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,6 @@ - (void)awakeFromNib
2626
[commitList registerForDraggedTypes:[NSArray arrayWithObject:@"PBGitRef"]];
2727
}
2828

29-
- (NSArray<PBGitCommit *> *) commitsForMenuItem:(PBRefMenuItem *)menuItem {
30-
NSArray<id<PBGitRefish>> * refishs = menuItem.refishs;
31-
NSMutableArray *commits = [NSMutableArray arrayWithCapacity:refishs.count];
32-
for (id<PBGitRefish> refish in refishs) {
33-
[commits addObject:[self refishToCommit:refish]];
34-
}
35-
return commits;
36-
}
37-
38-
- (PBGitCommit *) refishToCommit:(id<PBGitRefish>)refish {
39-
return [refish refishType] == kGitXCommitType
40-
? (PBGitCommit *)refish
41-
: [historyController.repository commitForRef:refish];
42-
}
43-
44-
45-
#pragma mark Diff
46-
47-
- (void) diffWithHEAD:(PBRefMenuItem *)sender
48-
{
49-
PBGitCommit *commit = [self commitsForMenuItem:sender].firstObject;
50-
NSString *diff = [historyController.repository performDiff:commit against:nil forFiles:nil];
51-
52-
[PBDiffWindowController showDiff:diff];
53-
}
54-
5529
#pragma mark Stash
5630

5731
- (IBAction) stashPop:(PBRefMenuItem *)sender

0 commit comments

Comments
 (0)