Permalink
Browse files

Include libgit2 as submodule and use it to store sha's

This reduces GitX's memory usage and makes some operations much faster,
like graphing, by having a cheaper comparison
  • Loading branch information...
1 parent 1a7ad94 commit d2eafc2d52967cbd4fd99e00fbecb750fca30249 @pieter pieter committed Nov 21, 2008
Showing with 206 additions and 111 deletions.
  1. +3 −0 .gitmodules
  2. +31 −0 GitX.xcodeproj/project.pbxproj
  3. +6 −3 PBGitCommit.h
  4. +18 −5 PBGitCommit.m
  5. +3 −0 PBGitGrapher.h
  6. +5 −3 PBGitGrapher.mm
  7. +84 −84 PBGitHistoryView.xib
  8. +19 −5 PBGitLane.h
  9. +21 −3 PBGitLane.mm
  10. +11 −4 PBGitRevList.mm
  11. +1 −1 PBGitTree.m
  12. +2 −2 PBWebHistoryController.m
  13. +1 −1 html/views/history/history.js
  14. +1 −0 libgit2
View
@@ -0,0 +1,3 @@
+[submodule "libgit2"]
+ path = libgit2
+ url = git://github.com/pieter/libgit2.git
@@ -80,6 +80,8 @@
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 */; };
+ F5C580F50EDA251100995434 /* 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,6 +216,7 @@
F5B721C30E05CF7E00AF29DC /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
F5C007730E731B48007B84B2 /* PBGitRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRef.h; sourceTree = "<group>"; };
F5C007740E731B48007B84B2 /* PBGitRef.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRef.m; sourceTree = "<group>"; };
+ F5C580E40EDA250900995434 /* libgit2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgit2.a; path = libgit2/libgit2.a; sourceTree = "<group>"; };
F5C6F68B0E65FF9300478D97 /* PBGitLane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitLane.h; sourceTree = "<group>"; };
F5C6F68C0E65FF9300478D97 /* PBGitLane.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBGitLane.mm; sourceTree = "<group>"; };
F5D2DC850EA401A80034AD24 /* PBGitConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitConfig.h; sourceTree = "<group>"; };
@@ -259,6 +262,7 @@
911112370E5A097800BF76B4 /* Security.framework in Frameworks */,
F580E6AE0E733276009E2D3F /* Sparkle.framework in Frameworks */,
F5E4DBFB0EAB58D90013FAFC /* SystemConfiguration.framework in Frameworks */,
+ F5C580E50EDA250900995434 /* libgit2.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -273,6 +277,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ F5C580F50EDA251100995434 /* libgit2.a in Frameworks */,
F5886A1E0ED5D3880066E74C /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -375,6 +380,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
+ F5C580E40EDA250900995434 /* libgit2.a */,
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
);
@@ -578,6 +584,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 26FC0A840875C7B200E6366F /* Build configuration list for PBXNativeTarget "GitX" */;
buildPhases = (
+ F5792DFB0EDB570C001B0C31 /* Compilie libgit2 */,
8D1107290486CEB800E47090 /* Resources */,
8D11072C0486CEB800E47090 /* Sources */,
8D11072E0486CEB800E47090 /* Frameworks */,
@@ -683,6 +690,20 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
+ F5792DFB0EDB570C001B0C31 /* Compilie libgit2 */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Compilie libgit2";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "git submodule init\ngit submodule update\ncd libgit2\nrm -f libgit2.a\nmake CFLAGS=\"-arch i386 -arch ppc\"\nranlib libgit2.a";
+ };
F5CF04A20EAE696C00D75C81 /* Copy HTML files */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -840,8 +861,10 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = GitX_Prefix.pch;
+ HEADER_SEARCH_PATHS = libgit2/src;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
+ LIBRARY_SEARCH_PATHS = libgit2;
PRODUCT_NAME = GitX;
WRAPPER_EXTENSION = app;
ZERO_LINK = YES;
@@ -860,8 +883,10 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = GitX_Prefix.pch;
+ HEADER_SEARCH_PATHS = libgit2/src;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
+ LIBRARY_SEARCH_PATHS = libgit2;
PRODUCT_NAME = GitX;
WRAPPER_EXTENSION = app;
};
@@ -904,6 +929,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
INSTALL_PATH = /usr/local/bin;
+ LIBRARY_SEARCH_PATHS = libgit2;
OTHER_LDFLAGS = (
"-framework",
Foundation,
@@ -926,6 +952,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
INSTALL_PATH = /usr/local/bin;
+ LIBRARY_SEARCH_PATHS = libgit2;
OTHER_LDFLAGS = (
"-framework",
Foundation,
@@ -949,10 +976,13 @@
GCC_OPTIMIZATION_LEVEL = 2;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = GitX_Prefix.pch;
+ HEADER_SEARCH_PATHS = libgit2/src;
INFOPLIST_FILE = "SpeedTest-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
+ LIBRARY_SEARCH_PATHS = libgit2;
OTHER_CFLAGS = "-DCLI";
OTHER_LDFLAGS = (
+ "-L.",
"-framework",
Foundation,
"-framework",
@@ -976,6 +1006,7 @@
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
INFOPLIST_FILE = "SpeedTest-Info.plist";
INSTALL_PATH = "$(HOME)/Applications";
+ LIBRARY_SEARCH_PATHS = libgit2;
OTHER_LDFLAGS = (
"-framework",
Foundation,
View
@@ -9,9 +9,10 @@
#import <Cocoa/Cocoa.h>
#import "PBGitRepository.h"
#import "PBGitTree.h"
+#include "git/oid.h"
@interface PBGitCommit : NSObject {
- NSString* sha;
+ git_oid sha;
NSString* subject;
NSString* author;
NSString* details;
@@ -24,12 +25,14 @@
PBGitRepository* repository;
}
-- initWithRepository:(PBGitRepository*) repo andSha:(NSString*) sha;
+- initWithRepository:(PBGitRepository *)repo andSha:(git_oid)sha;
- (void)addRef:(id)ref;
- (void)removeRef:(id)ref;
-@property (copy) NSString* sha;
+- (NSString *)realSha;
+
+@property (readonly) git_oid *sha;
@property (copy) NSString* subject;
@property (copy) NSString* author;
@property (retain) NSArray* parents;
View
@@ -11,7 +11,7 @@
@implementation PBGitCommit
-@synthesize sha, repository, subject, author, date, parents, sign, lineInfo, refs;
+@synthesize repository, subject, author, date, parents, sign, lineInfo, refs;
- (NSString *) dateString
@@ -25,22 +25,35 @@ - (NSArray*) treeContents
return self.tree.children;
}
-- initWithRepository:(PBGitRepository*) repo andSha:(NSString*) newSha
+- (git_oid *)sha
+{
+ return &sha;
+}
+
+- initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
{
details = nil;
- self.repository = repo;
- self.sha = newSha;
+ repository = repo;
+ sha = newSha;
return self;
}
+- (NSString *)realSha
+{
+ char *hex = git_oid_mkhex(&sha);
+ NSString *str = [NSString stringWithUTF8String:hex];
+ free(hex);
+ return str;
+}
+
// NOTE: This method should remain threadsafe, as we load it in async
// from the web view.
- (NSString*) details
{
if (details != nil)
return details;
- details = [self.repository outputForCommand:[@"show --pretty=raw " stringByAppendingString:self.sha]];
+ details = [self.repository outputForCommand:[@"show --pretty=raw " stringByAppendingString:[self realSha]]];
return details;
}
View
@@ -14,6 +14,9 @@
@interface PBGitGrapher : NSObject {
PBGraphCellInfo* previous;
void *pl;
+ void *storage;
+ int curLane;
+
NSDictionary* refs;
PBGitRepository* repository;
}
View
@@ -6,6 +6,10 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
+extern "C" {
+#import "git/oid.h"
+}
+
#import "PBGitGrapher.h"
#import "PBGitCommit.h"
#import "PBGitLane.h"
@@ -31,7 +35,6 @@ - (id) initWithRepository: (PBGitRepository*) repo
- (void) decorateCommit: (PBGitCommit *) commit
{
- //NSLog(@"Decoriting commit %@", commit.sha);
int i = 0, newPos = -1;
std::vector<PBGitLane *> *currentLanes = new std::vector<PBGitLane *>;
std::vector<PBGitLane *> *previousLanes = (std::vector<PBGitLane *> *)pl;
@@ -48,7 +51,6 @@ - (void) decorateCommit: (PBGitCommit *) commit
i++;
// This is our commit! We should do a "merge": move the line from
// our upperMapping to their lowerMapping
-
if ((*it)->isCommit([commit sha])) {
if (!didFirst) {
didFirst = YES;
@@ -116,7 +118,7 @@ - (void) decorateCommit: (PBGitCommit *) commit
// This boolean will tell us if that happened
BOOL addedParent = NO;
- for (NSString* parent in [commit.parents subarrayWithRange:NSMakeRange(1, [commit.parents count] -1)]) {
+ for (NSString *parent in [commit.parents subarrayWithRange:NSMakeRange(1, [commit.parents count] -1)]) {
int i = 0;
BOOL was_displayed = NO;
std::vector<PBGitLane *>::iterator it = currentLanes->begin();
Oops, something went wrong.

0 comments on commit d2eafc2

Please sign in to comment.