Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

created the wrapper around git_config

  • Loading branch information...
commit fbf8ff7e16597bc83d70c0337682454612e0b66b 1 parent fc2d6b0
@joshaber joshaber authored
View
34 Classes/GTConfiguration.h
@@ -0,0 +1,34 @@
+//
+// GTConfiguration.h
+// ObjectiveGitFramework
+//
+// Created by Josh Abernathy on 12/30/11.
+// Copyright (c) 2011 GitHub, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#include "git2.h"
+#import "dct_weak.h"
+
+
+@interface GTConfiguration : NSObject
+
+@property (nonatomic, readonly, assign) git_config *git_config;
+
++ (GTConfiguration *)configurationWithConfiguration:(git_config *)config;
+
+- (void)setString:(NSString *)s forKey:(NSString *)key;
+- (NSString *)stringForKey:(NSString *)key;
+
+- (void)setBoolForKey:(BOOL)b forKey:(NSString *)key;
+- (BOOL)boolForKey:(NSString *)key;
+
+- (void)setInt32:(int32_t)i forKey:(NSString *)key;
+- (int32_t)int32ForKey:(NSString *)key;
+
+- (void)setInt64:(int64_t)i forKey:(NSString *)key;
+- (int64_t)int64ForKey:(NSString *)key;
+
+- (BOOL)deleteValueForKey:(NSString *)key error:(NSError **)error;
+
+@end
View
83 Classes/GTConfiguration.m
@@ -0,0 +1,83 @@
+//
+// GTConfiguration.m
+// ObjectiveGitFramework
+//
+// Created by Josh Abernathy on 12/30/11.
+// Copyright (c) 2011 GitHub, Inc. All rights reserved.
+//
+
+#import "GTConfiguration.h"
+
+@interface GTConfiguration ()
+@property (nonatomic, assign) git_config *git_config;
+@end
+
+
+@implementation GTConfiguration
+
+- (void)dealloc {
+ git_config_free(self.git_config);
+}
+
+
+#pragma mark API
+
+@synthesize git_config;
+
++ (GTConfiguration *)configurationWithConfiguration:(git_config *)config {
+ GTConfiguration *configuration = [[self alloc] init];
+ configuration.git_config = config;
+ return configuration;
+}
+
+- (void)setString:(NSString *)s forKey:(NSString *)key {
+ git_config_set_string(self.git_config, [key UTF8String], [s UTF8String]);
+}
+
+- (NSString *)stringForKey:(NSString *)key {
+ const char *string = NULL;
+ git_config_get_string(self.git_config, [key UTF8String], &string);
+ if(string == NULL) return nil;
+
+ return [NSString stringWithUTF8String:string];
+}
+
+- (void)setBoolForKey:(BOOL)b forKey:(NSString *)key {
+ git_config_set_bool(self.git_config, [key UTF8String], b);
+}
+
+- (BOOL)boolForKey:(NSString *)key {
+ int b = 0;
+ git_config_get_bool(self.git_config, [key UTF8String], &b);
+ return (BOOL) b;
+}
+
+- (void)setInt32:(int32_t)i forKey:(NSString *)key {
+ git_config_set_int32(self.git_config, [key UTF8String], i);
+}
+
+- (int32_t)int32ForKey:(NSString *)key {
+ int32_t i = 0;
+ git_config_get_int32(self.git_config, [key UTF8String], &i);
+
+ return i;
+}
+
+- (void)setInt64:(int64_t)i forKey:(NSString *)key {
+ git_config_set_int64(self.git_config, [key UTF8String], i);
+}
+
+- (int64_t)int64ForKey:(NSString *)key {
+ int64_t i = 0;
+ git_config_get_int64(self.git_config, [key UTF8String], &i);
+
+ return i;
+}
+
+- (BOOL)deleteValueForKey:(NSString *)key error:(NSError **)error {
+ git_config_delete(self.git_config, [key UTF8String]);
+
+ return YES;
+}
+
+@end
View
8 ObjectiveGitFramework.xcodeproj/project.pbxproj
@@ -68,6 +68,8 @@
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 */; };
+ 88EB7E4D14AEBA600046FEA4 /* GTConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 88EB7E4B14AEBA600046FEA4 /* GTConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 88EB7E4E14AEBA600046FEA4 /* GTConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 88EB7E4C14AEBA600046FEA4 /* GTConfiguration.m */; };
88F50F59132054D800584FBE /* GTBranch.h in Headers */ = {isa = PBXBuildFile; fileRef = 88F50F56132054D800584FBE /* GTBranch.h */; settings = {ATTRIBUTES = (Public, ); }; };
88F50F5A132054D800584FBE /* GTBranch.m in Sources */ = {isa = PBXBuildFile; fileRef = 88F50F57132054D800584FBE /* GTBranch.m */; };
88F6D9D91320451F00CC0BA8 /* ObjectiveGit.h in Headers */ = {isa = PBXBuildFile; fileRef = 88F6D9D81320451F00CC0BA8 /* ObjectiveGit.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -190,6 +192,8 @@
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>"; };
+ 88EB7E4C14AEBA600046FEA4 /* GTConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTConfiguration.m; sourceTree = "<group>"; };
88F50F56132054D800584FBE /* GTBranch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTBranch.h; sourceTree = "<group>"; };
88F50F57132054D800584FBE /* GTBranch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = GTBranch.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
88F6D9D81320451F00CC0BA8 /* ObjectiveGit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = ObjectiveGit.h; path = Classes/ObjectiveGit.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@@ -469,6 +473,8 @@
55C8054D13861F34004DCB0F /* GTObjectDatabase.m */,
AA046110134F4D2000DF526B /* GTOdbObject.h */,
AA046111134F4D2000DF526B /* GTOdbObject.m */,
+ 88EB7E4B14AEBA600046FEA4 /* GTConfiguration.h */,
+ 88EB7E4C14AEBA600046FEA4 /* GTConfiguration.m */,
);
path = Classes;
sourceTree = "<group>";
@@ -539,6 +545,7 @@
55C8057E13875C1B004DCB0F /* NSString+Git.h in Headers */,
79262F8B13C69B1600A4B1EA /* git2.h in Headers */,
883014EE14AC3E6E0040153F /* dct_weak.h in Headers */,
+ 88EB7E4D14AEBA600046FEA4 /* GTConfiguration.h in Headers */,
8849C6A214AD81FF003890AF /* GTRepository+Private.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -757,6 +764,7 @@
AA046114134F4D2000DF526B /* GTOdbObject.m in Sources */,
55C8055013861FE7004DCB0F /* GTObjectDatabase.m in Sources */,
55C8057A13875578004DCB0F /* NSString+Git.m in Sources */,
+ 88EB7E4E14AEBA600046FEA4 /* GTConfiguration.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Please sign in to comment.
Something went wrong with that request. Please try again.