Browse files

Rename methods to be more Cocoa-like.

General convention followed in this process:

- Any parameter to a method that is an actual Objective-C object has its full name (sans prefix) in the method declaration.  In other words, `initWithRepo:` becomes `initWithRepository:`, because the parameter is of type `GTRepository`.
- Methods that require a libgit primitive use a shortened version of the libgit type in the method declaration.  For example, creating a `GTObject` from a `git_object` means the method is named: `objectWithObj:inRepository:` (again, the second part of the selector having the type fully spelled out, because the second parameter is an object).  Likewise, if you have a `git_signature *`, you can turn it into a `GTSignature` using `+signatureWithSig:`.
- Methods that return an `NSDate` now have the word "date" in the selector (as opposed to "time").
- Class-level convenience methods that return a sha hash are named `shaByCreating[Type]...` to emphasize that the returned type is a string.
- A `<GTObject>` protocol has been created to type any object that has a readonly `GTRepository` property.  This is to help unify the disparate GT* objects that don't inherity from `GTObject`, yet have a `GTRepository` property.  The property is `readonly` to accomodate some classes exporting the property as `(nonatomic, readonly, assign)`.
- Methods that return arrays of objects have had the `listAll` prefix removed.
- `...AndReturnError:(NSError **)error` methods have been renamed to either `...WithError:` or just `error:` (as appropriate).
- Other general method name cleanup

Yes, most of these altered method names are much longer now, but they more strictly follow the Cocoa Naming Conventions and are much easier to understand.
  • Loading branch information...
