Permalink
Browse files

updated libgit2

  • Loading branch information...
1 parent 0eef540 commit 6a43f62c9979ac65b2d9372003429c90b61e1772 @joshaber joshaber committed May 23, 2012
@@ -305,7 +305,7 @@ - (BOOL)git_getOid:(git_oid *)oid error:(NSError **)error {
if ([self length] != sizeof(git_oid)) {
if (error != NULL) {
*error = [NSError errorWithDomain:GTGitErrorDomain
- code:GIT_EINVALIDARGS
+ code:GITERR_INVALID
userInfo:
[NSDictionary dictionaryWithObject:@"can't extract oid from data of incorrect length"
forKey:NSLocalizedDescriptionKey]];
View
@@ -41,7 +41,7 @@ typedef enum {
@property (nonatomic, readonly) NSString *sha;
@property (nonatomic, readonly) NSString *remoteName;
@property (nonatomic, readonly) GTBranchType branchType;
-@property (nonatomic, readonly, dct_weak) GTRepository *repository;
+@property (nonatomic, readonly, unsafe_unretained) GTRepository *repository;
@property (nonatomic, readonly, strong) GTReference *reference;
@property (nonatomic, copy) NSArray *remoteBranches;
@@ -74,4 +74,6 @@ typedef enum {
// returns the matched remote branch or nil if no match was found.
- (GTBranch *)remoteBranchForRemoteName:(NSString *)remote;
+- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error;
+
@end
View
@@ -27,11 +27,12 @@
#import "GTReference.h"
#import "GTEnumerator.h"
#import "GTRepository.h"
+#import "GTCommit.h"
@interface GTBranch ()
@property (nonatomic, strong) GTReference *reference;
-@property (nonatomic, dct_weak) GTRepository *repository;
+@property (nonatomic, unsafe_unretained) GTRepository *repository;
@end
@implementation GTBranch
@@ -166,4 +167,31 @@ - (NSArray *)remoteBranches {
return nil;
}
+- (NSArray *)uniqueCommitsRelativeToBranch:(GTBranch *)otherBranch error:(NSError **)error {
+ if(otherBranch == nil) return [NSArray array];
+
+ GTEnumerator *enumerator = [GTEnumerator enumeratorWithRepository:self.repository error:error];
+ if(enumerator == nil) return nil;
+
+ [enumerator setOptions:GTEnumeratorOptionsTopologicalSort];
+
+ BOOL success = [enumerator push:self.sha error:error];
+ if(!success) return nil;
+
+ NSString *otherBranchTip = otherBranch.sha;
+ NSMutableArray *commits = [NSMutableArray array];
+ GTCommit *currentCommit = [enumerator nextObjectWithError:error];
+ while(currentCommit != nil) {
+ if([currentCommit.sha isEqualToString:otherBranchTip]) {
+ break;
+ }
+
+ [commits addObject:currentCommit];
+
+ currentCommit = [enumerator nextObjectWithError:error];
+ }
+
+ return commits;
+}
+
@end
@@ -49,7 +49,7 @@ typedef unsigned int GTEnumeratorOptions;
// GTRepository
@interface GTEnumerator : NSEnumerator <GTObject> {}
-@property (nonatomic, dct_weak) GTRepository *repository;
+@property (nonatomic, unsafe_unretained) GTRepository *repository;
@property (nonatomic, assign) GTEnumeratorOptions options;
- (id)initWithRepository:(GTRepository *)theRepo error:(NSError **)error;
@@ -54,7 +54,7 @@ typedef enum {
@property (nonatomic, getter=isStaged, readonly) NSUInteger staged;
@property (nonatomic, getter=isValid, readonly) BOOL valid;
@property (nonatomic, readonly) GTIndexEntryStatus status;
-@property (nonatomic, dct_weak) GTRepository *repository;
+@property (nonatomic, unsafe_unretained) GTRepository *repository;
// Convenience initializers
- (id)initWithEntry:(git_index_entry *)theEntry;
View
@@ -28,7 +28,6 @@
//
#include "git2.h"
-#import "dct_weak.h"
typedef enum {
GTObjectTypeAny = GIT_OBJ_ANY, /**< Object can be any of the following */
@@ -59,7 +58,7 @@ typedef enum {
@property (nonatomic, readonly) NSString *type;
@property (nonatomic, readonly) NSString *sha;
@property (nonatomic, readonly) NSString *shortSha;
-@property (nonatomic, dct_weak) GTRepository *repository;
+@property (nonatomic, unsafe_unretained) GTRepository *repository;
// Convenience initializers
- (id)initWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo;
@@ -29,7 +29,7 @@
@interface GTObjectDatabase : NSObject <GTObject>
@property (nonatomic, assign) git_odb *git_odb;
-@property (nonatomic, readonly, dct_weak) GTRepository *repository;
+@property (nonatomic, readonly, unsafe_unretained) GTRepository *repository;
+ (id)objectDatabaseWithRepository:(GTRepository *)repository;
- (id)initWithRepository:(GTRepository *)repository;
@@ -30,7 +30,7 @@
#import "NSString+Git.h"
@interface GTObjectDatabase ()
-@property (nonatomic, dct_weak) GTRepository *repository;
+@property (nonatomic, unsafe_unretained) GTRepository *repository;
@end
@@ -43,7 +43,7 @@ typedef enum {
@interface GTReference : NSObject <GTObject> {}
@property (nonatomic, assign) git_reference *git_reference;
-@property (nonatomic, dct_weak) GTRepository *repository;
+@property (nonatomic, unsafe_unretained) GTRepository *repository;
@property (nonatomic, readonly) NSString *type;
@property (nonatomic, readonly) const git_oid *oid;
@property (nonatomic, readonly, getter=isValid) BOOL valid;
@@ -452,41 +452,12 @@ - (GTBranch *)currentBranchWithError:(NSError **)error {
}
- (NSArray *)localCommitsRelativeToRemoteBranch:(GTBranch *)remoteBranch error:(NSError **)error {
- if(remoteBranch == nil) {
- return [NSArray array];
- }
-
GTBranch *localBranch = [self currentBranchWithError:error];
if(localBranch == nil) {
return nil;
}
-
- GTEnumerator *localBranchEnumerator = [GTEnumerator enumeratorWithRepository:self error:error];
- if(localBranchEnumerator == nil) {
- return nil;
- }
-
- [localBranchEnumerator setOptions:GTEnumeratorOptionsTopologicalSort];
-
- BOOL success = [localBranchEnumerator push:localBranch.sha error:error];
- if(!success) {
- return nil;
- }
-
- NSString *remoteBranchTip = remoteBranch.sha;
- NSMutableArray *commits = [NSMutableArray array];
- GTCommit *currentCommit = [localBranchEnumerator nextObjectWithError:error];
- while(currentCommit != nil) {
- if([currentCommit.sha isEqualToString:remoteBranchTip]) {
- break;
- }
-
- [commits addObject:currentCommit];
-
- currentCommit = [localBranchEnumerator nextObjectWithError:error];
- }
-
- return commits;
+
+ return [localBranch uniqueCommitsRelativeToBranch:remoteBranch error:error];
}
- (NSArray *)referenceNamesWithTypes:(GTReferenceTypes)types error:(NSError **)error {
@@ -35,7 +35,7 @@
@interface GTTreeEntry : NSObject <GTObject> {}
@property (nonatomic, assign, readonly) const git_tree_entry *git_tree_entry;
-@property (nonatomic, readonly, dct_weak) GTTree *tree;
+@property (nonatomic, readonly, unsafe_unretained) GTTree *tree;
- (id)initWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree *)parent;
+ (id)entryWithEntry:(const git_tree_entry *)theEntry parentTree:(GTTree *)parent;
@@ -36,7 +36,7 @@
@interface GTTreeEntry()
@property (nonatomic, assign) const git_tree_entry *git_tree_entry;
-@property (nonatomic, dct_weak) GTTree *tree;
+@property (nonatomic, unsafe_unretained) GTTree *tree;
@end
@@ -64,7 +64,6 @@
79262F1013C697C100A4B1EA /* git2 in Copy git2 Headers */ = {isa = PBXBuildFile; fileRef = 79262F0E13C697BE00A4B1EA /* git2 */; };
79262F8B13C69B1600A4B1EA /* git2.h in Headers */ = {isa = PBXBuildFile; fileRef = 79262F8A13C69B1600A4B1EA /* git2.h */; settings = {ATTRIBUTES = (Public, ); }; };
8803DA871313145700E6E818 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8803DA861313145700E6E818 /* libz.dylib */; };
- 883014EE14AC3E6E0040153F /* dct_weak.h in Headers */ = {isa = PBXBuildFile; fileRef = 883014ED14AC3E6E0040153F /* dct_weak.h */; settings = {ATTRIBUTES = (Public, ); }; };
88383CFA1468982B009012D5 /* libgit2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 88383CF91468982B009012D5 /* libgit2.a */; };
88383CFB1468982B009012D5 /* libgit2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 88383CF91468982B009012D5 /* libgit2.a */; };
8849C6A214AD81FF003890AF /* GTRepository+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 8849C6A114AD81FF003890AF /* GTRepository+Private.h */; };
@@ -190,7 +189,6 @@
79262F0E13C697BE00A4B1EA /* git2 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = git2; path = libgit2/include/git2; sourceTree = "<group>"; };
79262F8A13C69B1600A4B1EA /* git2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = git2.h; path = libgit2/include/git2.h; sourceTree = "<group>"; };
8803DA861313145700E6E818 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
- 883014ED14AC3E6E0040153F /* dct_weak.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dct_weak.h; sourceTree = "<group>"; };
88383CF91468982B009012D5 /* libgit2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgit2.a; sourceTree = "<group>"; };
8849C6A114AD81FF003890AF /* GTRepository+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTRepository+Private.h"; sourceTree = "<group>"; };
88EB7E4B14AEBA600046FEA4 /* GTConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTConfiguration.h; sourceTree = "<group>"; };
@@ -383,7 +381,6 @@
BDD8AF18131331F800CB5D40 /* GHUnitTestMain.m */,
BDD9C486133BA73E003708E7 /* GHUnitIOSTestMain.m */,
32DBCF5E0370ADEE00C91783 /* ObjectiveGitFramework_Prefix.pch */,
- 883014ED14AC3E6E0040153F /* dct_weak.h */,
);
name = "Other Sources";
sourceTree = "<group>";
@@ -544,7 +541,6 @@
88F6D9FC1320467800CC0BA8 /* GTSignature.h in Headers */,
88F50F59132054D800584FBE /* GTBranch.h in Headers */,
79262F8B13C69B1600A4B1EA /* git2.h in Headers */,
- 883014EE14AC3E6E0040153F /* dct_weak.h in Headers */,
88EB7E4D14AEBA600046FEA4 /* GTConfiguration.h in Headers */,
BDE4C064130EFE2C00851650 /* NSError+Git.h in Headers */,
55C8057D13875C11004DCB0F /* NSData+Git.h in Headers */,
Submodule libgit2 updated 1 files
+0 −2 src/mwindow.c
View
Binary file not shown.

0 comments on commit 6a43f62

Please sign in to comment.