Skip to content
This repository
Browse code

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...
commit d2eafc2d52967cbd4fd99e00fbecb750fca30249 1 parent 1a7ad94
Pieter de Bie authored November 21, 2008
3  .gitmodules
... ...
@@ -0,0 +1,3 @@
  1
+[submodule "libgit2"]
  2
+	path = libgit2
  3
+	url = git://github.com/pieter/libgit2.git
31  GitX.xcodeproj/project.pbxproj
@@ -80,6 +80,8 @@
80 80
 		F5AD56790E79B78100EDAAFE /* PBCommitList.m in Sources */ = {isa = PBXBuildFile; fileRef = F5AD56780E79B78100EDAAFE /* PBCommitList.m */; };
81 81
 		F5B721C40E05CF7E00AF29DC /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5B721C20E05CF7E00AF29DC /* MainMenu.xib */; };
82 82
 		F5C007750E731B48007B84B2 /* PBGitRef.m in Sources */ = {isa = PBXBuildFile; fileRef = F5C007740E731B48007B84B2 /* PBGitRef.m */; };
  83
+		F5C580E50EDA250900995434 /* libgit2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F5C580E40EDA250900995434 /* libgit2.a */; };
  84
+		F5C580F50EDA251100995434 /* libgit2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F5C580E40EDA250900995434 /* libgit2.a */; };
83 85
 		F5C6F68D0E65FF9300478D97 /* PBGitLane.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5C6F68C0E65FF9300478D97 /* PBGitLane.mm */; };
84 86
 		F5DFFA6C0E075D8800617813 /* PBEasyFS.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DFFA6B0E075D8800617813 /* PBEasyFS.m */; };
85 87
 		F5E424110EA3E4D60046E362 /* PBDiffWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F5E424100EA3E4D60046E362 /* PBDiffWindow.xib */; };
@@ -214,6 +216,7 @@
214 216
 		F5B721C30E05CF7E00AF29DC /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = "<group>"; };
215 217
 		F5C007730E731B48007B84B2 /* PBGitRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRef.h; sourceTree = "<group>"; };
216 218
 		F5C007740E731B48007B84B2 /* PBGitRef.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitRef.m; sourceTree = "<group>"; };
  219
+		F5C580E40EDA250900995434 /* libgit2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgit2.a; path = libgit2/libgit2.a; sourceTree = "<group>"; };
217 220
 		F5C6F68B0E65FF9300478D97 /* PBGitLane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitLane.h; sourceTree = "<group>"; };
218 221
 		F5C6F68C0E65FF9300478D97 /* PBGitLane.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PBGitLane.mm; sourceTree = "<group>"; };
219 222
 		F5D2DC850EA401A80034AD24 /* PBGitConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitConfig.h; sourceTree = "<group>"; };
@@ -259,6 +262,7 @@
259 262
 				911112370E5A097800BF76B4 /* Security.framework in Frameworks */,
260 263
 				F580E6AE0E733276009E2D3F /* Sparkle.framework in Frameworks */,
261 264
 				F5E4DBFB0EAB58D90013FAFC /* SystemConfiguration.framework in Frameworks */,
  265
+				F5C580E50EDA250900995434 /* libgit2.a in Frameworks */,
262 266
 			);
263 267
 			runOnlyForDeploymentPostprocessing = 0;
264 268
 		};
@@ -273,6 +277,7 @@
273 277
 			isa = PBXFrameworksBuildPhase;
274 278
 			buildActionMask = 2147483647;
275 279
 			files = (
  280
+				F5C580F50EDA251100995434 /* libgit2.a in Frameworks */,
276 281
 				F5886A1E0ED5D3880066E74C /* Cocoa.framework in Frameworks */,
277 282
 			);
278 283
 			runOnlyForDeploymentPostprocessing = 0;
