Skip to content

Use GTOID instead of PBGitSHA class #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Controllers/PBGitHistoryController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@class QLPreviewPanel;
@class PBCommitList;
@class GLFileView;
@class PBGitSHA;
@class GTOID;
@class PBHistorySearchController;

@interface PBGitHistoryController : PBViewController {
Expand Down Expand Up @@ -69,7 +69,7 @@
- (IBAction) setTreeView:(id)sender;
- (IBAction) setBranchFilter:(id)sender;

- (void)selectCommit:(PBGitSHA *)commit;
- (void)selectCommit:(GTOID *)commit;
- (IBAction) refresh:(id)sender;
- (IBAction) toggleQLPreviewPanel:(id)sender;
- (IBAction) openSelectedFile:(id)sender;
Expand Down
5 changes: 2 additions & 3 deletions Classes/Controllers/PBGitHistoryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "PBGitSHA.h"
#import "PBGitCommit.h"
#import "PBGitTree.h"
#import "PBGitRef.h"
Expand Down Expand Up @@ -488,7 +487,7 @@ - (void) scrollSelectionToTopOfViewFrom:(NSInteger)oldIndex
commitList.useAdjustScroll = NO;
}

- (NSArray *) selectedObjectsForSHA:(PBGitSHA *)commitSHA
- (NSArray *) selectedObjectsForSHA:(GTOID *)commitSHA
{
NSPredicate *selection = [NSPredicate predicateWithFormat:@"sha == %@", commitSHA];
NSArray *selectedCommits = [[commitController content] filteredArrayUsingPredicate:selection];
Expand All @@ -499,7 +498,7 @@ - (NSArray *) selectedObjectsForSHA:(PBGitSHA *)commitSHA
return selectedCommits;
}

