From 9b3a0fcc55665d0d2f181de04e72005b511a1fcf Mon Sep 17 00:00:00 2001 From: Mac Morgan Date: Tue, 14 May 2013 19:26:41 -0400 Subject: [PATCH 1/2] added stash command --- Classes/GTRepository.h | 16 ++++++++++++++++ Classes/GTRepository.m | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Classes/GTRepository.h b/Classes/GTRepository.h index 1330c1eaa..cd97e2290 100644 --- a/Classes/GTRepository.h +++ b/Classes/GTRepository.h @@ -61,6 +61,13 @@ typedef enum : git_reset_t { GTRepositoryResetTypeHard = GIT_RESET_HARD } GTRepositoryResetType; +typedef enum : git_stash_flags { + GTRepositoryStashFlagDefault = GIT_STASH_DEFAULT, + GTRepositoryStashFlagKeepIndex = GIT_STASH_KEEP_INDEX, + GTRepositoryStashFlagIncludeUntracked = GIT_STASH_INCLUDE_UNTRACKED, + GTRepositoryStashFlagIncludeIgnored = GIT_STASH_INCLUDE_IGNORED +} GTRepositoryStashFlag; + typedef void (^GTRepositoryStatusBlock)(NSURL *fileURL, GTRepositoryFileStatus status, BOOL *stop); @interface GTRepository : NSObject @@ -212,4 +219,13 @@ typedef void (^GTRepositoryStatusBlock)(NSURL *fileURL, GTRepositoryFileStatus s // Returns the signature. - (GTSignature *)userSignatureForNow; +// Stash the repository's changes. +// +// message - the message to be attributed to the item in the stash. +// stashFlag - The flag of stash to be used. +// error(out) - in the event of an error this may be set. +// +// Returns commit of the stashed changes if successful, nil in the even of an error +- (GTCommit*)stashChangesWithMessage:(NSString *)message withStashFlag:(GTRepositoryStashFlag)stashFlag error:(NSError **)error; + @end diff --git a/Classes/GTRepository.m b/Classes/GTRepository.m index 032acfeac..91032f412 100644 --- a/Classes/GTRepository.m +++ b/Classes/GTRepository.m @@ -657,4 +657,17 @@ - (GTSignature *)userSignatureForNow { return [[GTSignature alloc] initWithName:name email:email time:[NSDate date]]; } +#pragma mark Stash + +- (GTCommit*)stashChangesWithMessage:(NSString *)message withStashFlag:(GTRepositoryStashFlag)stashFlag error:(NSError **)error +{ + git_oid oid; + + git_stash_save(&oid, self.git_repository, [self userSignatureForNow].git_signature, [message cStringUsingEncoding:NSUTF8StringEncoding], stashFlag); + + GTCommit* commit = (GTCommit*)[self lookupObjectByOid:&oid error:error]; + + return commit; +} + @end From daee703475f02324b647de374efebb113206baef Mon Sep 17 00:00:00 2001 From: Dmitry Golomidov Date: Tue, 14 May 2013 17:09:24 -0700 Subject: [PATCH 2/2] better formatting --- Classes/GTRepository.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/GTRepository.h b/Classes/GTRepository.h index cd97e2290..5e456de04 100644 --- a/Classes/GTRepository.h +++ b/Classes/GTRepository.h @@ -62,10 +62,10 @@ typedef enum : git_reset_t { } GTRepositoryResetType; typedef enum : git_stash_flags { - GTRepositoryStashFlagDefault = GIT_STASH_DEFAULT, - GTRepositoryStashFlagKeepIndex = GIT_STASH_KEEP_INDEX, + GTRepositoryStashFlagDefault = GIT_STASH_DEFAULT, + GTRepositoryStashFlagKeepIndex = GIT_STASH_KEEP_INDEX, GTRepositoryStashFlagIncludeUntracked = GIT_STASH_INCLUDE_UNTRACKED, - GTRepositoryStashFlagIncludeIgnored = GIT_STASH_INCLUDE_IGNORED + GTRepositoryStashFlagIncludeIgnored = GIT_STASH_INCLUDE_IGNORED } GTRepositoryStashFlag; typedef void (^GTRepositoryStatusBlock)(NSURL *fileURL, GTRepositoryFileStatus status, BOOL *stop);