@@ -375,6 +380,7 @@
375 380
 		29B97323FDCFA39411CA2CEA /* Frameworks */ = {
376 381
 			isa = PBXGroup;
377 382
 			children = (
  383
+				F5C580E40EDA250900995434 /* libgit2.a */,
378 384
 				1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
379 385
 				1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
380 386
 			);
@@ -578,6 +584,7 @@
578 584
 			isa = PBXNativeTarget;
579 585
 			buildConfigurationList = 26FC0A840875C7B200E6366F /* Build configuration list for PBXNativeTarget "GitX" */;
580 586
 			buildPhases = (
  587
+				F5792DFB0EDB570C001B0C31 /* Compilie libgit2 */,
581 588
 				8D1107290486CEB800E47090 /* Resources */,
582 589
 				8D11072C0486CEB800E47090 /* Sources */,
583 590
 				8D11072E0486CEB800E47090 /* Frameworks */,
@@ -683,6 +690,20 @@
683 690
 /* End PBXResourcesBuildPhase section */
684 691
 
685 692
 /* Begin PBXShellScriptBuildPhase section */
  693
+		F5792DFB0EDB570C001B0C31 /* Compilie libgit2 */ = {
  694
+			isa = PBXShellScriptBuildPhase;
  695
+			buildActionMask = 2147483647;
  696
+			files = (
  697
+			);
  698
+			inputPaths = (
  699
+			);
  700
+			name = "Compilie libgit2";
  701
+			outputPaths = (
  702
+			);
  703
+			runOnlyForDeploymentPostprocessing = 0;
  704
+			shellPath = /bin/sh;
  705
+			shellScript = "git submodule init\ngit submodule update\ncd libgit2\nrm -f libgit2.a\nmake CFLAGS=\"-arch i386 -arch ppc\"\nranlib libgit2.a";
  706
+		};
686 707
 		F5CF04A20EAE696C00D75C81 /* Copy HTML files */ = {
687 708
 			isa = PBXShellScriptBuildPhase;
688 709
 			buildActionMask = 2147483647;
@@ -840,8 +861,10 @@
840 861
 				GCC_OPTIMIZATION_LEVEL = 0;
841 862
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
842 863
 				GCC_PREFIX_HEADER = GitX_Prefix.pch;
  864
+				HEADER_SEARCH_PATHS = libgit2/src;
843 865
 				INFOPLIST_FILE = Info.plist;
844 866
 				INSTALL_PATH = "$(HOME)/Applications";
  867
+				LIBRARY_SEARCH_PATHS = libgit2;
845 868
 				PRODUCT_NAME = GitX;
846 869
 				WRAPPER_EXTENSION = app;
847 870
 				ZERO_LINK = YES;
@@ -860,8 +883,10 @@
860 883
 				GCC_MODEL_TUNING = G5;
861 884
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
862 885
 				GCC_PREFIX_HEADER = GitX_Prefix.pch;
  886
+				HEADER_SEARCH_PATHS = libgit2/src;
863 887
 				INFOPLIST_FILE = Info.plist;
864 888
 				INSTALL_PATH = "$(HOME)/Applications";
  889
+				LIBRARY_SEARCH_PATHS = libgit2;
865 890
 				PRODUCT_NAME = GitX;
866 891
 				WRAPPER_EXTENSION = app;
867 892
 			};
@@ -904,6 +929,7 @@
904 929
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
905 930
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
906 931
 				INSTALL_PATH = /usr/local/bin;
  932
+				LIBRARY_SEARCH_PATHS = libgit2;
907 933
 				OTHER_LDFLAGS = (
908 934
 					"-framework",
909 935
 					Foundation,
@@ -926,6 +952,7 @@
926 952
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
927 953
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
928 954
 				INSTALL_PATH = /usr/local/bin;
  955
+				LIBRARY_SEARCH_PATHS = libgit2;
929 956
 				OTHER_LDFLAGS = (
930 957
 					"-framework",
931 958
 					Foundation,
@@ -949,10 +976,13 @@
949 976
 				GCC_OPTIMIZATION_LEVEL = 2;
950 977
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
951 978
 				GCC_PREFIX_HEADER = GitX_Prefix.pch;
  979
+				HEADER_SEARCH_PATHS = libgit2/src;
952 980
 				INFOPLIST_FILE = "SpeedTest-Info.plist";
953 981
 				INSTALL_PATH = "$(HOME)/Applications";
  982
+				LIBRARY_SEARCH_PATHS = libgit2;
954 983
 				OTHER_CFLAGS = "-DCLI";
955 984
 				OTHER_LDFLAGS = (
  985
+					"-L.",
956 986
 					"-framework",
957 987
 					Foundation,
958 988
 					"-framework",
@@ -976,6 +1006,7 @@
976 1006
 				GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
977 1007
 				INFOPLIST_FILE = "SpeedTest-Info.plist";
978 1008
 				INSTALL_PATH = "$(HOME)/Applications";
  1009
+				LIBRARY_SEARCH_PATHS = libgit2;
979 1010
 				OTHER_LDFLAGS = (
980 1011
 					"-framework",
981 1012
 					Foundation,
9  PBGitCommit.h
@@ -9,9 +9,10 @@
9 9
 #import <Cocoa/Cocoa.h>
10 10
 #import "PBGitRepository.h"
11 11
 #import "PBGitTree.h"
  12
+#include "git/oid.h"
12 13
 
13 14
 @interface PBGitCommit : NSObject {
14  
-	NSString* sha;
  15
+	git_oid sha;
15 16
 	NSString* subject;
16 17
 	NSString* author;
17 18
 	NSString* details;
@@ -24,12 +25,14 @@
24 25
 	PBGitRepository* repository;
25 26
 }
26 27
 
27  
-- initWithRepository:(PBGitRepository*) repo andSha:(NSString*) sha;
  28
+- initWithRepository:(PBGitRepository *)repo andSha:(git_oid)sha;
28 29
 
29 30
 - (void)addRef:(id)ref;
30 31
 - (void)removeRef:(id)ref;
31 32
 
32  
-@property (copy) NSString* sha;
  33
+- (NSString *)realSha;
  34
+
  35
+@property (readonly) git_oid *sha;
33 36
 @property (copy) NSString* subject;
34 37
 @property (copy) NSString* author;
35 38
 @property (retain) NSArray* parents;
23  PBGitCommit.m
@@ -11,7 +11,7 @@
11 11
 
12 12
 @implementation PBGitCommit
13 13
 
14  
-@synthesize sha, repository, subject, author, date, parents, sign, lineInfo, refs;
  14
+@synthesize repository, subject, author, date, parents, sign, lineInfo, refs;
15 15
 
16 16
 
17 17
 - (NSString *) dateString
@@ -25,14 +25,27 @@ - (NSArray*) treeContents
25 25
 	return self.tree.children;
26 26
 }
27 27
 
28  
-- initWithRepository:(PBGitRepository*) repo andSha:(NSString*) newSha
  28
+- (git_oid *)sha
  29
+{
  30
+	return &sha;
  31
+}
  32
+
  33
+- initWithRepository:(PBGitRepository*) repo andSha:(git_oid)newSha
29 34
 {
30 35
 	details = nil;
31  
-	self.repository = repo;
32  
-	self.sha = newSha;
  36
+	repository = repo;
  37
+	sha = newSha;
33 38
 	return self;
34 39
 }
35 40
 
  41
+- (NSString *)realSha
  42
+{
  43
+	char *hex = git_oid_mkhex(&sha);
  44
+	NSString *str = [NSString stringWithUTF8String:hex];
  45
+	free(hex);
  46
+	return str;
  47
+}
  48
+
36 49
 // NOTE: This method should remain threadsafe, as we load it in async
37 50
 // from the web view.
38 51
 - (NSString*) details
@@ -40,7 +53,7 @@ - (NSString*) details
40 53
 	if (details != nil)
41 54
 		return details;
42 55
 
43  
-	details = [self.repository outputForCommand:[@"show --pretty=raw " stringByAppendingString:self.sha]];
  56
+	details = [self.repository outputForCommand:[@"show --pretty=raw " stringByAppendingString:[self realSha]]];
44 57
 	
45 58
 	return details;
46 59
 }
3  PBGitGrapher.h
@@ -14,6 +14,9 @@
14 14
 @interface PBGitGrapher : NSObject {
15 15
 	PBGraphCellInfo* previous;
16 16
 	void *pl;
  17
+	void *storage;
  18
+	int curLane;
  19
+
17 20
 	NSDictionary* refs;
18 21
 	PBGitRepository* repository;
19 22
 }
8  PBGitGrapher.mm
@@ -6,6 +6,10 @@
6 6
 //  Copyright 2008 __MyCompanyName__. All rights reserved.
7 7
 //
8 8
 
  9
+extern "C" {
  10
+#import "git/oid.h"
  11
+}
  12
+
9 13
 #import "PBGitGrapher.h"
10 14
 #import "PBGitCommit.h"
11 15
 #import "PBGitLane.h"
@@ -31,7 +35,6 @@ - (id) initWithRepository: (PBGitRepository*) repo
31 35
 
32 36
 - (void) decorateCommit: (PBGitCommit *) commit
33 37
 {
34  
-	//NSLog(@"Decoriting commit %@", commit.sha);
35 38
 	int i = 0, newPos = -1;
36 39
 	std::vector<PBGitLane *> *currentLanes = new std::vector<PBGitLane *>;
37 40
 	std::vector<PBGitLane *> *previousLanes = (std::vector<PBGitLane *> *)pl;
@@ -48,7 +51,6 @@ - (void) decorateCommit: (PBGitCommit *) commit
48 51
 			i++;
49 52
 			// This is our commit! We should do a "merge": move the line from
50 53
 			// our upperMapping to their lowerMapping
51  
-
52 54
 			if ((*it)->isCommit([commit sha])) {
53 55
 				if (!didFirst) {
54 56
 					didFirst = YES;
@@ -116,7 +118,7 @@ - (void) decorateCommit: (PBGitCommit *) commit
116 118
 	// This boolean will tell us if that happened
117 119
 	BOOL addedParent = NO;
118 120
 
119  
-	for (NSString* parent in [commit.parents subarrayWithRange:NSMakeRange(1, [commit.parents count] -1)]) {
  121
+	for (NSString *parent in [commit.parents subarrayWithRange:NSMakeRange(1, [commit.parents count] -1)]) {
120 122
 		int i = 0;
121 123
 		BOOL was_displayed = NO;
122 124
 		std::vector<PBGitLane *>::iterator it = currentLanes->begin();
168  PBGitHistoryView.xib
@@ -3,14 +3,14 @@
3 3
 	<data>
4 4
 		<int key="IBDocument.SystemTarget">1050</int>
5 5
 		<string key="IBDocument.SystemVersion">9F33</string>
6  
-		<string key="IBDocument.InterfaceBuilderVersion">672</string>
  6
+		<string key="IBDocument.InterfaceBuilderVersion">670</string>
7 7
 		<string key="IBDocument.AppKitVersion">949.34</string>
8 8
 		<string key="IBDocument.HIToolboxVersion">352.00</string>
9 9
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
10 10
 			<bool key="EncodedWithXMLCoder">YES</bool>
11 11
 			<integer value="236"/>
  12
+			<integer value="27"/>
12 13
 			<integer value="263"/>
13  
-			<integer value="11"/>
14 14
 		</object>
15 15
 		<object class="NSArray" key="IBDocument.PluginDependencies">
16 16
 			<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2362,87 +2362,6 @@
2362 2362
 						<reference key="parent" ref="555671215"/>
2363 2363
 					</object>
2364 2364
 					<object class="IBObjectRecord">
2365  
-						<int key="objectID">3</int>
2366  
-						<reference key="object" ref="663765878"/>
2367  
-						<object class="NSMutableArray" key="children">
2368  
-							<bool key="EncodedWithXMLCoder">YES</bool>
2369  
-							<reference ref="942510576"/>
2370  
-							<reference ref="452331733"/>
2371  
-							<reference ref="152625445"/>
2372  
-							<reference ref="254268962"/>
2373  
-						</object>
2374  
-						<reference key="parent" ref="202620420"/>
2375  
-					</object>
2376  
-					<object class="IBObjectRecord">
2377  
-						<int key="objectID">30</int>
2378  
-						<reference key="object" ref="942510576"/>
2379  
-						<reference key="parent" ref="663765878"/>
2380  
-					</object>
2381  
-					<object class="IBObjectRecord">
2382  
-						<int key="objectID">29</int>
2383  
-						<reference key="object" ref="452331733"/>
2384  
-						<reference key="parent" ref="663765878"/>
2385  
-					</object>
2386  
-					<object class="IBObjectRecord">
2387  
-						<int key="objectID">28</int>
2388  
-						<reference key="object" ref="152625445"/>
2389  
-						<reference key="parent" ref="663765878"/>
2390  
-					</object>
2391  
-					<object class="IBObjectRecord">
2392  
-						<int key="objectID">27</int>
2393  
-						<reference key="object" ref="254268962"/>
2394  
-						<object class="NSMutableArray" key="children">
2395  
-							<bool key="EncodedWithXMLCoder">YES</bool>
2396  
-							<reference ref="976830280"/>
2397  
-							<reference ref="1025472344"/>
2398  
-							<reference ref="792589327"/>
2399  
-						</object>
2400  
-						<reference key="parent" ref="663765878"/>
2401  
-						<string key="objectName">Commit List</string>
2402  
-					</object>
2403  
-					<object class="IBObjectRecord">
2404  
-						<int key="objectID">33</int>
2405  
-						<reference key="object" ref="976830280"/>
2406  
-						<object class="NSMutableArray" key="children">
2407  
-							<bool key="EncodedWithXMLCoder">YES</bool>
2408  
-							<reference ref="853819733"/>
2409  
-						</object>
2410  
-						<reference key="parent" ref="254268962"/>
2411  
-					</object>
2412  
-					<object class="IBObjectRecord">
2413  
-						<int key="objectID">32</int>
2414  
-						<reference key="object" ref="1025472344"/>
2415  
-						<object class="NSMutableArray" key="children">
2416  
-							<bool key="EncodedWithXMLCoder">YES</bool>
2417  
-							<reference ref="977219207"/>
2418  
-						</object>
2419  
-						<reference key="parent" ref="254268962"/>
2420  
-					</object>
2421  
-					<object class="IBObjectRecord">
2422  
-						<int key="objectID">31</int>
2423  
-						<reference key="object" ref="792589327"/>
2424  
-						<object class="NSMutableArray" key="children">
2425  
-							<bool key="EncodedWithXMLCoder">YES</bool>
2426  
-							<reference ref="746918365"/>
2427  
-						</object>
2428  
-						<reference key="parent" ref="254268962"/>
2429  
-					</object>
2430  
-					<object class="IBObjectRecord">
2431  
-						<int key="objectID">36</int>
2432  
-						<reference key="object" ref="746918365"/>
2433  
-						<reference key="parent" ref="792589327"/>
2434  
-					</object>
2435  
-					<object class="IBObjectRecord">
2436  
-						<int key="objectID">35</int>
2437  
-						<reference key="object" ref="977219207"/>
2438  
-						<reference key="parent" ref="1025472344"/>
2439  
-					</object>
2440  
-					<object class="IBObjectRecord">
2441  
-						<int key="objectID">34</int>
2442  
-						<reference key="object" ref="853819733"/>
2443  
-						<reference key="parent" ref="976830280"/>
2444  
-					</object>
2445  
-					<object class="IBObjectRecord">
2446 2365
 						<int key="objectID">231</int>
2447 2366
 						<reference key="object" ref="892732705"/>
2448 2367
 						<reference key="parent" ref="1002"/>
@@ -2686,6 +2605,87 @@
2686 2605
 						<reference key="object" ref="882172208"/>
2687 2606
 						<reference key="parent" ref="604026377"/>
2688 2607
 					</object>
  2608
+					<object class="IBObjectRecord">
  2609
+						<int key="objectID">3</int>
  2610
+						<reference key="object" ref="663765878"/>
  2611
+						<object class="NSMutableArray" key="children">
  2612
+							<bool key="EncodedWithXMLCoder">YES</bool>
  2613
+							<reference ref="254268962"/>
  2614
+							<reference ref="152625445"/>
  2615
+							<reference ref="452331733"/>
  2616
+							<reference ref="942510576"/>
  2617
+						</object>
  2618
+						<reference key="parent" ref="202620420"/>
  2619
+					</object>
  2620
+					<object class="IBObjectRecord">
  2621
+						<int key="objectID">27</int>
  2622
+						<reference key="object" ref="254268962"/>
  2623
+						<object class="NSMutableArray" key="children">
  2624
+							<bool key="EncodedWithXMLCoder">YES</bool>
  2625
+							<reference ref="792589327"/>
  2626
+							<reference ref="1025472344"/>
  2627
+							<reference ref="976830280"/>
  2628
+						</object>
  2629
+						<reference key="parent" ref="663765878"/>
  2630
+						<string key="objectName">Commit List</string>
  2631
+					</object>
  2632
+					<object class="IBObjectRecord">
  2633
+						<int key="objectID">31</int>
  2634
+						<reference key="object" ref="792589327"/>
  2635
+						<object class="NSMutableArray" key="children">
  2636
+							<bool key="EncodedWithXMLCoder">YES</bool>
  2637
+							<reference ref="746918365"/>
  2638
+						</object>
  2639
+						<reference key="parent" ref="254268962"/>
  2640
+					</object>
  2641
+					<object class="IBObjectRecord">
  2642
+						<int key="objectID">36</int>
  2643
+						<reference key="object" ref="746918365"/>
  2644
+						<reference key="parent" ref="792589327"/>
  2645
+					</object>
  2646
+					<object class="IBObjectRecord">
  2647
+						<int key="objectID">32</int>
  2648
+						<reference key="object" ref="1025472344"/>
  2649
+						<object class="NSMutableArray" key="children">
  2650
+							<bool key="EncodedWithXMLCoder">YES</bool>
  2651
+							<reference ref="977219207"/>
  2652
+						</object>
  2653
+						<reference key="parent" ref="254268962"/>
  2654
+					</object>
  2655
+					<object class="IBObjectRecord">
  2656
+						<int key="objectID">35</int>
  2657
+						<reference key="object" ref="977219207"/>
  2658
+						<reference key="parent" ref="1025472344"/>
  2659
+					</object>
  2660
+					<object class="IBObjectRecord">
  2661
+						<int key="objectID">33</int>
  2662
+						<reference key="object" ref="976830280"/>
  2663
+						<object class="NSMutableArray" key="children">
  2664
+							<bool key="EncodedWithXMLCoder">YES</bool>
  2665
+							<reference ref="853819733"/>
  2666
+						</object>
  2667
+						<reference key="parent" ref="254268962"/>
  2668
+					</object>
  2669
+					<object class="IBObjectRecord">
  2670
+						<int key="objectID">34</int>
  2671
+						<reference key="object" ref="853819733"/>
  2672
+						<reference key="parent" ref="976830280"/>
  2673
+					</object>
  2674
+					<object class="IBObjectRecord">
  2675
+						<int key="objectID">28</int>
  2676
+						<reference key="object" ref="152625445"/>
  2677
+						<reference key="parent" ref="663765878"/>
  2678
+					</object>
  2679
+					<object class="IBObjectRecord">
  2680
+						<int key="objectID">29</int>
  2681
+						<reference key="object" ref="452331733"/>
  2682
+						<reference key="parent" ref="663765878"/>
  2683
+					</object>
  2684
+					<object class="IBObjectRecord">
  2685
+						<int key="objectID">30</int>
  2686
+						<reference key="object" ref="942510576"/>
  2687
+						<reference key="parent" ref="663765878"/>
  2688
+					</object>
2689 2689
 				</object>
2690 2690
 			</object>
2691 2691
 			<object class="NSMutableDictionary" key="flattenedProperties">
@@ -2796,7 +2796,7 @@
2796 2796
 					<string>com.apple.InterfaceBuilderKit</string>
2797 2797
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
2798 2798
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
2799  
-					<string>{{69, 366}, {616, 227}}</string>
  2799
+					<string>{{312, 366}, {616, 227}}</string>
2800 2800
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
2801 2801
 					<string>{{132, 614}, {616, 0}}</string>
2802 2802
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
24  PBGitLane.h
@@ -6,32 +6,46 @@
6 6
 //  Copyright 2008 __MyCompanyName__. All rights reserved.
7 7
 //
8 8
 #import <Cocoa/Cocoa.h>
  9
+extern "C"
  10
+{
  11
+#include "git/oid.h"
  12
+}
9 13
 
10 14
 class PBGitLane {
11 15
 	static int s_colorIndex;
12 16
 
13  
-	NSString *d_sha;
  17
+	git_oid d_sha;
14 18
 	int d_index;
15 19
 
16 20
 public:
17 21
 
  22
+	PBGitLane(git_oid sha)
  23
+	{
  24
+		d_index = s_colorIndex++;
  25
+		d_sha = sha;
  26
+	}
  27
+
18 28
 	PBGitLane(NSString *sha)
19 29
 	{
  30
+		git_oid_mkstr(&d_sha, [sha UTF8String]);
20 31
 		d_index = s_colorIndex++;
21  
-		d_sha = [sha copy];
22 32
 	}
23 33
 	
24 34
 	PBGitLane()
25 35
 	{
26 36
 		d_index = s_colorIndex++;
27  
-		d_sha = NULL;
  37
+		//d_sha = NULL;
28 38
 	}
29 39
 	
  40
+	bool isCommit(git_oid *sha) const;
30 41
 	bool isCommit(NSString *sha) const;
  42
+	
  43
+	void setSha(git_oid sha);
31 44
 	void setSha(NSString *sha);
32  
-	NSString *sha() const
  45
+	
  46
+	git_oid const *sha() const
33 47
 	{
34  
-		return [d_sha copy];
  48
+		return &d_sha;
35 49
 	}
36 50
 	
37 51
 	int index() const;
24  PBGitLane.mm
@@ -24,10 +24,22 @@
24 24
 
25 25
 int PBGitLane::s_colorIndex = 0;
26 26
 
  27
+static git_oid str_to_oid(NSString *str)
  28
+{
  29
+	git_oid oid;
  30
+	git_oid_mkstr(&oid, [str UTF8String]);
  31
+	return oid;
  32
+}
  33
+
  34
+bool PBGitLane::isCommit(git_oid *sha) const
  35
+{
  36
+	return !git_oid_cmp(&d_sha, sha);
  37
+}
  38
+
27 39
 bool PBGitLane::isCommit(NSString *sha) const
28 40
 {
29  
-	//NSLog(@"Comparing %@ with %@", d_sha, sha);
30  
-	return [d_sha isEqualToString:sha];
  41
+	git_oid a = str_to_oid(sha);
  42
+	return isCommit(&a);
31 43
 }
32 44
 
33 45
 int PBGitLane::index() const
@@ -35,11 +47,17 @@
35 47
 	return d_index;
36 48
 }
37 49
 
38  
-void PBGitLane::setSha(NSString *sha)
  50
+void PBGitLane::setSha(git_oid sha)
39 51
 {
40 52
 	d_sha = sha;
41 53
 }
42 54
 
  55
+void PBGitLane::setSha(NSString *sha)
  56
+{
  57
+	return setSha(str_to_oid(sha));
  58
+}
  59
+
  60
+
43 61
 void PBGitLane::resetColors()
44 62
 {
45 63
 	s_colorIndex = 0;
15  PBGitRevList.mm
@@ -6,6 +6,11 @@
6 6
 //  Copyright 2008 __MyCompanyName__. All rights reserved.
7 7
 //
8 8
 
  9
+extern "C"
  10
+{
  11
+#include "git/oid.h"
  12
+}
  13
+
9 14
 #import "PBGitRevList.h"
10 15
 #import "PBGitRepository.h"
11 16
 #import "PBGitCommit.h"
@@ -116,7 +121,9 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
116 121
 		}
117 122
 
118 123
 		// From now on, 1.2 seconds
119  
-		PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository: repository andSha: [NSString stringWithUTF8String:sha.c_str()]];
  124
+		git_oid oid;
  125
+		git_oid_mkstr(&oid, sha.c_str());
  126
+		PBGitCommit* newCommit = [[PBGitCommit alloc] initWithRepository:repository andSha:oid];
120 127
 
121 128
 		string author;
122 129
 		getline(stream, author, '\0');
@@ -154,11 +161,11 @@ - (void) walkRevisionListWithSpecifier: (PBGitRevSpecifier*) rev
154 161
 		}
155 162
 
156 163
 		[revisions addObject: newCommit];
157  
-		//[g decorateCommit: newCommit];
  164
+		[g decorateCommit: newCommit];
158 165
 		
159 166
 		// 0.1 second on linux-2.6
160  
-		if (refs && [refs objectForKey:newCommit.sha])
161  
-			newCommit.refs = [refs objectForKey:newCommit.sha];
  167
+		if (refs && [refs objectForKey:[newCommit realSha]])
  168
+			newCommit.refs = [refs objectForKey:[newCommit realSha]];
162 169
 		
163 170
 		if (++num % 1000 == 0)
164 171
 			[self performSelectorOnMainThread:@selector(setCommits:) withObject:revisions waitUntilDone:NO];
2  PBGitTree.m
@@ -22,7 +22,7 @@ + (PBGitTree*) rootForCommit:(id) commit
22 22
 	PBGitTree* tree = [[self alloc] init];
23 23
 	tree.parent = nil;
24 24
 	tree.leaf = NO;
25  
-	tree.sha = c.sha;
  25
+	tree.sha = [c realSha];
26 26
 	tree.repository = c.repository;
27 27
 	tree.path = @"";
28 28
 	return tree;
4  PBWebHistoryController.m
@@ -38,12 +38,12 @@ - (void) changeContentTo: (PBGitCommit *) content
38 38
 		return;
39 39
 
40 40
 	// The sha is the same, but refs may have changed.. reload it lazy
41  
-	if ([currentSha isEqualToString: content.sha])
  41
+	if ([currentSha isEqualToString: [content realSha]])
42 42
 	{
43 43
 		[[self script] callWebScriptMethod:@"reload" withArguments: nil];
44 44
 		return;
45 45
 	}
46  
-	currentSha = content.sha;
  46
+	currentSha = [content realSha];
47 47
 
48 48
 	NSArray *arguments = [NSArray arrayWithObjects:content, [[[historyController repository] headRef] simpleRef], nil];
49 49
 	[[self script] callWebScriptMethod:@"loadCommit" withArguments: arguments];
2  html/views/history/history.js
@@ -4,7 +4,7 @@ var Commit = function(obj) {
4 4
 
5 5
 	this.refs = obj.refs;
6 6
 	this.author_name = obj.author;
7  
-	this.sha = obj.sha;
  7
+	this.sha = obj.realSha();
8 8
 	this.parents = obj.parents;
9 9
 	this.subject = obj.subject;
10 10
 
1  libgit2
... ...
@@ -0,0 +1 @@
  1
+Subproject commit bda29d0f7bc59a821b03c716562aef6ea3b5903a

0 notes on commit d2eafc2

Please sign in to comment.
Something went wrong with that request. Please try again.