From ac1019d5cc53ebc32cdc88aac82a60654030d68c Mon Sep 17 00:00:00 2001 From: German Laullon Date: Fri, 20 May 2011 00:46:13 +0200 Subject: [PATCH] no libgit2 --- .gitmodules | 3 - GLFileView.m | 2 +- GitX.xcodeproj/project.pbxproj | 72 ----------------- PBGitCommit.h | 9 +-- PBGitCommit.m | 7 +- PBGitGrapher.mm | 13 ++- PBGitHistoryController.h | 4 +- PBGitHistoryController.m | 4 +- PBGitHistoryGrapher.m | 3 +- PBGitHistoryList.h | 3 +- PBGitHistoryList.m | 9 +-- PBGitLane.h | 26 ++---- PBGitLane.mm | 2 +- PBGitRepository.h | 14 ++-- PBGitRepository.m | 24 +++--- PBGitRevList.mm | 16 ++-- PBGitRevisionCell.m | 4 +- PBGitSHA.h | 28 ------- PBGitSHA.m | 139 --------------------------------- PBHistorySearchController.m | 2 +- PBWebHistoryController.h | 4 +- PBWebHistoryController.m | 13 ++- build_libgit2.sh | 66 ---------------- libgit2 | 1 - 24 files changed, 69 insertions(+), 399 deletions(-) delete mode 100644 .gitmodules delete mode 100644 PBGitSHA.h delete mode 100644 PBGitSHA.m delete mode 100755 build_libgit2.sh delete mode 160000 libgit2 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 6e08054..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "libgit2"] - path = libgit2 - url = git://github.com/RomainMuller/libgit2.git \ No newline at end of file diff --git a/GLFileView.m b/GLFileView.m index 92baab9..9b6ecab 100644 --- a/GLFileView.m +++ b/GLFileView.m @@ -155,7 +155,7 @@ - (void) selectCommit:(NSString*)c { - [historyController selectCommit:[PBGitSHA shaWithString:c]]; + [historyController selectCommit:c]; } // TODO: need to be refactoring diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 92317c4..7cb0c81 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -129,7 +129,6 @@ D8F01C4B12182F19007F729F /* GitX.sdef in Resources */ = {isa = PBXBuildFile; fileRef = D8F01C4A12182F19007F729F /* GitX.sdef */; }; D8F01D531218A164007F729F /* NSApplication+GitXScripting.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F01D521218A164007F729F /* NSApplication+GitXScripting.m */; }; D8F4AB7912298CE200D6D53C /* rewindImage.pdf in Resources */ = {isa = PBXBuildFile; fileRef = D8F4AB7812298CE200D6D53C /* rewindImage.pdf */; }; - D8FBCF19115FA20C0098676A /* PBGitSHA.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FBCF18115FA20C0098676A /* PBGitSHA.m */; }; D8FDD9F711432A12005647F6 /* PBCloneRepositoryPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = D8FDD9F511432A12005647F6 /* PBCloneRepositoryPanel.xib */; }; D8FDDA6A114335E8005647F6 /* PBGitSVBranchItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA5D114335E8005647F6 /* PBGitSVBranchItem.m */; }; D8FDDA6B114335E8005647F6 /* PBGitSVFolderItem.m in Sources */ = {isa = PBXBuildFile; fileRef = D8FDDA5F114335E8005647F6 /* PBGitSVFolderItem.m */; }; @@ -178,7 +177,6 @@ F5AD56790E79B78100EDAAFE /* PBCommitList.m in Sources */ = {isa = PBXBuildFile; fileRef = F5AD56780E79B78100EDAAFE /* PBCommitList.m */; }; F5B721C40E05CF7E00AF29DC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5B721C20E05CF7E00AF29DC /* MainMenu.xib */; }; F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C007740E731B48007B84B2 /* PBGitRef.m */; }; - F5C580E50EDA250900995434 /* libgit2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F5C580E40EDA250900995434 /* libgit2.a */; }; F5C6F68D0E65FF9300478D97 /* PBGitLane.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5C6F68C0E65FF9300478D97 /* PBGitLane.mm */; }; F5DFFA6C0E075D8800617813 /* PBEasyFS.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DFFA6B0E075D8800617813 /* PBEasyFS.m */; }; F5E424110EA3E4D60046E362 /* PBDiffWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */; }; @@ -214,13 +212,6 @@ remoteGlobalIDString = 913D5E480E55644600CECEA2; remoteInfo = "cli tool"; }; - D8022C1911DFE8ED003C21F6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; - proxyType = 1; - remoteGlobalIDString = D8022B1411DFCE7F003C21F6; - remoteInfo = libgit2; - }; F5643A010F792B4900A579C2 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; @@ -417,8 +408,6 @@ D8F01D521218A164007F729F /* NSApplication+GitXScripting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+GitXScripting.m"; sourceTree = ""; }; D8F01D841218A406007F729F /* GitX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX.h; sourceTree = ""; }; D8F4AB7812298CE200D6D53C /* rewindImage.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = rewindImage.pdf; path = Images/rewindImage.pdf; sourceTree = ""; }; - D8FBCF17115FA20C0098676A /* PBGitSHA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSHA.h; sourceTree = ""; }; - D8FBCF18115FA20C0098676A /* PBGitSHA.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSHA.m; sourceTree = ""; }; D8FDD9F611432A12005647F6 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/PBCloneRepositoryPanel.xib; sourceTree = ""; }; D8FDDA5C114335E8005647F6 /* PBGitSVBranchItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitSVBranchItem.h; sourceTree = ""; }; D8FDDA5D114335E8005647F6 /* PBGitSVBranchItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitSVBranchItem.m; sourceTree = ""; }; @@ -560,7 +549,6 @@ 911112370E5A097800BF76B4 /* Security.framework in Frameworks */, F580E6AE0E733276009E2D3F /* Sparkle.framework in Frameworks */, F5E4DBFB0EAB58D90013FAFC /* SystemConfiguration.framework in Frameworks */, - F5C580E50EDA250900995434 /* libgit2.a in Frameworks */, D8E3B2B810DC9FB2001096A3 /* ScriptingBridge.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1084,8 +1072,6 @@ F56524EF0E02D45200F03B52 /* PBGitCommit.m */, F5C007730E731B48007B84B2 /* PBGitRef.h */, F5C007740E731B48007B84B2 /* PBGitRef.m */, - D8FBCF17115FA20C0098676A /* PBGitSHA.h */, - D8FBCF18115FA20C0098676A /* PBGitSHA.m */, D8295D281130A1DC00C838E8 /* PBGitHistoryList.h */, D8295D291130A1DC00C838E8 /* PBGitHistoryList.m */, F5FF4E160E0829C20006317A /* PBGitRevList.h */, @@ -1146,22 +1132,6 @@ }; /* End PBXGroup section */ -/* Begin PBXLegacyTarget section */ - D8022B1411DFCE7F003C21F6 /* libgit2 */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "\"${PROJECT_DIR}/build_libgit2.sh\""; - buildConfigurationList = D8022B1C11DFCE98003C21F6 /* Build configuration list for PBXLegacyTarget "libgit2" */; - buildPhases = ( - ); - buildToolPath = /bin/sh; - dependencies = ( - ); - name = libgit2; - passBuildSettingsInEnvironment = 1; - productName = libgit2; - }; -/* End PBXLegacyTarget section */ - /* Begin PBXNativeTarget section */ 551BF110112F371800265053 /* gitx_askpasswd */ = { isa = PBXNativeTarget; @@ -1196,7 +1166,6 @@ 551BF175112F3F3500265053 /* PBXTargetDependency */, 913D5E5A0E5564F400CECEA2 /* PBXTargetDependency */, F5643A020F792B4900A579C2 /* PBXTargetDependency */, - D8022C1A11DFE8ED003C21F6 /* PBXTargetDependency */, ); name = GitX; productInstallPath = "$(HOME)/Applications"; @@ -1242,7 +1211,6 @@ 8D1107260486CEB800E47090 /* GitX */, 913D5E480E55644600CECEA2 /* cli tool */, F56439F70F792B2100A579C2 /* Generate PList Prefix */, - D8022B1411DFCE7F003C21F6 /* libgit2 */, 551BF110112F371800265053 /* gitx_askpasswd */, ); }; @@ -1452,7 +1420,6 @@ D8295D2A1130A1DC00C838E8 /* PBGitHistoryList.m in Sources */, D8295DE01130E43900C838E8 /* PBGitHistoryGrapher.m in Sources */, D8E105471157C18200FC28A4 /* PBQLTextView.m in Sources */, - D8FBCF19115FA20C0098676A /* PBGitSHA.m in Sources */, D8022FED11E124C8003C21F6 /* PBGitXMessageSheet.m in Sources */, D8EB616A122F643E00FCCAF4 /* GitXRelativeDateFormatter.m in Sources */, D8F01D531218A164007F729F /* NSApplication+GitXScripting.m in Sources */, @@ -1506,11 +1473,6 @@ target = 913D5E480E55644600CECEA2 /* cli tool */; targetProxy = 913D5E590E5564F400CECEA2 /* PBXContainerItemProxy */; }; - D8022C1A11DFE8ED003C21F6 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D8022B1411DFCE7F003C21F6 /* libgit2 */; - targetProxy = D8022C1911DFE8ED003C21F6 /* PBXContainerItemProxy */; - }; F5643A020F792B4900A579C2 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = F56439F70F792B2100A579C2 /* Generate PList Prefix */; @@ -1820,31 +1782,6 @@ }; name = Release; }; - D8022B1511DFCE7F003C21F6 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = libgit2; - SDKROOT = ""; - }; - name = Debug; - }; - D8022B1611DFCE7F003C21F6 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - PRODUCT_NAME = libgit2; - SDKROOT = ""; - ZERO_LINK = NO; - }; - name = Release; - }; F56439F80F792B2100A579C2 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1911,15 +1848,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - D8022B1C11DFCE98003C21F6 /* Build configuration list for PBXLegacyTarget "libgit2" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D8022B1511DFCE7F003C21F6 /* Debug */, - D8022B1611DFCE7F003C21F6 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; F56439FD0F792B3600A579C2 /* Build configuration list for PBXAggregateTarget "Generate PList Prefix" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/PBGitCommit.h b/PBGitCommit.h index e77ee32..5ad99e6 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -10,14 +10,13 @@ #import "PBGitRepository.h" #import "PBGitTree.h" #import "PBGitRefish.h" -#import "PBGitSHA.h" extern NSString * const kGitXCommitType; @interface PBGitCommit : NSObject { - PBGitSHA *sha; + NSString *sha; NSString* subject; NSString* author; @@ -33,8 +32,8 @@ extern NSString * const kGitXCommitType; PBGitRepository* repository; } -+ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(PBGitSHA *)newSha; -- (id)initWithRepository:(PBGitRepository *)repo andSha:(PBGitSHA *)newSha; ++ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(NSString *)newSha; +- (id)initWithRepository:(PBGitRepository *)repo andSha:(NSString *)newSha; - (void) addRef:(PBGitRef *)ref; - (void) removeRef:(id)ref; @@ -49,7 +48,7 @@ extern NSString * const kGitXCommitType; - (NSString *) shortName; - (NSString *) refishType; -@property (readonly) PBGitSHA *sha; +@property (readonly) NSString *sha; @property (copy) NSString* subject; @property (copy) NSString* author; @property (copy) NSString *committer; diff --git a/PBGitCommit.m b/PBGitCommit.m index 067d6f4..be4afc8 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -7,7 +7,6 @@ // #import "PBGitCommit.h" -#import "PBGitSHA.h" #import "PBGitDefaults.h" @@ -38,12 +37,12 @@ NSString * const kGitXCommitType = @"commit"; return self.tree.children; } -+ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(PBGitSHA *)newSha ++ (PBGitCommit *)commitWithRepository:(PBGitRepository*)repo andSha:(NSString *)newSha { return [[self alloc] initWithRepository:repo andSha:newSha]; } -- (id)initWithRepository:(PBGitRepository*) repo andSha:(PBGitSHA *)newSha +- (id)initWithRepository:(PBGitRepository*) repo andSha:(NSString *)newSha { details = nil; repository = repo; @@ -53,7 +52,7 @@ NSString * const kGitXCommitType = @"commit"; - (NSString *)realSha { - return sha.string; + return sha; } - (BOOL) isOnSameBranchAs:(PBGitCommit *)otherCommit diff --git a/PBGitGrapher.mm b/PBGitGrapher.mm index 47d9cfd..98827d2 100644 --- a/PBGitGrapher.mm +++ b/PBGitGrapher.mm @@ -11,7 +11,6 @@ #import "PBGitLane.h" #import "PBGitGraphLine.h" #import -#import using namespace std; @@ -48,7 +47,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in PBGitLane *currentLane = NULL; BOOL didFirst = NO; - git_oid commit_oid = [[commit sha] oid]; + NSString *commit_oid = [commit sha]; // First, iterate over earlier columns and pass through any that don't want this commit if (previous != nil) { @@ -88,8 +87,8 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in // If we already did the first parent, don't do so again if (!didFirst && currentLanes->size() < MAX_LANES && nParents) { - git_oid parentOID = [[parents objectAtIndex:0] oid]; - PBGitLane *newLane = new PBGitLane(&parentOID); + NSString *parentOID = [parents objectAtIndex:0]; + PBGitLane *newLane = new PBGitLane(parentOID); currentLanes->push_back(newLane); newPos = currentLanes->size(); add_line(lines, ¤tLine, 0, newPos, newPos, newLane->index()); @@ -103,7 +102,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in int parentIndex = 0; for (parentIndex = 1; parentIndex < nParents; ++parentIndex) { - git_oid parentOID = [[parents objectAtIndex:parentIndex] oid]; + NSString *parentOID = [parents objectAtIndex:parentIndex]; int i = 0; BOOL was_displayed = NO; std::list::iterator it = currentLanes->begin(); @@ -123,7 +122,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in // Really add this parent addedParent = YES; - PBGitLane *newLane = new PBGitLane(&parentOID); + PBGitLane *newLane = new PBGitLane(parentOID); currentLanes->push_back(newLane); add_line(lines, ¤tLine, 0, currentLanes->size(), newPos, newLane->index()); } @@ -150,7 +149,7 @@ void add_line(struct PBGitGraphLine *lines, int *nLines, int upper, int from, in // Update the current lane to point to the new parent if (currentLane && nParents > 0) - currentLane->setSha([[parents objectAtIndex:0] oid]); + currentLane->setSha([parents objectAtIndex:0]); else currentLanes->remove(currentLane); diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index a09bc64..840d8c4 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -18,7 +18,7 @@ @class QLPreviewPanel; @class PBCommitList; @class GLFileView; -@class PBGitSHA; +@class NSString; @class PBHistorySearchController; @@ -71,7 +71,7 @@ - (IBAction) setTreeView:(id)sender; - (IBAction) setBranchFilter:(id)sender; -- (void)selectCommit:(PBGitSHA *)commit; +- (void)selectCommit:(NSString *)commit; - (IBAction) refresh:(id)sender; - (IBAction) toggleQLPreviewPanel:(id)sender; - (IBAction) openSelectedFile:(id)sender; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index d69eb61..4d1a787 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -447,7 +447,7 @@ commitList.useAdjustScroll = NO; } -- (NSArray *) selectedObjectsForSHA:(PBGitSHA *)commitSHA +- (NSArray *) selectedObjectsForSHA:(NSString *)commitSHA { NSPredicate *selection = [NSPredicate predicateWithFormat:@"sha == %@", commitSHA]; NSArray *selectedCommits = [[commitController content] filteredArrayUsingPredicate:selection]; @@ -458,7 +458,7 @@ return selectedCommits; } -- (void)selectCommit:(PBGitSHA *)commitSHA +- (void)selectCommit:(NSString *)commitSHA { if (!forceSelectionUpdate && [[[[commitController selectedObjects] lastObject] sha] isEqual:commitSHA]) return; diff --git a/PBGitHistoryGrapher.m b/PBGitHistoryGrapher.m index 062c7ae..2d45ad4 100644 --- a/PBGitHistoryGrapher.m +++ b/PBGitHistoryGrapher.m @@ -8,7 +8,6 @@ #import "PBGitHistoryGrapher.h" #import "PBGitGrapher.h" -#import "PBGitSHA.h" @implementation PBGitHistoryGrapher @@ -47,7 +46,7 @@ for (PBGitCommit *commit in revList) { if ([currentThread isCancelled]) return; - PBGitSHA *commitSHA = [commit sha]; + NSString *commitSHA = [commit sha]; if (viewAllBranches || [searchSHAs containsObject:commitSHA]) { [grapher decorateCommit:commit]; [commits addObject:commit]; diff --git a/PBGitHistoryList.h b/PBGitHistoryList.h index 75e1c6c..c0a444b 100644 --- a/PBGitHistoryList.h +++ b/PBGitHistoryList.h @@ -14,7 +14,6 @@ @class PBGitRef; @class PBGitRevList; @class PBGitHistoryGrapher; -@class PBGitSHA; @interface PBGitHistoryList : NSObject { PBGitRepository *repository; @@ -22,7 +21,7 @@ PBGitRevList *projectRevList; PBGitRevList *currentRevList; - PBGitSHA *lastSHA; + NSString *lastSHA; NSSet *lastRefSHAs; NSInteger lastBranchFilter; PBGitRef *lastRemoteRef; diff --git a/PBGitHistoryList.m b/PBGitHistoryList.m index 0ab1324..34b1485 100644 --- a/PBGitHistoryList.m +++ b/PBGitHistoryList.m @@ -11,7 +11,6 @@ #import "PBGitRevList.h" #import "PBGitGrapher.h" #import "PBGitHistoryGrapher.h" -#import "PBGitSHA.h" @@ -168,7 +167,7 @@ NSMutableSet *baseCommitSHAs = [NSMutableSet set]; NSDictionary *refs = repository.refs; - for (PBGitSHA *sha in refs) + for (NSString *sha in refs) for (PBGitRef *ref in [refs objectForKey:sha]) if ([ref isBranch] || [ref isTag]) [baseCommitSHAs addObject:sha]; @@ -187,7 +186,7 @@ PBGitRef *remoteRef = [[repository.currentBranch ref] remoteRef]; - for (PBGitSHA *sha in refs) + for (NSString *sha in refs) for (PBGitRef *ref in [refs objectForKey:sha]) if ([remoteRef isEqualToRef:[ref remoteRef]]) [baseCommitSHAs addObject:sha]; @@ -203,7 +202,7 @@ return [NSMutableSet setWithObject:lastSHA]; else if ([repository.currentBranch isSimpleRef]) { PBGitRef *currentRef = [repository.currentBranch ref]; - PBGitSHA *sha = [repository shaForRef:currentRef]; + NSString *sha = [repository shaForRef:currentRef]; if (sha) return [NSMutableSet setWithObject:sha]; } @@ -273,7 +272,7 @@ return NO; } - PBGitSHA *revSHA = [repository shaForRef:[rev ref]]; + NSString *revSHA = [repository shaForRef:[rev ref]]; if ([revSHA isEqual:lastSHA] && (lastBranchFilter == repository.currentBranchFilter)) return NO; diff --git a/PBGitLane.h b/PBGitLane.h index 136e5b3..2591621 100644 --- a/PBGitLane.h +++ b/PBGitLane.h @@ -6,46 +6,32 @@ // Copyright 2008 __MyCompanyName__. All rights reserved. // #import -#include class PBGitLane { static int s_colorIndex; - git_oid d_sha; + NSString *d_sha; int d_index; public: - PBGitLane(git_oid *sha) - { - d_index = s_colorIndex++; - d_sha = *sha; - } - PBGitLane(NSString *sha) { - git_oid_mkstr(&d_sha, [sha UTF8String]); d_index = s_colorIndex++; + d_sha = sha; } - + PBGitLane() { d_index = s_colorIndex++; } - bool isCommit(git_oid sha) const + bool isCommit(NSString *sha) const { - return !git_oid_cmp(&d_sha, &sha); - } - - void setSha(git_oid sha); - - git_oid const *sha() const - { - return &d_sha; + return [d_sha isEqual:sha]; } + void setSha(NSString *sha); int index() const; - static void resetColors(); }; \ No newline at end of file diff --git a/PBGitLane.mm b/PBGitLane.mm index 2ae767f..6b5f9df 100644 --- a/PBGitLane.mm +++ b/PBGitLane.mm @@ -29,7 +29,7 @@ int PBGitLane::index() const return d_index; } -void PBGitLane::setSha(git_oid sha) +void PBGitLane::setSha(NSString *sha) { d_sha = sha; } diff --git a/PBGitRepository.h b/PBGitRepository.h index 7e4cd6f..eb2f57c 100644 --- a/PBGitRepository.h +++ b/PBGitRepository.h @@ -42,7 +42,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { @class PBGitWindowController; @class PBGitCommit; -@class PBGitSHA; +@class NSString; @interface PBGitRepository : NSDocument { PBGitHistoryList* revisionList; @@ -55,7 +55,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { NSMutableDictionary *refs; PBGitRevSpecifier *_headRef; // Caching - PBGitSHA* _headSha; + NSString* _headSha; PBStashController *stashController; PBSubmoduleController *submoduleController; @@ -112,13 +112,13 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (void) addRef:(PBGitRef *)ref fromParameters:(NSArray *)params; - (void) lazyReload; - (PBGitRevSpecifier*)headRef; -- (PBGitSHA *)headSHA; +- (NSString *)headSHA; - (PBGitCommit *)headCommit; -- (PBGitSHA *)shaForRef:(PBGitRef *)ref; +- (NSString *)shaForRef:(PBGitRef *)ref; - (PBGitCommit *)commitForRef:(PBGitRef *)ref; -- (PBGitCommit *)commitForSHA:(PBGitSHA *)sha; -- (BOOL)isOnSameBranch:(PBGitSHA *)baseSHA asSHA:(PBGitSHA *)testSHA; -- (BOOL)isSHAOnHeadBranch:(PBGitSHA *)testSHA; +- (PBGitCommit *)commitForSHA:(NSString *)sha; +- (BOOL)isOnSameBranch:(NSString *)baseSHA asSHA:(NSString *)testSHA; +- (BOOL)isSHAOnHeadBranch:(NSString *)testSHA; - (BOOL)isRefOnHeadBranch:(PBGitRef *)testRef; - (BOOL)checkRefFormat:(NSString *)refName; - (BOOL)refExists:(PBGitRef *)ref; diff --git a/PBGitRepository.m b/PBGitRepository.m index 69d8405..aa635bf 100644 --- a/PBGitRepository.m +++ b/PBGitRepository.m @@ -274,11 +274,11 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; { NSString* type = [components objectAtIndex:1]; - PBGitSHA *sha; + NSString *sha; if ([type isEqualToString:@"tag"] && [components count] == 4) - sha = [PBGitSHA shaWithString:[components objectAtIndex:3]]; + sha = [components objectAtIndex:3]; else - sha = [PBGitSHA shaWithString:[components objectAtIndex:2]]; + sha = [components objectAtIndex:2]; if(!sha) { NSLog(@"sha was nil...? ref=%@, components=%@",ref,components); @@ -374,7 +374,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return _headRef; } -- (PBGitSHA *)headSHA +- (NSString *)headSHA { if (! _headSha) [self headRef]; @@ -387,12 +387,12 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return [self commitForSHA:[self headSHA]]; } -- (PBGitSHA *)shaForRef:(PBGitRef *)ref +- (NSString *)shaForRef:(PBGitRef *)ref { if (!ref) return nil; - for (PBGitSHA *sha in refs) + for (NSString *sha in refs) for (PBGitRef *existingRef in [refs objectForKey:sha]) if ([existingRef isEqualToRef:ref]) return sha; @@ -403,7 +403,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; if (retValue || [shaForRef isEqualToString:@""]) return nil; - return [PBGitSHA shaWithString:shaForRef]; + return shaForRef; } - (PBGitCommit *)commitForRef:(PBGitRef *)ref @@ -414,7 +414,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return [self commitForSHA:[self shaForRef:ref]]; } -- (PBGitCommit *)commitForSHA:(PBGitSHA *)sha +- (PBGitCommit *)commitForSHA:(NSString *)sha { if (!sha) return nil; @@ -431,7 +431,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return nil; } -- (BOOL)isOnSameBranch:(PBGitSHA *)branchSHA asSHA:(PBGitSHA *)testSHA +- (BOOL)isOnSameBranch:(NSString *)branchSHA asSHA:(NSString *)testSHA { if (!branchSHA || !testSHA) return NO; @@ -444,7 +444,7 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; NSMutableSet *searchSHAs = [NSMutableSet setWithObject:branchSHA]; for (PBGitCommit *commit in revList) { - PBGitSHA *commitSHA = [commit sha]; + NSString *commitSHA = [commit sha]; if ([searchSHAs containsObject:commitSHA]) { if ([testSHA isEqual:commitSHA]) return YES; @@ -458,12 +458,12 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain"; return NO; } -- (BOOL)isSHAOnHeadBranch:(PBGitSHA *)testSHA +- (BOOL)isSHAOnHeadBranch:(NSString *)testSHA { if (!testSHA) return NO; - PBGitSHA *headSHA = [self headSHA]; + NSString *headSHA = [self headSHA]; if ([testSHA isEqual:headSHA]) return YES; diff --git a/PBGitRevList.mm b/PBGitRevList.mm index b787e59..4295b3c 100644 --- a/PBGitRevList.mm +++ b/PBGitRevList.mm @@ -17,8 +17,6 @@ #include #include -#include - using namespace std; @@ -159,11 +157,11 @@ using namespace std; } } - git_oid oid; - if(git_oid_mkstr(&oid, sha.c_str())!=GIT_SUCCESS) + NSString *oid=[NSString stringWithCString:sha.c_str() encoding:encoding]; + if([oid length]!=40) break; - PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:[PBGitSHA shaWithOID:oid]]; + PBGitCommit *newCommit = [PBGitCommit commitWithRepository:repository andSha:oid]; if (showSign) [newCommit setSign: sign]; @@ -176,6 +174,7 @@ using namespace std; string parentString; getline(stream, parentString, '\1'); + if (parentString.size() != 0) { if (((parentString.size() + 1) % 41) != 0) { @@ -185,9 +184,10 @@ using namespace std; int nParents = (parentString.size() + 1) / 41; NSMutableArray *parents = [NSMutableArray arrayWithCapacity:nParents]; int parentIndex; - for (parentIndex = 0; parentIndex < nParents; ++parentIndex) - [parents addObject:[PBGitSHA shaWithCString:parentString.substr(parentIndex * 41, 40).c_str()]]; - + for (parentIndex = 0; parentIndex < nParents; ++parentIndex) { + NSString *pOid=[NSString stringWithCString:parentString.substr(parentIndex * 41, 40).c_str() encoding:encoding]; + [parents addObject:pOid]; + } [newCommit setParents:parents]; } diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m index 65889a6..df8cca1 100644 --- a/PBGitRevisionCell.m +++ b/PBGitRevisionCell.m @@ -60,10 +60,10 @@ - (BOOL) isCurrentCommit { - PBGitSHA *thisSha = [self.objectValue sha]; + NSString *thisSha = [self.objectValue sha]; PBGitRepository* repository = [self.objectValue repository]; - PBGitSHA *currentSha = [repository headSHA]; + NSString *currentSha = [repository headSHA]; return [currentSha isEqual:thisSha]; } diff --git a/PBGitSHA.h b/PBGitSHA.h deleted file mode 100644 index 15eeeb3..0000000 --- a/PBGitSHA.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// PBGitSHA.h -// GitX -// -// Created by BrotherBard on 3/28/10. -// Copyright 2010 BrotherBard. All rights reserved. -// - -#import -#include - - -@interface PBGitSHA : NSObject { - git_oid oid; - NSString *string; -} - - -+ (PBGitSHA *)shaWithOID:(git_oid)oid; -+ (PBGitSHA *)shaWithString:(NSString *)shaString; -+ (PBGitSHA *)shaWithCString:(const char *)shaCString; - -- (BOOL)isEqualToOID:(git_oid)other_oid; - -@property (readonly) git_oid oid; -@property (readonly) NSString *string; - -@end diff --git a/PBGitSHA.m b/PBGitSHA.m deleted file mode 100644 index a310040..0000000 --- a/PBGitSHA.m +++ /dev/null @@ -1,139 +0,0 @@ -// -// PBGitSHA.m -// GitX -// -// Created by BrotherBard on 3/28/10. -// Copyright 2010 BrotherBard. All rights reserved. -// - -#import "PBGitSHA.h" -#import - -@interface PBGitSHA () - -- (id)initWithOID:(git_oid)g_oid; - -@end - - -@implementation PBGitSHA - - -@synthesize oid; -@synthesize string; - - -+ (PBGitSHA *)shaWithOID:(git_oid)oid -{ - return [[PBGitSHA alloc] initWithOID:oid]; -} - - -+ (PBGitSHA *)shaWithString:(NSString *)shaString -{ - git_oid oid; - int err = git_oid_mkstr(&oid, [shaString UTF8String]); - if (err == GIT_ENOTOID) - return nil; - - return [self shaWithOID:oid]; -} - - -+ (PBGitSHA *)shaWithCString:(const char *)shaCString -{ - git_oid oid; - int err = git_oid_mkstr(&oid, shaCString); - if (err == GIT_ENOTOID) - return nil; - - return [self shaWithOID:oid]; -} - - -+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector -{ - return NO; -} - - -+ (BOOL)isKeyExcludedFromWebScript:(const char *)name -{ - return NO; -} - - - -#pragma mark - -#pragma mark PBGitSHA - -- (id)initWithOID:(git_oid)g_oid -{ - self = [super init]; - if (!self) - return nil; - - oid = g_oid; - - return self; -} - - -- (NSString *)string -{ - if (!string) { - char *hex = git_oid_allocfmt(&oid); - if (hex == NULL) - return nil; - string = [NSString stringWithUTF8String:hex]; - free(hex); - } - - return string; -} - - -- (BOOL)isEqual:(id)otherSHA -{ - if (self == otherSHA) - return YES; - - git_oid other_oid = [(PBGitSHA *)otherSHA oid]; - return git_oid_cmp(&oid, &other_oid) == 0; -} - - -- (BOOL)isEqualToOID:(git_oid)other_oid -{ - return git_oid_cmp(&oid, &other_oid) == 0; -} - - -- (NSUInteger)hash -{ - NSUInteger hash; - memcpy(&hash, &(oid.id), sizeof(NSUInteger)); - - return hash; -} - - -- (NSString *)description -{ - return [self string]; -} - - - -#pragma mark - -- (id)copyWithZone:(NSZone *)zone -{ - git_oid oidCopy; - git_oid_cpy(&oidCopy, &oid); - PBGitSHA *copy = [[[self class] allocWithZone:zone] initWithOID:oidCopy]; - - return copy; -} - -@end diff --git a/PBHistorySearchController.m b/PBHistorySearchController.m index e028563..6f7da2b 100644 --- a/PBHistorySearchController.m +++ b/PBHistorySearchController.m @@ -442,7 +442,7 @@ 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]) { [indexes addIndex:index]; break; } diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index 74c600f..f7a7cf8 100644 --- a/PBWebHistoryController.h +++ b/PBWebHistoryController.h @@ -14,13 +14,13 @@ #import "PBRefContextDelegate.h" -@class PBGitSHA; +@class NSString; @interface PBWebHistoryController : PBWebController { IBOutlet PBGitHistoryController* historyController; IBOutlet id contextMenuDelegate; - PBGitSHA* currentSha; + NSString* currentSha; NSString* diff; } diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index a05bfe8..5d1bd47 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -8,7 +8,6 @@ #import "PBWebHistoryController.h" #import "PBGitDefaults.h" -#import "PBGitSHA.h" #import "GLFileView.h" #import @@ -57,7 +56,7 @@ // 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", @"--numstat", @"--summary", @"--pretty=raw", [currentSha string], nil]; + NSMutableArray *taskArguments = [NSMutableArray arrayWithObjects:@"show", @"--numstat", @"--summary", @"--pretty=raw", currentSha, nil]; if (![PBGitDefaults showWhitespaceDifferences]) [taskArguments insertObject:@"-w" atIndex:1]; @@ -107,17 +106,17 @@ NSMutableDictionary *stats=[self parseStats:details]; // File list - NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", [currentSha string], nil]]; + NSString *dt=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"-r", @"-C90%", @"-M90%", currentSha, nil]]; NSString *fileList=[GLFileView parseDiffTree:dt withStats:stats]; // Diffs list - NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", [currentSha string], nil]]; + NSString *d=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"diff-tree", @"--root", @"--cc", @"-C90%", @"-M90%", currentSha, nil]]; NSString *diffs=[GLFileView parseDiff:d]; NSString *html=[NSString stringWithFormat:@"%@%@
%@
",header,fileList,diffs]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",[currentSha string]]]; - html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:[currentSha string]]; + html=[html stringByReplacingOccurrencesOfString:@"{SHA_PREV}" withString:[NSString stringWithFormat:@"%@^",currentSha]]; + html=[html stringByReplacingOccurrencesOfString:@"{SHA}" withString:currentSha]; [[view windowScriptObject] callWebScriptMethod:@"showCommit" withArguments:[NSArray arrayWithObject:html]]; @@ -223,7 +222,7 @@ - (void)selectCommit:(NSString *)sha { - [historyController selectCommit:[PBGitSHA shaWithString:sha]]; + [historyController selectCommit:sha]; } // TODO: need to be refactoring diff --git a/build_libgit2.sh b/build_libgit2.sh deleted file mode 100755 index 15b92ea..0000000 --- a/build_libgit2.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh - -# build_libgit2.sh -# GitX -# -# Created by BrotherBard on 7/3/10. -# Copyright 2010 BrotherBard. All rights reserved. -# -# based on: http://log.yeahrightkeller.com/post/270155578/run-script-while-cleaning-in-xcode - -buildAction () { - echo "Building libgit2..." - if [[ -d .git ]] - then - if [ "$(which git)" == "" ]; then - echo "git not found" - exit -1 - fi - git submodule init - git submodule sync - git submodule update - cd libgit2 - CFLAGS='-arch i386 -arch x86_64' - ./waf --out=$TARGET_TEMP_DIR --prefix=$TARGET_BUILD_DIR configure - if [ $? != 0 ]; then - echo "error: failed to waf configure" - exit -1 - fi - ./waf build-static - if [ $? != 0 ]; then - echo "error: failed to waf build-static" - exit -1 - fi - ranlib $TARGET_TEMP_DIR/static/libgit2.a - cp $TARGET_TEMP_DIR/static/libgit2.a $TARGET_BUILD_DIR - else - echo "error: Not a git repository." - echo "error: clone GitX first so that the libgit2 submodule can be updated" - exit 1 - fi -} - -cleanAction () { - echo "Cleaning libgit2..." - cd libgit2 - ./waf clean -} - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# MAIN - -#echo "Running with ACTION=${ACTION}" - -case $ACTION in - # NOTE: it gets set to "" rather than "build" when doing a build. - "") - buildAction - ;; - - "clean") - cleanAction - ;; -esac - -exit 0 - diff --git a/libgit2 b/libgit2 deleted file mode 160000 index d1685ac..0000000 --- a/libgit2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d1685ac7e91c5269cf01f6ab57c2c4705a14e6bc