forked from libgit2/objective-git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
914 additions
and
852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// GTOdbObject.h | ||
// ObjectiveGitFramework | ||
// | ||
// Created by Timothy Clem on 3/23/11. | ||
// Copyright 2011 GitHub, Inc. All rights reserved. | ||
// | ||
|
||
#import <git2.h> | ||
#import "GTObject.h" | ||
|
||
@interface GTOdbObject : NSObject {} | ||
|
||
@property (nonatomic, assign, readonly) git_odb_object *odbObject; | ||
|
||
- (id)initWithObject:(git_odb_object *)object; | ||
+ (id)objectWithObject:(git_odb_object *)object; | ||
|
||
- (NSString *)hash; | ||
- (GTObjectType)type; | ||
- (NSUInteger)length; | ||
- (NSData *)data; | ||
- (NSString *)dataAsUTF8String; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// GTOdbObject.m | ||
// ObjectiveGitFramework | ||
// | ||
// Created by Timothy Clem on 3/23/11. | ||
// Copyright 2011 GitHub, Inc. All rights reserved. | ||
// | ||
|
||
#import "GTOdbObject.h" | ||
#import "GTLib.h" | ||
#import "NSString+Git.h" | ||
|
||
@interface GTOdbObject() | ||
@property (nonatomic, assign) git_odb_object *odbObject; | ||
@end | ||
|
||
@implementation GTOdbObject | ||
|
||
#pragma mark API | ||
@synthesize odbObject; | ||
|
||
- (id)initWithObject:(git_odb_object *)object { | ||
|
||
if((self = [super init])) { | ||
self.odbObject = object; | ||
} | ||
return self; | ||
} | ||
|
||
+ (id)objectWithObject:(git_odb_object *)object { | ||
|
||
return [[[self alloc] initWithObject:object] autorelease]; | ||
} | ||
|
||
- (NSString *)hash { | ||
|
||
return [GTLib convertOidToSha:git_odb_object_id(self.odbObject)]; | ||
} | ||
|
||
- (GTObjectType)type { | ||
|
||
return git_odb_object_type(self.odbObject); | ||
} | ||
|
||
- (NSUInteger)length { | ||
|
||
return git_odb_object_size(self.odbObject); | ||
} | ||
|
||
- (NSData *)data { | ||
|
||
return [NSData dataWithBytes:git_odb_object_data(self.odbObject) length:[self length]]; | ||
} | ||
|
||
- (NSString *)dataAsUTF8String { | ||
|
||
NSData *data = [self data]; | ||
if(!data) return nil; | ||
|
||
return [NSString stringWithUTF8String:[data bytes]]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.