- (void)selectCommit:(PBGitSHA *)commitSHA
- (void)selectCommit:(GTOID *)commitSHA
{
if (!forceSelectionUpdate && [[[[commitController selectedObjects] lastObject] sha] isEqual:commitSHA])
return;
Expand Down
3 changes: 1 addition & 2 deletions Classes/Controllers/PBHistorySearchController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#import "PBEasyPipe.h"
#import "PBGitBinary.h"
#import "PBGitCommit.h"
#import "PBGitSHA.h"

@interface PBHistorySearchController ()

Expand Down Expand Up @@ -448,7 +447,7 @@ - (void)parseBackgroundSearchResults:(NSNotification *)notification
for (NSString *resultSHA in resultsArray) {
NSUInteger index = 0;
for (PBGitCommit *commit in [commitController arrangedObjects]) {
if ([resultSHA isEqualToString:commit.sha.string]) {
if ([resultSHA isEqualToString:commit.sha.SHA]) {
[indexes addIndex:index];
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Controllers/PBWebHistoryController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
#import "PBRefContextDelegate.h"


@class PBGitSHA;
@class GTOID;


@interface PBWebHistoryController : PBWebController {
IBOutlet PBGitHistoryController* historyController;
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;

PBGitSHA* currentSha;
GTOID* currentSha;
NSString* diff;
}

Expand Down
6 changes: 3 additions & 3 deletions Classes/Controllers/PBWebHistoryController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "PBWebHistoryController.h"
#import "PBGitDefaults.h"
#import "PBGitSHA.h"
#import <ObjectiveGit/GTConfiguration.h>
#import "PBGitRef.h"
#import "PBGitRevSpecifier.h"

Expand Down Expand Up @@ -71,7 +71,7 @@ - (void) changeContentTo: (PBGitCommit *) content
// but this caused some funny behaviour because NSTask's and NSThread's don't really
// like each other. Instead, just do it async.

NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--pretty=raw", @"-M", @"--no-color", [currentSha string], nil];
NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--pretty=raw", @"-M", @"--no-color", [currentSha SHA], nil];
if (![PBGitDefaults showWhitespaceDifferences])
[taskArguments insertObject:@"-w" atIndex:1];

Expand Down Expand Up @@ -103,7 +103,7 @@ - (void)commitDetailsLoaded:(NSNotification *)notification

- (void)selectCommit:(NSString *)sha
{
[historyController selectCommit:[PBGitSHA shaWithString:sha]];
[historyController selectCommit: [GTOID oidWithSHA: sha]];
}

- (void) sendKey: (NSString*) key
Expand Down
3 changes: 1 addition & 2 deletions Classes/Views/GLFileView.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#import "GLFileView.h"
#import "PBGitTree.h"
#import "PBGitSHA.h"
#import "PBGitCommit.h"
#import "PBGitHistoryController.h"

Expand Down Expand Up @@ -110,7 +109,7 @@ - (void) showFile

- (void) selectCommit:(NSString*)c
{
[historyController selectCommit:[PBGitSHA shaWithString:c]];
[historyController selectCommit: [GTOID oidWithSHA: c]];
}

#pragma mark MGScopeBarDelegate methods
Expand Down
5 changes: 2 additions & 3 deletions Classes/Views/PBGitRevisionCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#import "PBGitRevisionCell.h"
#import "PBGitRef.h"
#import "PBGitSHA.h"
#import "PBGitCommit.h"
#import "PBGitRevSpecifier.h"
#import "RoundedRectangle.h"
Expand Down Expand Up @@ -107,10 +106,10 @@ - (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r of

- (BOOL) isCurrentCommit
{
PBGitSHA *thisSha = [self.objectValue sha];
GTOID *thisSha = [self.objectValue sha];

PBGitRepository* repository = [self.objectValue repository];
PBGitSHA *currentSha = [repository headSHA];
GTOID *currentSha = [repository headSHA];

return [currentSha isEqual:thisSha];
}
Expand Down
1 change: 0 additions & 1 deletion Classes/Views/PBRefMenuItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "PBRefMenuItem.h"
#import "PBGitRepository.h"
#import "PBGitRevSpecifier.h"
#import "PBGitSHA.h"

@implementation PBRefMenuItem
@synthesize refish;
Expand Down
13 changes: 13 additions & 0 deletions Classes/git/GTOID+JavaScript.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// GTOID+JavaScript.h
// GitX
//
// Created by Sven Weidauer on 18.05.14.
//
//

#import <ObjectiveGit/ObjectiveGit.h>

@interface GTOID (JavaScript)

@end
22 changes: 22 additions & 0 deletions Classes/git/GTOID+JavaScript.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// GTOID+JavaScript.m
// GitX
//
// Created by Sven Weidauer on 18.05.14.
//
//

#import "GTOID+JavaScript.h"

@implementation GTOID (JavaScript)

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
return NO;
}

+ (BOOL)isKeyExcludedFromWebScript:(const char *)name {
return NO;
}

@end
5 changes: 1 addition & 4 deletions Classes/git/PBGitCommit.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@class PBGitRepository;
@class PBGitTree;
@class PBGitRef;
@class PBGitSHA;
@class PBGraphCellInfo;

extern NSString * const kGitXCommitType;
Expand All @@ -22,7 +21,7 @@ extern NSString * const kGitXCommitType;

@property (nonatomic, weak, readonly) PBGitRepository* repository;

@property (nonatomic, strong, readonly) PBGitSHA *sha;
@property (nonatomic, strong, readonly) GTOID *sha;

@property (nonatomic, strong, readonly) NSDate *date;
@property (nonatomic, strong, readonly) NSString *subject;
Expand All @@ -43,8 +42,6 @@ extern NSString * const kGitXCommitType;
@property (readonly) NSArray* treeContents;


//+ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(PBGitSHA *)newSha;

- (id)initWithRepository:(PBGitRepository *)repo andCommit:(GTCommit *)gtCommit;

- (void) addRef:(PBGitRef *)ref;
Expand Down
16 changes: 4 additions & 12 deletions Classes/git/PBGitCommit.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "PBGitRepository.h"
#import "PBGitCommit.h"
#import "PBGitTree.h"
#import "PBGitSHA.h"
#import "PBGitRef.h"
#import "PBGitDefaults.h"

Expand All @@ -22,7 +21,7 @@ @interface PBGitCommit ()
@property (nonatomic, strong) NSArray *parents;

@property (nonatomic, strong) NSString *patch;
@property (nonatomic, strong) PBGitSHA *sha;
@property (nonatomic, strong) GTOID *sha;

@end

Expand Down Expand Up @@ -65,7 +64,7 @@ - (NSArray *)parents
NSArray *gtParents = self.gtCommit.parents;
NSMutableArray *parents = [NSMutableArray arrayWithCapacity:gtParents.count];
for (GTCommit *parent in gtParents) {
[parents addObject:[PBGitSHA shaWithString:parent.SHA]];
[parents addObject:parent.OID];
}
self.parents = parents;
}
Expand Down Expand Up @@ -114,16 +113,9 @@ - (NSString *)SVNRevision
return result;
}

- (PBGitSHA *)sha
- (GTOID *)sha
{
if (!self->_sha) {
const git_oid *oid = self.gtCommit.OID.git_oid;
if (oid) {
PBGitSHA *newSha = [PBGitSHA shaWithOID:oid];
self.sha = newSha;
}
}
return self->_sha;
return self.gtCommit.OID;
}

- (NSString *)realSha
Expand Down
18 changes: 11 additions & 7 deletions Classes/git/PBGitGrapher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
#import "PBGraphCellInfo.h"
#import "PBGitGrapher.h"
#import "PBGitCommit.h"
#import "PBGitSHA.h"
#import "PBGitLane.h"
#import "PBGitGraphLine.h"

#import <vector>
#import <git2/oid.h>
#include <algorithm>
#import <ObjectiveGit/GTOID.h>

using namespace std;
typedef std::vector<PBGitLane *> LaneCollection;

Expand Down Expand Up @@ -63,7 +67,7 @@ - (void) decorateCommit: (PBGitCommit *) commit

PBGitLane *currentLane = NULL;
BOOL didFirst = NO;
git_oid commit_oid = [[commit sha] oid];
const git_oid *commit_oid = [[commit sha] git_oid];

// First, iterate over earlier columns and pass through any that don't want this commit
if (self.previous != nil) {
Expand Down Expand Up @@ -106,8 +110,8 @@ - (void) decorateCommit: (PBGitCommit *) commit

// If we already did the first parent, don't do so again
if (!didFirst && nParents) {
git_oid parentOID = [(PBGitSHA*)[parents objectAtIndex:0] oid];
PBGitLane *newLane = new PBGitLane(&parentOID);
const git_oid *parentOID = [(GTOID*)[parents objectAtIndex:0] git_oid];
PBGitLane *newLane = new PBGitLane(parentOID);
currentLanes->push_back(newLane);
newPos = currentLanes->size();
add_line(lines, &currentLine, 0, newPos, newPos, newLane->index());
Expand All @@ -121,7 +125,7 @@ - (void) decorateCommit: (PBGitCommit *) commit

int parentIndex = 0;
for (parentIndex = 1; parentIndex < nParents; ++parentIndex) {
git_oid parentOID = [(PBGitSHA*)[parents objectAtIndex:parentIndex] oid];
const git_oid *parentOID = [(GTOID*)[parents objectAtIndex:parentIndex] git_oid];
int i = 0;
BOOL was_displayed = NO;
LaneCollection::iterator it = currentLanes->begin();
Expand All @@ -138,7 +142,7 @@ - (void) decorateCommit: (PBGitCommit *) commit

// Really add this parent
addedParent = YES;
PBGitLane *newLane = new PBGitLane(&parentOID);
PBGitLane *newLane = new PBGitLane(parentOID);
currentLanes->push_back(newLane);
add_line(lines, &currentLine, 0, currentLanes->size(), newPos, newLane->index());
}
Expand Down Expand Up @@ -166,7 +170,7 @@ - (void) decorateCommit: (PBGitCommit *) commit
// Update the current lane to point to the new parent
if (currentLane) {
if (nParents > 0)
currentLane->setSha([(PBGitSHA*)[parents objectAtIndex:0] oid]);
currentLane->setSha( [(GTOID*)[parents objectAtIndex:0] git_oid]);
else {
// The current lane's commit does not have any parents
// AKA, this is a first commit
Expand Down
4 changes: 1 addition & 3 deletions Classes/git/PBGitHistoryGrapher.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

#import "PBGitHistoryGrapher.h"
#import "PBGitGrapher.h"
#import "PBGitSHA.h"
#import "PBGitCommit.h"


@implementation PBGitHistoryGrapher


Expand Down Expand Up @@ -50,7 +48,7 @@ - (void) graphCommits:(NSArray *)revList
for (PBGitCommit *commit in revList) {
if ([currentThread isCancelled])
return;
PBGitSHA *commitSHA = [commit sha];
GTOID *commitSHA = [commit sha];
if (viewAllBranches || [searchSHAs containsObject:commitSHA]) {
[grapher decorateCommit:commit];
[commits addObject:commit];
Expand Down
4 changes: 2 additions & 2 deletions Classes/git/PBGitHistoryList.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
@class PBGitRef;
@class PBGitRevList;
@class PBGitHistoryGrapher;
@class PBGitSHA;
@class GTOID;

@interface PBGitHistoryList : NSObject {
__weak PBGitRepository *repository;

PBGitRevList *projectRevList;
PBGitRevList *currentRevList;

PBGitSHA *lastSHA;
GTOID *lastSHA;
NSSet *lastRefSHAs;
NSInteger lastBranchFilter;
PBGitRef *lastRemoteRef;
Expand Down
Loading