1 parent 32a98cf commit 541a54109e94744c3df834cf2d592c4039ad55e4 @davedelong davedelong committed May 16, 2011
View
13 Classes/GTBlob.h
@@ -39,18 +39,19 @@
//
// These call the associated createInRepo: methods, but then lookup the newly
// created blob in the repo and return it
-+ (GTBlob *)blobInRepo:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error;
-+ (GTBlob *)blobInRepo:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error;
-+ (GTBlob *)blobInRepo:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error;
++ (GTBlob *)blobInRepository:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error;
++ (GTBlob *)blobInRepository:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error;
++ (GTBlob *)blobInRepository:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error;
// Create a blob in the specified repository
//
// returns the sha1 of the created blob or nil if an error occurred
-+ (NSString *)createInRepo:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error;
-+ (NSString *)createInRepo:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error;
-+ (NSString *)createInRepo:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error;
++ (NSString *)shaByCreatingBlobInRepository:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error;
++ (NSString *)shaByCreatingBlobInRepository:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error;
++ (NSString *)shaByCreatingBlobInRepository:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error;
- (NSInteger)size;
- (NSString *)content;
+- (NSData *)data;
@end
View
33 Classes/GTBlob.m
@@ -38,31 +38,31 @@ @implementation GTBlob
- (git_blob *)blob {
- return (git_blob *)self.object;
+ return (git_blob *)self.obj;
}
#pragma mark -
#pragma mark API
-+ (GTBlob *)blobInRepo:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error {
++ (GTBlob *)blobInRepository:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error {
- NSString *sha = [GTBlob createInRepo:theRepo content:content error:error];
- return sha ? (GTBlob *)[theRepo lookupBySha:sha type:GTObjectTypeBlob error:error] : nil;
+ NSString *sha = [GTBlob shaByCreatingBlobInRepository:theRepo content:content error:error];
+ return sha ? (GTBlob *)[theRepo lookupObjectBySha:sha type:GTObjectTypeBlob error:error] : nil;
}
-+ (GTBlob *)blobInRepo:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error {
++ (GTBlob *)blobInRepository:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error {
- NSString *sha = [GTBlob createInRepo:theRepo data:data error:error];
- return sha ? (GTBlob *)[theRepo lookupBySha:sha type:GTObjectTypeBlob error:error] : nil;
+ NSString *sha = [GTBlob shaByCreatingBlobInRepository:theRepo data:data error:error];
+ return sha ? (GTBlob *)[theRepo lookupObjectBySha:sha type:GTObjectTypeBlob error:error] : nil;
}
-+ (GTBlob *)blobInRepo:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error {
++ (GTBlob *)blobInRepository:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error {
- NSString *sha = [GTBlob createInRepo:theRepo file:file error:error];
- return sha ? (GTBlob *)[theRepo lookupBySha:sha type:GTObjectTypeBlob error:error] : nil;
+ NSString *sha = [GTBlob shaByCreatingBlobInRepository:theRepo file:file error:error];
+ return sha ? (GTBlob *)[theRepo lookupObjectBySha:sha type:GTObjectTypeBlob error:error] : nil;
}
-+ (NSString *)createInRepo:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error {
++ (NSString *)shaByCreatingBlobInRepository:(GTRepository *)theRepo content:(NSString *)content error:(NSError **)error {
git_oid oid;
int gitError = git_blob_create_frombuffer(&oid, theRepo.repo, [NSString utf8StringForString:content], content.length);
@@ -75,7 +75,7 @@ + (NSString *)createInRepo:(GTRepository *)theRepo content:(NSString *)content e
return [GTLib convertOidToSha:&oid];
}
-+ (NSString *)createInRepo:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error {
++ (NSString *)shaByCreatingBlobInRepository:(GTRepository *)theRepo data:(NSData *)data error:(NSError **)error {
git_oid oid;
int gitError = git_blob_create_frombuffer(&oid, theRepo.repo, [data bytes], data.length);
@@ -88,7 +88,7 @@ + (NSString *)createInRepo:(GTRepository *)theRepo data:(NSData *)data error:(NS
return [GTLib convertOidToSha:&oid];
}
-+ (NSString *)createInRepo:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error {
++ (NSString *)shaByCreatingBlobInRepository:(GTRepository *)theRepo file:(NSURL *)file error:(NSError **)error {
git_oid oid;
int gitError = git_blob_create_fromfile(&oid, theRepo.repo, [NSString utf8StringForString:[file path]]);
@@ -114,4 +114,11 @@ - (NSString *)content {
return [NSString stringForUTF8String:git_blob_rawcontent(self.blob)];
}
+- (NSData *)data {
+ NSInteger s = [self size];
+ if (s == 0) return [NSData data];
+
+ return [NSData dataWithBytes:git_blob_rawcontent(self.blob) length:s];
+}
+
@end
View
21 Classes/GTBranch.h
@@ -23,16 +23,24 @@
// THE SOFTWARE.
//
+#import "GTObject.h"
+
@class GTCommit;
@class GTReference;
@class GTRepository;
-@interface GTBranch : NSObject {}
+typedef enum {
+ GTBranchTypeLocal = 1,
+ GTBranchTypeRemote
+} GTBranchType;
+
+@interface GTBranch : NSObject <GTObject> {}
@property (nonatomic, readonly) NSString *name;
@property (nonatomic, readonly) NSString *shortName;
@property (nonatomic, readonly) NSString *sha;
@property (nonatomic, readonly) NSString *remoteName;
+@property (nonatomic, readonly) GTBranchType branchType;
@property (nonatomic, readonly, assign) GTRepository *repository;
@property (nonatomic, readonly, retain) GTReference *reference;
@property (nonatomic, retain) GTBranch *remoteBranch;
@@ -61,30 +69,27 @@
// error(out) - will be filled if an error occurs
//
// returns an NSArray of GTBranch objects or nil if an error occurred
-+ (NSArray *)listAllLocalBranchesInRepository:(GTRepository *)repo error:(NSError **)error;
++ (NSArray *)branchesInRepository:(GTRepository *)repo error:(NSError **)error;
// List all remote branches in a repository
//
// error(out) - will be filled if an error occurs
//
// returns an NSArray of GTBranch objects or nil if an error occurred
-+ (NSArray *)listAllRemoteBranchesInRepository:(GTRepository *)repo error:(NSError **)error;
++ (NSArray *)remoteBranchesInRepository:(GTRepository *)repo error:(NSError **)error;
// List all branches in a repository with the given prefix.
//
// error(out) - will be filled if an error occurs
//
// returns an NSArray of GTBranch objects or nil if an error occurred
-+ (NSArray *)listAllBranchesInRepository:(GTRepository *)repo withPrefix:(NSString *)prefix error:(NSError **)error;
++ (NSArray *)branchesInRepository:(GTRepository *)repo withPrefix:(NSString *)prefix error:(NSError **)error;
// Count all commits in this branch
//
// error(out) - will be filled if an error occurs
//
// returns number of commits in the branch or NSNotFound if an error occurred
-- (NSInteger)numberOfCommitsAndReturnError:(NSError **)error;
-
-- (BOOL)isRemote;
-- (BOOL)isLocal;
+- (NSInteger)numberOfCommitsWithError:(NSError **)error;
@end
View
39 Classes/GTBranch.m
@@ -85,7 +85,7 @@ - (NSString *)description {
- (id)initWithName:(NSString *)branchName repository:(GTRepository *)repo error:(NSError **)error {
if((self = [super init])) {
- self.reference = [GTReference referenceByLookingUpRef:branchName inRepo:repo error:error];
+ self.reference = [GTReference referenceByLookingUpReferencedNamed:branchName inRepository:repo error:error];
if(self.reference == nil) return nil;
self.repository = repo;
@@ -112,7 +112,7 @@ + (id)branchWithReference:(GTReference *)ref repository:(GTRepository *)repo {
+ (id)branchFromCurrentBranchInRepository:(GTRepository *)repo error:(NSError **)error {
- GTReference *head = [repo headAndReturnError:error];
+ GTReference *head = [repo headReference:error];
if (head == nil) return nil;
return [self branchWithReference:head repository:repo];
@@ -125,9 +125,9 @@ - (NSString *)name {
- (NSString *)shortName {
- if([self isLocal]) {
+ if([self branchType] == GTBranchTypeLocal) {
return [self.name stringByReplacingOccurrencesOfString:[[self class] localNamePrefix] withString:@""];
- } else if([self isRemote]) {
+ } else if([self branchType] == GTBranchTypeRemote) {
// remote repos also have their remote in their name
NSString *remotePath = [[[self class] remoteNamePrefix] stringByAppendingFormat:[NSString stringWithFormat:@"%@/", [self remoteName]]];
return [self.name stringByReplacingOccurrencesOfString:remotePath withString:@""];
@@ -143,7 +143,7 @@ - (NSString *)sha {
- (NSString *)remoteName {
- if(![self isRemote]) {
+ if([self branchType] == GTBranchTypeLocal) {
return [self.remoteBranch remoteName];
}
@@ -158,22 +158,22 @@ - (NSString *)remoteName {
- (GTCommit *)targetCommitAndReturnError:(NSError **)error {
- return (GTCommit *)[self.repository lookupBySha:self.sha error:error];
+ return (GTCommit *)[self.repository lookupObjectBySha:self.sha error:error];
}
-+ (NSArray *)listAllLocalBranchesInRepository:(GTRepository *)repo error:(NSError **)error {
++ (NSArray *)branchesInRepository:(GTRepository *)repo error:(NSError **)error {
- return [self listAllBranchesInRepository:repo withPrefix:[self localNamePrefix] error:error];
+ return [self branchesInRepository:repo withPrefix:[self localNamePrefix] error:error];
}
-+ (NSArray *)listAllRemoteBranchesInRepository:(GTRepository *)repo error:(NSError **)error {
++ (NSArray *)remoteBranchesInRepository:(GTRepository *)repo error:(NSError **)error {
static NSArray *unwantedRemoteBranches = nil;
if(unwantedRemoteBranches == nil) {
unwantedRemoteBranches = [NSArray arrayWithObjects:@"HEAD", nil];
}
- NSArray *remoteBranches = [self listAllBranchesInRepository:repo withPrefix:[self remoteNamePrefix] error:error];
+ NSArray *remoteBranches = [self branchesInRepository:repo withPrefix:[self remoteNamePrefix] error:error];
if(remoteBranches == nil) return nil;
NSMutableArray *filteredList = [NSMutableArray arrayWithCapacity:remoteBranches.count];
@@ -186,9 +186,9 @@ + (NSArray *)listAllRemoteBranchesInRepository:(GTRepository *)repo error:(NSErr
return filteredList;
}
-+ (NSArray *)listAllBranchesInRepository:(GTRepository *)repo withPrefix:(NSString *)prefix error:(NSError **)error {
++ (NSArray *)branchesInRepository:(GTRepository *)repo withPrefix:(NSString *)prefix error:(NSError **)error {
- NSArray *references = [GTReference listAllReferenceNamesInRepo:repo error:error];
+ NSArray *references = [GTReference referenceNamesInRepository:repo error:error];
if(references == nil) return nil;
NSMutableArray *branches = [NSMutableArray array];
@@ -202,24 +202,23 @@ + (NSArray *)listAllBranchesInRepository:(GTRepository *)repo withPrefix:(NSStri
return branches;
}
-- (NSInteger)numberOfCommitsAndReturnError:(NSError **)error {
+- (NSInteger)numberOfCommitsWithError:(NSError **)error {
return [self.repository.walker countFromSha:self.sha error:error];
}
-- (BOOL)isRemote {
- return [self.name hasPrefix:[[self class] remoteNamePrefix]];
-}
-
-- (BOOL)isLocal {
- return [self.name hasPrefix:[[self class] localNamePrefix]];
+- (GTBranchType)branchType {
+ if ([self.name hasPrefix:[[self class] remoteNamePrefix]]) {
+ return GTBranchTypeRemote;
+ }
+ return GTBranchTypeLocal;
}
- (GTBranch *)remoteBranch {
if(remoteBranch != nil) {
return remoteBranch;
- } else if([self isRemote]) {
+ } else if([self branchType] == GTBranchTypeRemote) {
return self;
}
View
36 Classes/GTCommit.h
@@ -41,28 +41,28 @@
@property (nonatomic, readonly) GTSignature *committer;
@property (nonatomic, readonly) NSArray *parents;
-+ (GTCommit *)commitInRepo:(GTRepository *)theRepo
- updateRefNamed:(NSString *)refName
- author:(GTSignature *)authorSig
- committer:(GTSignature *)committerSig
- message:(NSString *)newMessage
- tree:(GTTree *)theTree
- parents:(NSArray *)theParents
- error:(NSError **)error;
++ (GTCommit *)commitInRepository:(GTRepository *)theRepo
+ updateRefNamed:(NSString *)refName
+ author:(GTSignature *)authorSig
+ committer:(GTSignature *)committerSig
+ message:(NSString *)newMessage
+ tree:(GTTree *)theTree
+ parents:(NSArray *)theParents
+ error:(NSError **)error;
-+ (NSString *)createCommitInRepo:(GTRepository *)theRepo
- updateRefNamed:(NSString *)refName
- author:(GTSignature *)authorSig
- committer:(GTSignature *)committerSig
- message:(NSString *)newMessage
- tree:(GTTree *)theTree
- parents:(NSArray *)theParents
- error:(NSError **)error;
++ (NSString *)shaByCreatingCommitInRepository:(GTRepository *)theRepo
+ updateRefNamed:(NSString *)refName
+ author:(GTSignature *)authorSig
+ committer:(GTSignature *)committerSig
+ message:(NSString *)newMessage
+ tree:(GTTree *)theTree
+ parents:(NSArray *)theParents
+ error:(NSError **)error;
- (NSString *)message;
-- (NSString *)messageShort;
+- (NSString *)shortMessage;
- (NSString *)messageDetails;
-- (NSDate *)time;
+- (NSDate *)commitDate;
- (GTTree *)tree;
@end
View
26 Classes/GTCommit.m
@@ -40,7 +40,7 @@ @implementation GTCommit
- (git_commit *)commit {
- return (git_commit *)self.object;
+ return (git_commit *)self.obj;
}
#pragma mark -
@@ -50,7 +50,7 @@ - (git_commit *)commit {
@synthesize committer;
@synthesize parents;
-+ (GTCommit *)commitInRepo:(GTRepository *)theRepo
++ (GTCommit *)commitInRepository:(GTRepository *)theRepo
updateRefNamed:(NSString *)refName
author:(GTSignature *)authorSig
committer:(GTSignature *)committerSig
@@ -59,11 +59,11 @@ + (GTCommit *)commitInRepo:(GTRepository *)theRepo
parents:(NSArray *)theParents
error:(NSError **)error {
- NSString *sha = [GTCommit createCommitInRepo:theRepo updateRefNamed:refName author:authorSig committer:committerSig message:newMessage tree:theTree parents:theParents error:error];
- return sha ? (GTCommit *)[theRepo lookupBySha:sha type:GTObjectTypeCommit error:error] : nil;
+ NSString *sha = [GTCommit shaByCreatingCommitInRepository:theRepo updateRefNamed:refName author:authorSig committer:committerSig message:newMessage tree:theTree parents:theParents error:error];
+ return sha ? (GTCommit *)[theRepo lookupObjectBySha:sha type:GTObjectTypeCommit error:error] : nil;
}
-+ (NSString *)createCommitInRepo:(GTRepository *)theRepo
++ (NSString *)shaByCreatingCommitInRepository:(GTRepository *)theRepo
updateRefNamed:(NSString *)refName
author:(GTSignature *)authorSig
committer:(GTSignature *)committerSig
@@ -83,8 +83,8 @@ + (NSString *)createCommitInRepo:(GTRepository *)theRepo
&oid,
theRepo.repo,
refName ? [NSString utf8StringForString:refName] : NULL,
- authorSig.signature,
- committerSig.signature,
+ authorSig.sig,
+ committerSig.sig,
[NSString utf8StringForString:newMessage],
theTree.tree,
count,
@@ -103,7 +103,7 @@ - (NSString *)message {
return [NSString stringForUTF8String:s];
}
-- (NSString *)messageShort {
+- (NSString *)shortMessage {
const char *s = git_commit_message_short(self.commit);
return [NSString stringForUTF8String:s];
@@ -126,7 +126,7 @@ - (NSString *)messageDetails {
return result;
}
-- (NSDate *)time {
+- (NSDate *)commitDate {
time_t t = git_commit_time(self.commit);
return [NSDate dateWithTimeIntervalSince1970:t];
@@ -135,15 +135,15 @@ - (NSDate *)time {
- (GTSignature *)author {
if(author == nil) {
- author = [[GTSignature signatureWithSignature:(git_signature *)git_commit_author(self.commit)] retain];
+ author = [[GTSignature signatureWithSig:(git_signature *)git_commit_author(self.commit)] retain];
}
return author;
}
- (GTSignature *)committer {
if(committer == nil) {
- committer = [[GTSignature signatureWithSignature:(git_signature *)git_commit_committer(self.commit)] retain];
+ committer = [[GTSignature signatureWithSig:(git_signature *)git_commit_committer(self.commit)] retain];
}
return committer;
}
@@ -158,7 +158,7 @@ - (GTTree *)tree {
GTLog("Failed to get tree with error code: %d", gitError);
return nil;
}
- return (GTTree *)[GTObject objectInRepo:self.repo withObject:(git_object *)t];
+ return (GTTree *)[GTObject objectWithObj:(git_object *)t inRepository:self.repository];
}
- (NSArray *)parents {
@@ -169,7 +169,7 @@ - (NSArray *)parents {
// todo: do we care if a call to git_commit_parent fails?
git_commit *parent;
for(int i=0; git_commit_parent(&parent, self.commit, i) == GIT_SUCCESS; i++) {
- [rents addObject:(GTCommit *)[GTObject objectInRepo:self.repo withObject:(git_object *)parent]];
+ [rents addObject:(GTCommit *)[GTObject objectWithObj:(git_object *)parent inRepository:self.repository]];
}
parents = [[NSArray arrayWithArray:rents] retain];
View
6 Classes/GTIndex.h
@@ -43,14 +43,14 @@
+ (id)indexWithPath:(NSURL *)localFileUrl error:(NSError **)error;
- (id)initWithGitIndex:(git_index *)theIndex;
-+ (id)indexWithIndex:(git_index *)theIndex;
++ (id)indexWithGitIndex:(git_index *)theIndex;
// Refresh the index from the datastore
//
// error(out) - will be filled if an error occurs
//
// returns YES if refresh was successful
-- (BOOL)refreshAndReturnError:(NSError **)error;
+- (BOOL)refreshWithError:(NSError **)error;
// Clear the contents (all entry objects) of the index. This happens in memory.
// Changes can be written to the datastore by calling writeAndReturnError:
@@ -69,6 +69,6 @@
// error(out) - will be filled if an error occurs
//
// returns YES if the write was successful.
-- (BOOL)writeAndReturnError:(NSError **)error;
+- (BOOL)writeWithError:(NSError **)error;
@end
View
6 Classes/GTIndex.m
@@ -76,7 +76,7 @@ - (id)initWithGitIndex:(git_index *)theIndex; {
}
return self;
}
-+ (id)indexWithIndex:(git_index *)theIndex {
++ (id)indexWithGitIndex:(git_index *)theIndex {
return [[[self alloc] initWithGitIndex:theIndex] autorelease];
}
@@ -86,7 +86,7 @@ - (NSInteger)entryCount {
return git_index_entrycount(self.index);
}
-- (BOOL)refreshAndReturnError:(NSError **)error {
+- (BOOL)refreshWithError:(NSError **)error {
int gitError = git_index_read(self.index);
if(gitError != GIT_SUCCESS) {
@@ -135,7 +135,7 @@ - (BOOL)addFile:(NSString *)file error:(NSError **)error {
return YES;
}
-- (BOOL)writeAndReturnError:(NSError **)error {
+- (BOOL)writeWithError:(NSError **)error {
int gitError = git_index_write(self.index);
if(gitError != GIT_SUCCESS) {
View
4 Classes/GTIndexEntry.h
@@ -34,8 +34,8 @@
@property (nonatomic, assign) git_index_entry *entry;
@property (nonatomic, assign) NSString *path;
-@property (nonatomic, assign) NSDate *mTime;
-@property (nonatomic, assign) NSDate *cTime;
+@property (nonatomic, assign) NSDate *modificationDate;
+@property (nonatomic, assign) NSDate *creationDate;
@property (nonatomic, assign) long long fileSize;
@property (nonatomic, assign) NSUInteger dev;
@property (nonatomic, assign) NSUInteger ino;
View
12 Classes/GTIndexEntry.m
@@ -47,8 +47,8 @@ - (void)dealloc {
@synthesize entry;
@synthesize path;
-@synthesize mTime;
-@synthesize cTime;
+@synthesize modificationDate;
+@synthesize creationDate;
@synthesize fileSize;
@synthesize dev;
@synthesize ino;
@@ -108,24 +108,24 @@ - (BOOL)setSha:(NSString *)theSha error:(NSError **)error {
return YES;
}
-- (NSDate *)mTime {
+- (NSDate *)modificationDate {
double time = self.entry->mtime.seconds + (self.entry->mtime.nanoseconds/1000);
return [NSDate dateWithTimeIntervalSince1970:time];
}
-- (void)setMTime:(NSDate *)time {
+- (void)setModificationDate:(NSDate *)time {
NSTimeInterval t = [time timeIntervalSince1970];
self.entry->mtime.seconds = (int)t;
self.entry->mtime.nanoseconds = 1000 * (t - (int)t);
}
-- (NSDate *)cTime {
+- (NSDate *)creationDate {
double time = self.entry->ctime.seconds + (self.entry->ctime.nanoseconds/1000);
return [NSDate dateWithTimeIntervalSince1970:time];
}
-- (void)setCTime:(NSDate *)time {
+- (void)setCreationDate:(NSDate *)time {
NSTimeInterval t = [time timeIntervalSince1970];
self.entry->ctime.seconds = (int)t;
View
17 Classes/GTObject.h
@@ -46,17 +46,24 @@ typedef enum {
@class GTRepository;
@class GTOdbObject;
-@interface GTObject : NSObject {}
+@protocol GTObject <NSObject>
-@property (nonatomic, readonly) git_object *object;
+@required
+- (GTRepository *)repository;
+
+@end
+
+@interface GTObject : NSObject <GTObject> {}
+
+@property (nonatomic, readonly) git_object *obj;
@property (nonatomic, readonly) NSString *type;
@property (nonatomic, readonly) NSString *sha;
@property (nonatomic, readonly) NSString *shortSha;
-@property (nonatomic, assign) GTRepository *repo;
+@property (nonatomic, assign) GTRepository *repository;
// Convenience initializers
-- (id)initInRepo:(GTRepository *)theRepo withObject:(git_object *)theObject;
-+ (id)objectInRepo:(GTRepository *)theRepo withObject:(git_object *)theObject;
+- (id)initWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo;
++ (id)objectWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo;
// Read the raw object from the datastore
//
View
24 Classes/GTObject.m
@@ -46,7 +46,7 @@ @implementation GTObject
- (void)dealloc {
- self.repo = nil;
+ self.repository = nil;
[super dealloc];
}
@@ -59,26 +59,26 @@ - (BOOL)isEqual:(id)otherObject {
if(![otherObject isKindOfClass:[GTObject class]]) return NO;
- return 0 == git_oid_cmp(git_object_id(self.object), git_object_id(((GTObject *)otherObject).object)) ? YES : NO;
+ return 0 == git_oid_cmp(git_object_id(self.obj), git_object_id(((GTObject *)otherObject).obj)) ? YES : NO;
}
#pragma mark -
#pragma mark API
-@synthesize object;
+@synthesize obj;
@synthesize type;
@synthesize sha;
-@synthesize repo;
+@synthesize repository;
-- (id)initInRepo:(GTRepository *)theRepo withObject:(git_object *)theObject {
+- (id)initWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo {
if((self = [super init])) {
- self.repo = theRepo;
- object = theObject;
+ self.repository = theRepo;
+ obj = theObject;
}
return self;
}
-+ (id)objectInRepo:(GTRepository *)theRepo withObject:(git_object *)theObject {
++ (id)objectWithObj:(git_object *)theObject inRepository:(GTRepository *)theRepo {
NSString *klass;
git_otype t = git_object_type(theObject);
@@ -100,17 +100,17 @@ + (id)objectInRepo:(GTRepository *)theRepo withObject:(git_object *)theObject {
break;
}
- return [[[NSClassFromString(klass) alloc] initInRepo:theRepo withObject:theObject] autorelease];
+ return [[[NSClassFromString(klass) alloc] initWithObj:theObject inRepository:theRepo] autorelease];
}
- (NSString *)type {
- return [NSString stringForUTF8String:git_object_type2string(git_object_type(self.object))];
+ return [NSString stringForUTF8String:git_object_type2string(git_object_type(self.obj))];
}
- (NSString *)sha {
- return [GTLib convertOidToSha:git_object_id(self.object)];
+ return [GTLib convertOidToSha:git_object_id(self.obj)];
}
- (NSString *)shortSha {
@@ -120,7 +120,7 @@ - (NSString *)shortSha {
- (GTOdbObject *)readRawAndReturnError:(NSError **)error {
- return [self.repo rawRead:git_object_id(self.object) error:error];
+ return [self.repository rawRead:git_object_id(self.obj) error:error];
}
@end
View
2 Classes/GTOdbObject.h
@@ -16,7 +16,7 @@
- (id)initWithObject:(git_odb_object *)object;
+ (id)objectWithObject:(git_odb_object *)object;
-- (NSString *)hash;
+- (NSString *)shaHash;
- (GTObjectType)type;
- (NSUInteger)length;
- (NSData *)data;
View
2 Classes/GTOdbObject.m
@@ -34,7 +34,7 @@ + (id)objectWithObject:(git_odb_object *)object {
return [[[self alloc] initWithObject:object] autorelease];
}
-- (NSString *)hash {
+- (NSString *)shaHash {
return [GTLib convertOidToSha:git_odb_object_id(self.odbObject)];
}
View
27 Classes/GTReference.h
@@ -24,6 +24,7 @@
//
#import <git2.h>
+#import "GTObject.h"
typedef enum {
GTReferenceTypesOid = GIT_REF_OID, /** A reference which points at an object id */
@@ -35,22 +36,22 @@ typedef enum {
@class GTRepository;
-@interface GTReference : NSObject {}
+@interface GTReference : NSObject <GTObject> {}
@property (nonatomic, assign) git_reference *ref;
-@property (nonatomic, assign) GTRepository *repo;
+@property (nonatomic, assign) GTRepository *repository;
@property (nonatomic, readonly) NSString *type;
@property (nonatomic, readonly) const git_oid *oid;
// Convenience initializers
-+ (id)referenceByLookingUpRef:(NSString *)refName inRepo:(GTRepository *)theRepo error:(NSError **)error;
-- (id)initByLookingUpRef:(NSString *)refName inRepo:(GTRepository *)theRepo error:(NSError **)error;
++ (id)referenceByLookingUpReferencedNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error;
+- (id)initByLookingUpReferenceNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error;
-+ (id)referenceByCreatingRef:(NSString *)refName fromRef:(NSString *)target inRepo:(GTRepository *)theRepo error:(NSError **)error;
-- (id)initByCreatingRef:(NSString *)refName fromRef:(NSString *)target inRepo:(GTRepository *)theRepo error:(NSError **)error;
++ (id)referenceByCreatingReferenceNamed:(NSString *)refName fromReferenceTarget:(NSString *)target inRepository:(GTRepository *)theRepo error:(NSError **)error;
+- (id)initByCreatingReferenceNamed:(NSString *)refName fromReferenceTarget:(NSString *)target inRepository:(GTRepository *)theRepo error:(NSError **)error;
-+ (id)referenceByResolvingRef:(GTReference *)symbolicRef error:(NSError **)error;
-- (id)initByResolvingRef:(GTReference *)symbolicRef error:(NSError **)error;
++ (id)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
+- (id)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error;
// List references in a repository
//
@@ -60,7 +61,7 @@ typedef enum {
//
// returns an array of NSStrings holding the names of the references
// returns nil if an error occurred and fills the error parameter
-+ (NSArray *)listReferenceNamesInRepo:(GTRepository *)theRepo types:(GTReferenceTypes)types error:(NSError **)error;
++ (NSArray *)referenceNamesInRepository:(GTRepository *)theRepo types:(GTReferenceTypes)types error:(NSError **)error;
// List all references in a repository
//
@@ -71,7 +72,7 @@ typedef enum {
//
// returns an array of NSStrings holding the names of the references
// returns nil if an error occurred and fills the error parameter
-+ (NSArray *)listAllReferenceNamesInRepo:(GTRepository *)theRepo error:(NSError **)error;
++ (NSArray *)referenceNamesInRepository:(GTRepository *)theRepo error:(NSError **)error;
- (NSString *)target;
- (BOOL)setTarget:(NSString *)newTarget error:(NSError **)error;
@@ -83,20 +84,20 @@ typedef enum {
// error(out) - will be filled if an error occurs
//
// returns YES if the pack was successful
-- (BOOL)packAllAndReturnError:(NSError **)error;
+- (BOOL)packAllWithError:(NSError **)error;
// Delete this reference
//
// error(out) - will be filled if an error occurs
//
// returns YES if the delete was successful
-- (BOOL)deleteAndReturnError:(NSError **)error;
+- (BOOL)deleteWithError:(NSError **)error;
// Resolve this reference as a symbolic ref
//
// error(out) - will be filled if an error occurs
//
// returns the peeled GTReference or nil if an error occurred.
-- (GTReference *)resolveAndReturnError:(NSError **)error;
+- (GTReference *)resolvedReferenceWithError:(NSError **)error;
@end
View
52 Classes/GTReference.m
@@ -34,7 +34,7 @@ @implementation GTReference
- (void)dealloc {
- self.repo = nil;
+ self.repository = nil;
[super dealloc];
}
@@ -47,14 +47,14 @@ - (const git_oid *)oid {
#pragma mark API
@synthesize ref;
-@synthesize repo;
+@synthesize repository;
@synthesize type;
-- (id)initByLookingUpRef:(NSString *)refName inRepo:(GTRepository *)theRepo error:(NSError **)error {
+- (id)initByLookingUpReferenceNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error {
if((self = [super init])) {
- self.repo = theRepo;
- int gitError = git_reference_lookup(&ref, self.repo.repo, [NSString utf8StringForString:refName]);
+ self.repository = theRepo;
+ int gitError = git_reference_lookup(&ref, self.repository.repo, [NSString utf8StringForString:refName]);
if(gitError != GIT_SUCCESS) {
if(error != NULL)
*error = [NSError gitErrorForLookupRef:gitError];
@@ -63,28 +63,28 @@ - (id)initByLookingUpRef:(NSString *)refName inRepo:(GTRepository *)theRepo erro
}
return self;
}
-+ (id)referenceByLookingUpRef:(NSString *)refName inRepo:(GTRepository *)theRepo error:(NSError **)error {
++ (id)referenceByLookingUpReferencedNamed:(NSString *)refName inRepository:(GTRepository *)theRepo error:(NSError **)error {
- return [[[self alloc] initByLookingUpRef:refName inRepo:theRepo error:error] autorelease];
+ return [[[self alloc] initByLookingUpReferenceNamed:refName inRepository:theRepo error:error] autorelease];
}
-- (id)initByCreatingRef:(NSString *)refName fromRef:(NSString *)theTarget inRepo:(GTRepository *)theRepo error:(NSError **)error {
+- (id)initByCreatingReferenceNamed:(NSString *)refName fromReferenceTarget:(NSString *)theTarget inRepository:(GTRepository *)theRepo error:(NSError **)error {
if((self = [super init])) {
git_oid oid;
int gitError;
- self.repo = theRepo;
+ self.repository = theRepo;
if (git_oid_mkstr(&oid, [NSString utf8StringForString:theTarget]) == GIT_SUCCESS) {
gitError = git_reference_create_oid(&ref,
- self.repo.repo,
+ self.repository.repo,
[NSString utf8StringForString:refName],
&oid);
}
else {
gitError = git_reference_create_symbolic(&ref,
- self.repo.repo,
+ self.repository.repo,
[NSString utf8StringForString:refName],
[NSString utf8StringForString:theTarget]);
}
@@ -97,12 +97,12 @@ - (id)initByCreatingRef:(NSString *)refName fromRef:(NSString *)theTarget inRepo
}
return self;
}
-+ (id)referenceByCreatingRef:(NSString *)refName fromRef:(NSString *)target inRepo:(GTRepository *)theRepo error:(NSError **)error {
++ (id)referenceByCreatingReferenceNamed:(NSString *)refName fromReferenceTarget:(NSString *)target inRepository:(GTRepository *)theRepo error:(NSError **)error {
- return [[[self alloc] initByCreatingRef:refName fromRef:target inRepo:theRepo error:error] autorelease];
+ return [[[self alloc] initByCreatingReferenceNamed:refName fromReferenceTarget:target inRepository:theRepo error:error] autorelease];
}
-- (id)initByResolvingRef:(GTReference *)symbolicRef error:(NSError **)error {
+- (id)initByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error {
if((self = [super init])) {
@@ -112,13 +112,13 @@ - (id)initByResolvingRef:(GTReference *)symbolicRef error:(NSError **)error {
*error = [NSError gitErrorForResloveRef:gitError];
return nil;
}
- self.repo = symbolicRef.repo;
+ self.repository = symbolicRef.repository;
}
return self;
}
-+ (id)referenceByResolvingRef:(GTReference *)symbolicRef error:(NSError **)error {
++ (id)referenceByResolvingSymbolicReference:(GTReference *)symbolicRef error:(NSError **)error {
- return [[[self alloc] initByResolvingRef:symbolicRef error:error] autorelease];
+ return [[[self alloc] initByResolvingSymbolicReference:symbolicRef error:error] autorelease];
}
- (NSString *)name {
@@ -141,10 +141,10 @@ - (NSString *)type {
return [NSString stringForUTF8String:git_object_type2string(git_reference_type(self.ref))];
}
-+ (NSArray *)listReferenceNamesInRepo:(GTRepository *)theRepo types:(GTReferenceTypes)types error:(NSError **)error {
++ (NSArray *)referenceNamesInRepository:(GTRepository *)theRepo types:(GTReferenceTypes)types error:(NSError **)error {
NSParameterAssert(theRepo != nil);
- NSParameterAssert(theRepo.repo != nil);
+ NSParameterAssert(theRepo.repository != nil);
git_strarray array;
@@ -163,9 +163,9 @@ + (NSArray *)listReferenceNamesInRepo:(GTRepository *)theRepo types:(GTReference
return references;
}
-+ (NSArray *)listAllReferenceNamesInRepo:(GTRepository *)theRepo error:(NSError **)error {
++ (NSArray *)referenceNamesInRepository:(GTRepository *)theRepo error:(NSError **)error {
- return [self listReferenceNamesInRepo:theRepo types:GTReferenceTypesListAll error:error];
+ return [self referenceNamesInRepository:theRepo types:GTReferenceTypesListAll error:error];
}
- (NSString *)target {
@@ -204,9 +204,9 @@ - (BOOL)setTarget:(NSString *)newTarget error:(NSError **)error {
return YES;
}
-- (BOOL)packAllAndReturnError:(NSError **)error {
+- (BOOL)packAllWithError:(NSError **)error {
- int gitError = git_reference_packall(self.repo.repo);
+ int gitError = git_reference_packall(self.repository.repo);
if(gitError != GIT_SUCCESS) {
if(error != NULL)
*error = [NSError gitErrorForPackAllRefs:gitError];
@@ -215,7 +215,7 @@ - (BOOL)packAllAndReturnError:(NSError **)error {
return YES;
}
-- (BOOL)deleteAndReturnError:(NSError **)error {
+- (BOOL)deleteWithError:(NSError **)error {
int gitError = git_reference_delete(self.ref);
if(gitError != GIT_SUCCESS) {
@@ -227,9 +227,9 @@ - (BOOL)deleteAndReturnError:(NSError **)error {
return YES;
}
-- (GTReference *)resolveAndReturnError:(NSError **)error {
+- (GTReference *)resolvedReferenceWithError:(NSError **)error {
- return [GTReference referenceByResolvingRef:self error:error];
+ return [GTReference referenceByResolvingSymbolicReference:self error:error];
}
@end
View
27 Classes/GTRepository.h
@@ -28,18 +28,17 @@
//
#import <git2.h>
+#import "GTObject.h"
#import "GTWalker.h"
#import "GTReference.h"
-@class GTWalker;
-@class GTObject;
@class GTOdbObject;
@class GTCommit;
@class GTIndex;
@class GTBranch;
-@interface GTRepository : NSObject {}
+@interface GTRepository : NSObject <GTObject> {}
@property (nonatomic, assign, readonly) git_repository *repo;
@property (nonatomic, retain, readonly) NSURL *fileUrl;
@@ -62,10 +61,10 @@
+ (NSString *)hash:(NSString *)data type:(GTObjectType)type error:(NSError **)error;
// Lookup objects in the repo by oid or sha1
-- (GTObject *)lookupByOid:(git_oid *)oid type:(GTObjectType)type error:(NSError **)error;
-- (GTObject *)lookupByOid:(git_oid *)oid error:(NSError **)error;
-- (GTObject *)lookupBySha:(NSString *)sha type:(GTObjectType)type error:(NSError **)error;
-- (GTObject *)lookupBySha:(NSString *)sha error:(NSError **)error;
+- (GTObject *)lookupObjectByOid:(git_oid *)oid type:(GTObjectType)type error:(NSError **)error;
+- (GTObject *)lookupObjectByOid:(git_oid *)oid error:(NSError **)error;
+- (GTObject *)lookupObjectBySha:(NSString *)sha type:(GTObjectType)type error:(NSError **)error;
+- (GTObject *)lookupObjectBySha:(NSString *)sha error:(NSError **)error;
// Check to see if objects exist in the repo
- (BOOL)exists:(NSString *)sha error:(NSError **)error;
@@ -80,25 +79,25 @@
- (BOOL)walk:(NSString *)sha error:(NSError **)error block:(void (^)(GTCommit *commit, BOOL *stop))block;
- (NSArray *)selectCommitsStartingFrom:(NSString *)sha error:(NSError **)error block:(BOOL (^)(GTCommit *commit, BOOL *stop))block;
-- (BOOL)setupIndexAndReturnError:(NSError **)error;
+- (BOOL)setupIndex:(NSError **)error;
-- (GTReference *)headAndReturnError:(NSError **)error;
+- (GTReference *)headReference:(NSError **)error;
// Convenience methods to return references in this repository (see GTReference.h)
-- (NSArray *)listReferenceNamesOfTypes:(GTReferenceTypes)types error:(NSError **)error;
-- (NSArray *)listAllReferenceNamesAndReturnError:(NSError **)error;
+- (NSArray *)allReferenceNamesOfTypes:(GTReferenceTypes)types error:(NSError **)error;
+- (NSArray *)allReferenceNames:(NSError **)error;
// Convenience methods to return branches in the repository
-- (NSArray *)listAllBranchesAndReturnError:(NSError **)error;
+- (NSArray *)allBranches:(NSError **)error;
// Count all commits in the current branch (HEAD)
//
// error(out) - will be filled if an error occurs
//
// returns number of commits in the current branch or NSNotFound if an error occurred
-- (NSInteger)numberOfCommitsInCurrentBranchAndReturnError:(NSError **)error;
+- (NSInteger)numberOfCommitsInCurrentBranch:(NSError **)error;
-- (GTBranch *)createBranchFrom:(GTReference *)ref named:(NSString *)name error:(NSError **)error;
+- (GTBranch *)createBranchNamed:(NSString *)name fromReference:(GTReference *)ref error:(NSError **)error;
- (BOOL)isEmpty;
View
56 Classes/GTRepository.m
@@ -53,7 +53,7 @@ - (void)dealloc {
git_repository_free(self.repo);
self.fileUrl = nil;
- self.walker.repo = nil;
+ self.walker.repository = nil;
self.walker = nil;
self.index = nil;
[super dealloc];
@@ -160,7 +160,7 @@ + (NSString *)hash:(NSString *)data type:(GTObjectType)type error:(NSError **)er
}
-- (GTObject *)lookupByOid:(git_oid *)oid type:(GTObjectType)type error:(NSError **)error {
+- (GTObject *)lookupObjectByOid:(git_oid *)oid type:(GTObjectType)type error:(NSError **)error {
git_object *obj;
@@ -171,15 +171,15 @@ - (GTObject *)lookupByOid:(git_oid *)oid type:(GTObjectType)type error:(NSError
return nil;
}
- return [GTObject objectInRepo:self withObject:obj];
+ return [GTObject objectWithObj:obj inRepository:self];
}
-- (GTObject *)lookupByOid:(git_oid *)oid error:(NSError **)error {
+- (GTObject *)lookupObjectByOid:(git_oid *)oid error:(NSError **)error {
- return [self lookupByOid:oid type:GTObjectTypeAny error:error];
+ return [self lookupObjectByOid:oid type:GTObjectTypeAny error:error];
}
-- (GTObject *)lookupBySha:(NSString *)sha type:(GTObjectType)type error:(NSError **)error {
+- (GTObject *)lookupObjectBySha:(NSString *)sha type:(GTObjectType)type error:(NSError **)error {
git_oid oid;
@@ -190,12 +190,12 @@ - (GTObject *)lookupBySha:(NSString *)sha type:(GTObjectType)type error:(NSError
return nil;
}
- return [self lookupByOid:&oid type:type error:error];
+ return [self lookupObjectByOid:&oid type:type error:error];
}
-- (GTObject *)lookupBySha:(NSString *)sha error:(NSError **)error {
+- (GTObject *)lookupObjectBySha:(NSString *)sha error:(NSError **)error {
- return [self lookupBySha:sha type:GTObjectTypeAny error:error];
+ return [self lookupObjectBySha:sha type:GTObjectTypeAny error:error];
}
- (BOOL)exists:(NSString *)sha error:(NSError **)error {
@@ -291,7 +291,7 @@ - (BOOL)walk:(NSString *)sha sorting:(GTWalkerOptions)sortMode error:(NSError **
}
if(sha == nil) {
- GTReference *head = [self headAndReturnError:error];
+ GTReference *head = [self headReference:error];
if(head == nil) return NO;
sha = head.target;
}
@@ -332,7 +332,7 @@ - (NSArray *)selectCommitsStartingFrom:(NSString *)sha error:(NSError **)error b
}
}
-- (BOOL)setupIndexAndReturnError:(NSError **)error {
+- (BOOL)setupIndex:(NSError **)error {
git_index *i;
int gitError = git_repository_index(&i, self.repo);
@@ -342,34 +342,34 @@ - (BOOL)setupIndexAndReturnError:(NSError **)error {
return NO;
}
else {
- self.index = [GTIndex indexWithIndex:i];
+ self.index = [GTIndex indexWithGitIndex:i];
return YES;
}
}
-- (GTReference *)headAndReturnError:(NSError **)error {
+- (GTReference *)headReference:(NSError **)error {
- GTReference *headSymRef = [GTReference referenceByLookingUpRef:@"HEAD" inRepo:self error:error];
+ GTReference *headSymRef = [GTReference referenceByLookingUpReferencedNamed:@"HEAD" inRepository:self error:error];
if(headSymRef == nil) return nil;
- return [GTReference referenceByResolvingRef:headSymRef error:error];
+ return [GTReference referenceByResolvingSymbolicReference:headSymRef error:error];
}
-- (NSArray *)listReferenceNamesOfTypes:(GTReferenceTypes)types error:(NSError **)error {
+- (NSArray *)allReferenceNamesOfTypes:(GTReferenceTypes)types error:(NSError **)error {
- return [GTReference listReferenceNamesInRepo:self types:types error:error];
+ return [GTReference referenceNamesInRepository:self types:types error:error];
}
-- (NSArray *)listAllReferenceNamesAndReturnError:(NSError **)error {
+- (NSArray *)allReferenceNames:(NSError **)error {
- return [GTReference listAllReferenceNamesInRepo:self error:error];
+ return [GTReference referenceNamesInRepository:self error:error];
}
-- (NSArray *)listAllBranchesAndReturnError:(NSError **)error {
+- (NSArray *)allBranches:(NSError **)error {
NSMutableArray *allBranches = [NSMutableArray array];
- NSArray *localBranches = [GTBranch listAllLocalBranchesInRepository:self error:error];
- NSArray *remoteBranches = [GTBranch listAllRemoteBranchesInRepository:self error:error];
+ NSArray *localBranches = [GTBranch branchesInRepository:self error:error];
+ NSArray *remoteBranches = [GTBranch remoteBranchesInRepository:self error:error];
if(localBranches == nil || remoteBranches == nil) return nil;
[allBranches addObjectsFromArray:localBranches];
@@ -392,22 +392,26 @@ - (NSArray *)listAllBranchesAndReturnError:(NSError **)error {
return allBranches;
}
-- (NSInteger)numberOfCommitsInCurrentBranchAndReturnError:(NSError **)error {
+- (NSInteger)numberOfCommitsInCurrentBranch:(NSError **)error {
- GTReference *head = [self headAndReturnError:error];
+ GTReference *head = [self headReference:error];
if(head == nil) return NSNotFound;
return [self.walker countFromSha:head.target error:error];
}
-- (GTBranch *)createBranchFrom:(GTReference *)ref named:(NSString *)name error:(NSError **)error {
+- (GTBranch *)createBranchNamed:(NSString *)name fromReference:(GTReference *)ref error:(NSError **)error {
- GTReference *newRef = [GTReference referenceByCreatingRef:[NSString stringWithFormat:@"%@%@", [GTBranch localNamePrefix], name] fromRef:[ref target] inRepo:self error:error];
+ GTReference *newRef = [GTReference referenceByCreatingReferenceNamed:[NSString stringWithFormat:@"%@%@", [GTBranch localNamePrefix], name] fromReferenceTarget:[ref target] inRepository:self error:error];
return [GTBranch branchWithReference:newRef repository:self];
}
- (BOOL)isEmpty {
return git_repository_is_empty(self.repo);
}
+- (GTRepository *)repository {
+ return self;
+}
+
@end
View
6 Classes/GTSignature.h
@@ -32,14 +32,14 @@
@interface GTSignature : NSObject {}
-@property (nonatomic, assign) git_signature *signature;
+@property (nonatomic, assign) git_signature *sig;
@property (nonatomic, assign) NSString *name;
@property (nonatomic, assign) NSString *email;
@property (nonatomic, assign) NSDate *time;
// Convenience initializers
-- (id)initWithSignature:(git_signature *)theSignature;
-+ (id)signatureWithSignature:(git_signature *)theSignature;
+- (id)initWithSig:(git_signature *)theSignature;
++ (id)signatureWithSig:(git_signature *)theSignature;
- (id)initWithName:(NSString *)theName email:(NSString *)theEmail time:(NSDate *)theTime;
+ (id)signatureWithName:(NSString *)theName email:(NSString *)theEmail time:(NSDate *)theTime;
View
28 Classes/GTSignature.m
@@ -51,27 +51,27 @@ - (NSString *)description {
#pragma mark -
#pragma mark API
-@synthesize signature;
+@synthesize sig;
@synthesize name;
@synthesize email;
@synthesize time;
-- (id)initWithSignature:(git_signature *)theSignature {
+- (id)initWithSig:(git_signature *)theSignature {
if((self = [self init])) {
- self.signature = theSignature;
+ self.sig = theSignature;
}
return self;
}
-+ (id)signatureWithSignature:(git_signature *)theSignature {
++ (id)signatureWithSig:(git_signature *)theSignature {
- return [[[self alloc] initWithSignature:theSignature] autorelease];
+ return [[[self alloc] initWithSig:theSignature] autorelease];
}
- (id)initWithName:(NSString *)theName email:(NSString *)theEmail time:(NSDate *)theTime {
if((self = [super init])) {
- self.signature = git_signature_new(
+ self.sig = git_signature_new(
[NSString utf8StringForString:theName],
[NSString utf8StringForString:theEmail],
[theTime timeIntervalSince1970],
@@ -87,31 +87,31 @@ + (id)signatureWithName:(NSString *)theName email:(NSString *)theEmail time:(NSD
- (NSString *)name {
- return [NSString stringForUTF8String:self.signature->name];
+ return [NSString stringForUTF8String:self.sig->name];
}
- (void)setName:(NSString *)n {
- free(self.signature->name);
- self.signature->name = strdup([n cStringUsingEncoding:NSUTF8StringEncoding]);
+ free(self.sig->name);
+ self.sig->name = strdup([n cStringUsingEncoding:NSUTF8StringEncoding]);
}
- (NSString *)email {
- return [NSString stringForUTF8String:self.signature->email];
+ return [NSString stringForUTF8String:self.sig->email];
}
- (void)setEmail:(NSString *)e {
- free(self.signature->email);
- self.signature->email = strdup([e cStringUsingEncoding:NSUTF8StringEncoding]);
+ free(self.sig->email);
+ self.sig->email = strdup([e cStringUsingEncoding:NSUTF8StringEncoding]);
}
- (NSDate *)time {
- return [NSDate dateWithTimeIntervalSince1970:self.signature->when.time];
+ return [NSDate dateWithTimeIntervalSince1970:self.sig->when.time];
}
- (void)setTime:(NSDate *)d {
- self.signature->when.time = [d timeIntervalSince1970];
+ self.sig->when.time = [d timeIntervalSince1970];
}
@end
View
4 Classes/GTTag.h
@@ -39,8 +39,8 @@
@property (nonatomic, readonly) git_tag *tag;
@property (nonatomic, readonly) GTSignature *tagger;
-+ (GTTag *)tagInRepo:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error;
-+ (NSString *)createTagInRepo:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error;
++ (GTTag *)tagInRepository:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error;
++ (NSString *)shaByCreatingTagInRepository:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error;
- (NSString *)message;
- (NSString *)name;
View
16 Classes/GTTag.m
@@ -40,24 +40,24 @@ @implementation GTTag
- (git_tag *)tag {
- return (git_tag *)self.object;
+ return (git_tag *)self.obj;
}
#pragma mark -
#pragma mark API
@synthesize tagger;
-+ (GTTag *)tagInRepo:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error {
++ (GTTag *)tagInRepository:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error {
- NSString *sha = [GTTag createTagInRepo:theRepo name:tagName target:theTarget tagger:theTagger message:theMessage error:error];
- return sha ? (GTTag *)[theRepo lookupBySha:sha type:GTObjectTypeTag error:error] : nil;
+ NSString *sha = [GTTag shaByCreatingTagInRepository:theRepo name:tagName target:theTarget tagger:theTagger message:theMessage error:error];
+ return sha ? (GTTag *)[theRepo lookupObjectBySha:sha type:GTObjectTypeTag error:error] : nil;
}
-+ (NSString *)createTagInRepo:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error {
++ (NSString *)shaByCreatingTagInRepository:(GTRepository *)theRepo name:(NSString *)tagName target:(GTObject *)theTarget tagger:(GTSignature *)theTagger message:(NSString *)theMessage error:(NSError **)error {
git_oid oid;
- int gitError = git_tag_create_o(&oid, theRepo.repo, [NSString utf8StringForString:tagName], theTarget.object, theTagger.signature, [NSString utf8StringForString:theMessage]);
+ int gitError = git_tag_create_o(&oid, theRepo.repo, [NSString utf8StringForString:tagName], theTarget.obj, theTagger.sig, [NSString utf8StringForString:theMessage]);
if(gitError != GIT_SUCCESS) {
if(error != NULL)
*error = [NSError gitErrorFor:gitError withDescription:@"Failed to create tag in repository"];
@@ -83,7 +83,7 @@ - (GTObject *)target {
// todo: might want to actually return an error here
int gitError = git_tag_target(&t, self.tag);
if(gitError != GIT_SUCCESS) return nil;
- return [GTObject objectInRepo:self.repo withObject:(git_object *)t];
+ return [GTObject objectWithObj:(git_object *)t inRepository:self.repository];
}
- (NSString *)targetType {
@@ -94,7 +94,7 @@ - (NSString *)targetType {
- (GTSignature *)tagger {
if(tagger == nil) {
- tagger = [GTSignature signatureWithSignature:(git_signature *)git_tag_tagger(self.tag)];
+ tagger = [GTSignature signatureWithSig:(git_signature *)git_tag_tagger(self.tag)];
}
return tagger;
}
View
4 Classes/GTTree.h
@@ -40,7 +40,7 @@
// Get the number of entries
//
// returns the number of entries in this tree
-- (NSInteger)entryCount;
+- (NSInteger)numberOfEntries;
// Get a entry at the specified index
//
@@ -54,7 +54,7 @@
// name - the name of the entry
//
// returns a GTTreeEntry or nil if there is nothing with the specified name
-- (GTTreeEntry *)entryByName:(NSString *)name;
+- (GTTreeEntry *)entryWithName:(NSString *)name;
/*
// Add an entry to the index
View
6 Classes/GTTree.m
@@ -38,13 +38,13 @@ @implementation GTTree
- (git_tree *)tree {
- return (git_tree *)self.object;
+ return (git_tree *)self.obj;
}
#pragma mark -
#pragma mark API
-- (NSInteger)entryCount {
+- (NSInteger)numberOfEntries {
return [[NSNumber numberWithInt:git_tree_entrycount(self.tree)] integerValue];
}
@@ -59,7 +59,7 @@ - (GTTreeEntry *)entryAtIndex:(NSInteger)index {
return [self createEntryWithEntry:git_tree_entry_byindex(self.tree, index)];
}
-- (GTTreeEntry *)entryByName:(NSString *)name {
+- (GTTreeEntry *)entryWithName:(NSString *)name {
return [self createEntryWithEntry:git_tree_entry_byname(self.tree, [NSString utf8StringForString:name])];
}
View
12 Classes/GTTreeEntry.h
@@ -28,12 +28,11 @@
//
#import <git2.h>
-
+#import "GTObject.h"
@class GTTree;
-@class GTObject;
-@interface GTTreeEntry : NSObject {}
+@interface GTTreeEntry : NSObject <GTObject> {}
@property (nonatomic, assign, readonly) const git_tree_entry *entry;
@property (nonatomic, assign, readonly) GTTree *tree;
@@ -53,3 +52,10 @@
- (GTObject *)toObjectAndReturnError:(NSError **)error;
@end
+
+@interface GTObject (GTTreeEntry)
+
++ (id)objectWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error;
+- (id)initWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error;
+
+@end
View
37 Classes/GTTreeEntry.m
@@ -83,17 +83,34 @@ - (NSString *)sha {
return [GTLib convertOidToSha:git_tree_entry_id(self.entry)];
}
+- (GTRepository *)repository {
+ return self.tree.repository;
+}
+
- (GTObject *)toObjectAndReturnError:(NSError **)error {
-
- git_object *obj;
- int gitError = git_tree_entry_2object(&obj, self.tree.repo.repo, self.entry);
- if(gitError != GIT_SUCCESS) {
- if(error != NULL)
- *error = [NSError gitErrorForTreeEntryToObject:gitError];
- return nil;
- }
-
- return [GTObject objectInRepo:self.tree.repo withObject:obj];
+ return [GTObject objectWithTreeEntry:self error:error];
+}
+
+@end
+
+@implementation GTObject (GTTreeEntry)
+
++ (id)objectWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error {
+ return [[[self alloc] initWithTreeEntry:treeEntry error:error] autorelease];
+}
+
+- (id)initWithTreeEntry:(GTTreeEntry *)treeEntry error:(NSError **)error {
+ git_object *obj;
+ int gitError = git_tree_entry_2object(&obj, treeEntry.repository.repo, treeEntry.entry);
+ if (gitError != GIT_SUCCESS) {
+ if (error != NULL) {
+ *error = [NSError gitErrorForTreeEntryToObject:gitError];
+ }
+ [self release];
+ return nil;
+ }
+
+ return [self initWithObj:obj inRepository:treeEntry.repository];
}
@end
View
5 Classes/GTWalker.h
@@ -40,13 +40,14 @@ typedef enum {
@class GTRepository;
@class GTCommit;
+@protocol GTObject;
// This object is usually used from within a repository. You generally don't
// need to instantiate a GTWalker. Instead, use the walker property on
// GTRepository
-@interface GTWalker : NSObject {}
+@interface GTWalker : NSObject <GTObject> {}
-@property (nonatomic, assign) GTRepository *repo;
+@property (nonatomic, assign) GTRepository *repository;
- (id)initWithRepository:(GTRepository *)theRepo error:(NSError **)error;
+ (id)walkerWithRepository:(GTRepository *)theRepo error:(NSError **)error;
View
10 Classes/GTWalker.m
@@ -43,22 +43,22 @@ @implementation GTWalker
- (void)dealloc {
git_revwalk_free(self.walk);
- self.repo = nil;
+ self.repository = nil;
[super dealloc];
}
#pragma mark -
#pragma mark API
-@synthesize repo;
+@synthesize repository;
@synthesize walk;
- (id)initWithRepository:(GTRepository *)theRepo error:(NSError **)error {
if((self = [super init])) {
- self.repo = theRepo;
+ self.repository = theRepo;
git_revwalk *w;
- int gitError = git_revwalk_new(&w, self.repo.repo);
+ int gitError = git_revwalk_new(&w, self.repository.repo);
if(gitError != GIT_SUCCESS) {
if (error != NULL)
*error = [NSError gitErrorForInitRevWalker:gitError];
@@ -124,7 +124,7 @@ - (GTCommit *)next {
return nil;
// ignore error if we can't lookup object and just return nil
- return (GTCommit *)[self.repo lookupBySha:[GTLib convertOidToSha:&oid] type:GTObjectTypeCommit error:nil];
+ return (GTCommit *)[self.repository lookupObjectBySha:[GTLib convertOidToSha:&oid] type:GTObjectTypeCommit error:nil];
}
- (NSInteger)countFromSha:(NSString *)sha error:(NSError **)error {
View
8 Tests/GTBlobTest.m
@@ -48,7 +48,7 @@ - (void)setUp {
- (void)testCanReadBlobData {
NSError *error = nil;
- GTBlob *blob = (GTBlob *)[repo lookupBySha:sha error:&error];
+ GTBlob *blob = (GTBlob *)[repo lookupObjectBySha:sha error:&error];
GHAssertEquals(9, (int)blob.size, nil);
GHAssertEqualStrings(@"new file\n", blob.content, nil);
GHAssertEqualStrings(@"blob", blob.type, nil);
@@ -76,7 +76,7 @@ - (void)testCanRewriteBlobData {
- (void)testCanWriteNewBlobData {
NSError *error = nil;
- NSString *newSha = [GTBlob createInRepo:repo content:@"a new blob content" error:&error];
+ NSString *newSha = [GTBlob shaByCreatingBlobInRepository:repo content:@"a new blob content" error:&error];
GHAssertNotNil(newSha, [error localizedDescription]);
rm_loose(newSha);
@@ -85,7 +85,7 @@ - (void)testCanWriteNewBlobData {
- (void)testCanWriteNewBlobData2 {
NSError *error = nil;
- GTBlob *blob = [GTBlob blobInRepo:repo content:@"a new blob content" error:&error];
+ GTBlob *blob = [GTBlob blobInRepository:repo content:@"a new blob content" error:&error];
GHAssertNotNil(blob, [error localizedDescription]);
rm_loose(blob.sha);
@@ -98,7 +98,7 @@ - (void)testCanGetCompleteContentWithNulls {
NSData *content = [NSData dataWithBytes:bytes length:sizeof(bytes)];
- NSString *newSha = [GTBlob createInRepo:repo data:content error:&error];
+ NSString *newSha = [GTBlob shaByCreatingBlobInRepository:repo data:content error:&error];
GHAssertNotNil(newSha, [error localizedDescription]);
rm_loose(newSha);
View
10 Tests/GTBranchTest.m
@@ -33,28 +33,28 @@ - (void)testCanOpenHeadInRepo {
- (void)testCanListLocalBranchesInRepo {
NSError *error = nil;
- NSArray *branches = [GTBranch listAllLocalBranchesInRepository:repo error:&error];
+ NSArray *branches = [GTBranch branchesInRepository:repo error:&error];
GHAssertNotNil(branches, [error localizedDescription], nil);
GHAssertEquals(2, (int)branches.count, nil);
}
- (void)testCanListRemoteBranchesInRepo {
NSError *error = nil;
- NSArray *branches = [GTBranch listAllRemoteBranchesInRepository:repo error:&error];
+ NSArray *branches = [GTBranch remoteBranchesInRepository:repo error:&error];
GHAssertNotNil(branches, [error localizedDescription], nil);
GHAssertEquals(0, (int)branches.count, nil);
}
- (void)testCanCountCommitsInBranch {
NSError *error = nil;
- GTReference *head = [repo headAndReturnError:&error];
+ GTReference *head = [repo headReference:&error];
GHAssertNotNil(head, [error localizedDescription]);
GTBranch *master = [GTBranch branchWithReference:head repository:repo];
GHAssertNotNil(master, [error localizedDescription]);
- NSUInteger n = [master numberOfCommitsAndReturnError:&error];
+ NSUInteger n = [master numberOfCommitsWithError:&error];
GHAssertNotEquals(n, (NSUInteger)NSNotFound, [error localizedDescription]);
GHAssertEquals((NSUInteger)3, n, nil);
}
@@ -65,7 +65,7 @@ - (void)testRetainOfBranchCreatedWithRef {
// This allows us to release the object and test that the branch
// is retaining properly.
NSError *error = nil;
- GTReference *head = [[GTReference alloc] initByLookingUpRef:@"HEAD" inRepo:repo error:&error];
+ GTReference *head = [[GTReference alloc] initByLookingUpReferenceNamed:@"HEAD" inRepository:repo error:&error];
GHAssertNotNil(head, [error localizedDescription]);
GTBranch *current = [GTBranch branchWithReference:head repository:repo];
GHAssertNotNil(current, [error localizedDescription]);
View
16 Tests/GTCommitTest.m
@@ -49,7 +49,7 @@ - (void)testCanReadCommitData {
NSString *sha = @"8496071c1b46c854b31185ea97743be6a8774479";
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:sha error:&error];
+ GTObject *obj = [repo lookupObjectBySha:sha error:&error];
GHAssertNil(error, [error localizedDescription]);
GHAssertNotNil(obj, nil);
@@ -81,7 +81,7 @@ - (void)testCanHaveMultipleParents {
NSString *sha = @"a4a7dce85cf63874e984719f4fdd239f5145052f";
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:sha error:&error];
+ GTObject *obj = [repo lookupObjectBySha:sha error:&error];
GHAssertNil(error, [error localizedDescription]);
GHAssertNotNil(obj, nil);
@@ -94,10 +94,10 @@ - (void)testCanWriteCommitData {
NSError *error = nil;
NSString *sha = @"8496071c1b46c854b31185ea97743be6a8774479";
- GTCommit *obj = (GTCommit *)[repo lookupBySha:sha error:&error];
+ GTCommit *obj = (GTCommit *)[repo lookupObjectBySha:sha error:&error];
GHAssertNotNil(obj, [error localizedDescription]);
- NSString *newSha = [GTCommit createCommitInRepo:repo
+ NSString *newSha = [GTCommit shaByCreatingCommitInRepository:repo
updateRefNamed:nil
author:obj.author
committer:obj.committer
@@ -115,7 +115,7 @@ - (void)testCanWriteNewCommitData {
NSString *tsha = @"c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b";
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:tsha error:&error];
+ GTObject *obj = [repo lookupObjectBySha:tsha error:&error];
GHAssertNil(error, [error localizedDescription]);
GHAssertNotNil(obj, nil);
@@ -125,7 +125,7 @@ - (void)testCanWriteNewCommitData {
initWithName:@"Tim"
email:@"tclem@github.com"
time:[NSDate date]] autorelease];
- GTCommit *commit = [GTCommit commitInRepo:repo updateRefNamed:nil author:person committer:person message:@"new message" tree:tree parents:nil error:&error];
+ GTCommit *commit = [GTCommit commitInRepository:repo updateRefNamed:nil author:person committer:person message:@"new message" tree:tree parents:nil error:&error];
GHAssertNotNil(commit, [error localizedDescription]);
GHTestLog(@"wrote sha %@", commit.sha);
@@ -136,7 +136,7 @@ - (void)testCanHandleNilWrites {
NSString *tsha = @"c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b";
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:tsha error:&error];
+ GTObject *obj = [repo lookupObjectBySha:tsha error:&error];
GHAssertNil(error, [error localizedDescription]);
GHAssertNotNil(obj, nil);
@@ -146,7 +146,7 @@ - (void)testCanHandleNilWrites {
initWithName:@"Tim"
email:@"tclem@github.com"
time:[NSDate date]] autorelease];
- GTCommit *commit = [GTCommit commitInRepo:repo updateRefNamed:nil author:person committer:person message:nil tree:tree parents:nil error:&error];
+ GTCommit *commit = [GTCommit commitInRepository:repo updateRefNamed:nil author:person committer:person message:nil tree:tree parents:nil error:&error];
GHAssertNotNil(commit, [error localizedDescription]);
GHTestLog(@"wrote sha %@", commit.sha);
View
24 Tests/GTIndexTest.m
@@ -44,7 +44,7 @@ - (void)setUp {
NSError *error = nil;
index = [GTIndex indexWithPath:[NSURL fileURLWithPath:TEST_INDEX_PATH()] error:&error];
- BOOL success = [index refreshAndReturnError:&error];
+ BOOL success = [index refreshWithError:&error];
GHAssertTrue(success, [error localizedDescription]);
}
@@ -66,8 +66,8 @@ - (void)testCanGetAllDataFromAnEntry {
GHAssertNotNil(e, nil);
GHAssertEqualStrings(@"README", e.path, nil);
GHAssertEqualStrings(@"1385f264afb75a56a5bec74243be9b367ba4ca08", e.sha, nil);
- GHAssertEquals(1273360380, (int)[e.mTime timeIntervalSince1970], nil);
- GHAssertEquals(1273360380, (int)[e.cTime timeIntervalSince1970], nil);
+ GHAssertEquals(1273360380, (int)[e.modificationDate timeIntervalSince1970], nil);
+ GHAssertEquals(1273360380, (int)[e.creationDate timeIntervalSince1970], nil);
GHAssertEquals((long long)4, e.fileSize, nil);
GHAssertEquals((NSUInteger)234881026, e.dev, nil);
GHAssertEquals((NSUInteger)6674088, e.ino, nil);
@@ -91,8 +91,8 @@ - (GTIndexEntry *)createNewIndexEntry {
e.path = @"new_path";
BOOL success = [e setSha:@"d385f264afb75a56a5bec74243be9b367ba4ca08" error:&error];
GHAssertTrue(success, [error localizedDescription]);
- e.mTime = now;
- e.cTime = now;
+ e.modificationDate = now;
+ e.creationDate = now;
e.fileSize = 1000;
e.dev = 234881027;
e.ino = 88888;
@@ -128,8 +128,8 @@ - (void)testCanUpdateEntries {
e.path = @"new_path";
BOOL success = [e setSha:@"12ea3153a78002a988bb92f4123e7e831fd1138a" error:&error];
GHAssertTrue(success, [error localizedDescription]);
- e.mTime = now;
- e.cTime = now;
+ e.modificationDate = now;
+ e.creationDate = now;
e.fileSize = 1000;
e.dev = 234881027;
e.ino = 88888;
@@ -140,8 +140,8 @@ - (void)testCanUpdateEntries {
GHAssertEqualStrings(@"new_path", e.path, nil);
GHAssertEqualStrings(@"12ea3153a78002a988bb92f4123e7e831fd1138a", e.sha, nil);
- GHAssertEquals((int)[now timeIntervalSince1970], (int)[e.mTime timeIntervalSince1970], nil);
- GHAssertEquals((int)[now timeIntervalSince1970], (int)[e.cTime timeIntervalSince1970], nil);
+ GHAssertEquals((int)[now timeIntervalSince1970], (int)[e.modificationDate timeIntervalSince1970], nil);
+ GHAssertEquals((int)[now timeIntervalSince1970], (int)[e.creationDate timeIntervalSince1970], nil);
GHAssertEquals((long long)1000, e.fileSize, nil);
GHAssertEquals((NSUInteger)234881027, e.dev, nil);
GHAssertEquals((NSUInteger)88888, e.ino, nil);
@@ -179,7 +179,7 @@ - (void)createTempPath {
wIndex = [GTIndex indexWithPath:tempPath error:&error];
GHAssertNil(error, [error localizedDescription]);
- BOOL success = [wIndex refreshAndReturnError:&error];
+ BOOL success = [wIndex refreshWithError:&error];
GHAssertTrue(success, [error localizedDescription]);
}
@@ -194,12 +194,12 @@ - (void)testCanWriteNewIndex {
e.path = @"else.txt";
success = [wIndex addEntry:e error:&error];
GHAssertTrue(success, [error localizedDescription]);
- success = [wIndex writeAndReturnError:&error];
+ success = [wIndex writeWithError:&error];
GHAssertTrue(success, [error localizedDescription]);
GTIndex *index2 = [GTIndex indexWithPath:tempPath error:&error];
GHAssertNil(error, [error localizedDescription]);
- success = [index2 refreshAndReturnError:&error];
+ success = [index2 refreshWithError:&error];
GHAssertTrue(success, [error localizedDescription]);
GHAssertEquals(4, (int)[index2 entryCount], nil);
}
View
12 Tests/GTObjectTest.m
@@ -46,7 +46,7 @@ - (void)setUpClass {
- (void)testCanLookupEmptyStringFails {
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:@"" error:&error];
+ GTObject *obj = [repo lookupObjectBySha:@"" error:&error];
GHAssertNotNil(error, nil);
GHAssertNil(obj, nil);
@@ -56,7 +56,7 @@ - (void)testCanLookupEmptyStringFails {
- (void)testCanLookupBadObjectFails {
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:@"a496071c1b46c854b31185ea97743be6a8774479" error:&error];
+ GTObject *obj = [repo lookupObjectBySha:@"a496071c1b46c854b31185ea97743be6a8774479" error:&error];
GHAssertNotNil(error, nil);
GHAssertNil(obj, nil);
@@ -66,7 +66,7 @@ - (void)testCanLookupBadObjectFails {
- (void)testCanLookupAnObject {
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
+ GTObject *obj = [repo lookupObjectBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
GHAssertNil(error, [error localizedDescription]);
GHAssertNotNil(obj, nil);
@@ -77,8 +77,8 @@ - (void)testCanLookupAnObject {
- (void)testTwoObjectsAreTheSame {
NSError *error = nil;
- GTObject *obj1 = [repo lookupBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
- GTObject *obj2 = [repo lookupBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
+ GTObject *obj1 = [repo lookupObjectBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
+ GTObject *obj2 = [repo lookupObjectBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
GHAssertNotNil(obj1, nil);
GHAssertNotNil(obj2, nil);
@@ -88,7 +88,7 @@ - (void)testTwoObjectsAreTheSame {
- (void)testCanReadRawDataFromObject {
NSError *error = nil;
- GTObject *obj = [repo lookupBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
+ GTObject *obj = [repo lookupObjectBySha:@"8496071c1b46c854b31185ea97743be6a8774479" error:&error];
GHAssertNotNil(obj, nil);
View
28 Tests/GTReferenceTest.m
@@ -26,7 +26,7 @@ - (void)testCanOpenRef {
NSError *error = nil;
GTRepository *repo = [GTRepository repoByOpeningRepositoryInDirectory:[NSURL fileURLWithPath:TEST_REPO_PATH()] error:&error];
GHAssertNil(error, [error localizedDescription]);
- GTReference *ref = [GTReference referenceByLookingUpRef:@"refs/heads/master" inRepo:repo error:&error];
+ GTReference *ref = [GTReference referenceByLookingUpReferencedNamed:@"refs/heads/master" inRepository:repo error:&error];
GHAssertNil(error, [error localizedDescription]);
GHAssertNotNil(ref, nil);