From 1b3f6aa344aeeb11353e2816395ab233c84e8633 Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 1 Jul 2015 11:57:25 -0400 Subject: [PATCH 1/7] ++libgit2 --- External/libgit2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/External/libgit2 b/External/libgit2 index 0c34fa509..aa92c318a 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit 0c34fa5094ba624ebe398d1b154fd27c207108cb +Subproject commit aa92c318a235cc6a5230682b9c071eb35f9c5f4c From 89b339f1dc0a7203ff92870fb522b015248f947e Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 1 Jul 2015 11:57:42 -0400 Subject: [PATCH 2/7] Constants changed. --- ObjectiveGit/GTRepository+RemoteOperations.m | 2 +- ObjectiveGit/GTSubmodule.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ObjectiveGit/GTRepository+RemoteOperations.m b/ObjectiveGit/GTRepository+RemoteOperations.m index 6de890980..2b2214b5e 100644 --- a/ObjectiveGit/GTRepository+RemoteOperations.m +++ b/ObjectiveGit/GTRepository+RemoteOperations.m @@ -249,7 +249,7 @@ - (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions int update_fetchhead = 1; // Ignored for push - git_remote_autotag_option_t download_tags = GIT_REMOTE_DOWNLOAD_TAGS_FALLBACK; + git_remote_autotag_option_t download_tags = GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED; NSString *reflog_message = [NSString stringWithFormat:@"pushing remote %@", remote.name]; gitError = git_remote_update_tips(remote.git_remote, &remote_callbacks, update_fetchhead, download_tags, reflog_message.UTF8String); diff --git a/ObjectiveGit/GTSubmodule.h b/ObjectiveGit/GTSubmodule.h index 2c5275b16..81d2e0a25 100644 --- a/ObjectiveGit/GTSubmodule.h +++ b/ObjectiveGit/GTSubmodule.h @@ -19,7 +19,7 @@ /// /// These flags are mutually exclusive. typedef NS_ENUM(NSInteger, GTSubmoduleIgnoreRule) { - GTSubmoduleIgnoreReset = GIT_SUBMODULE_IGNORE_RESET, + GTSubmoduleIgnoreUnspecified = GIT_SUBMODULE_IGNORE_UNSPECIFIED, GTSubmoduleIgnoreNone = GIT_SUBMODULE_IGNORE_NONE, GTSubmoduleIgnoreUntracked = GIT_SUBMODULE_IGNORE_UNTRACKED, GTSubmoduleIgnoreDirty = GIT_SUBMODULE_IGNORE_DIRTY, From c7f658a19d52a933db819c8de8e7f806fa08bf6f Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 1 Jul 2015 11:57:51 -0400 Subject: [PATCH 3/7] :fire: -reloadSubmodules: :fire: --- ObjectiveGit/GTRepository.h | 10 ---------- ObjectiveGit/GTRepository.m | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/ObjectiveGit/GTRepository.h b/ObjectiveGit/GTRepository.h index 0c160bd1c..de072a046 100644 --- a/ObjectiveGit/GTRepository.h +++ b/ObjectiveGit/GTRepository.h @@ -383,16 +383,6 @@ NS_ASSUME_NONNULL_BEGIN /// Returns the signature. - (GTSignature *)userSignatureForNow; -/// Reloads all cached information about the receiver's submodules. -/// -/// Existing GTSubmodule objects from this repository will be mutated as part of -/// this operation. -/// -/// error - If not NULL, set to any errors that occur. -/// -/// Returns whether the reload succeeded. -- (BOOL)reloadSubmodules:(NSError **)error; - /// Enumerates over all the tracked submodules in the repository. /// /// recursive - Whether to recurse into nested submodules, depth-first. diff --git a/ObjectiveGit/GTRepository.m b/ObjectiveGit/GTRepository.m index 237aa6a61..c08827420 100644 --- a/ObjectiveGit/GTRepository.m +++ b/ObjectiveGit/GTRepository.m @@ -674,16 +674,6 @@ static int submoduleEnumerationCallback(git_submodule *git_submodule, const char return 0; } -- (BOOL)reloadSubmodules:(NSError **)error { - int gitError = git_submodule_reload_all(self.git_repository, 0); - if (gitError != GIT_OK) { - if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to reload submodules."]; - return NO; - } - - return YES; -} - - (void)enumerateSubmodulesRecursively:(BOOL)recursive usingBlock:(void (^)(GTSubmodule *submodule, NSError *error, BOOL *stop))block { NSParameterAssert(block != nil); From ed33a45ffe7ce7aef2fdf7761810746636e8d0b0 Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 1 Jul 2015 11:58:17 -0400 Subject: [PATCH 4/7] APIs changed. --- ObjectiveGit/GTSubmodule.m | 4 ++-- ObjectiveGitTests/GTSubmoduleSpec.m | 25 ++----------------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/ObjectiveGit/GTSubmodule.m b/ObjectiveGit/GTSubmodule.m index ed7593e6b..6189c43c1 100644 --- a/ObjectiveGit/GTSubmodule.m +++ b/ObjectiveGit/GTSubmodule.m @@ -26,7 +26,7 @@ - (GTSubmoduleIgnoreRule)ignoreRule { } - (void)setIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule { - git_submodule_set_ignore(self.git_submodule, (git_submodule_ignore_t)ignoreRule); + git_submodule_set_ignore(self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule); } - (GTOID *)indexOID { @@ -96,7 +96,7 @@ - (instancetype)initWithGitSubmodule:(git_submodule *)submodule parentRepository - (GTSubmoduleStatus)status:(NSError **)error { unsigned status; - int gitError = git_submodule_status(&status, self.git_submodule); + int gitError = git_submodule_status(&status, self.parentRepository.git_repository, git_submodule_name(self.git_submodule), git_submodule_ignore(self.git_submodule)); if (gitError != GIT_OK) { if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to get submodule %@ status.", self.name]; return GTSubmoduleStatusUnknown; diff --git a/ObjectiveGitTests/GTSubmoduleSpec.m b/ObjectiveGitTests/GTSubmoduleSpec.m index ca09d6950..79a236203 100644 --- a/ObjectiveGitTests/GTSubmoduleSpec.m +++ b/ObjectiveGitTests/GTSubmoduleSpec.m @@ -21,7 +21,7 @@ expect(repo).notTo(beNil()); }); -it(@"should enumerate top-level submodules", ^{ +fit(@"should enumerate top-level submodules", ^{ NSMutableSet *names = [NSMutableSet set]; [repo enumerateSubmodulesRecursively:NO usingBlock:^(GTSubmodule *submodule, NSError *error, BOOL *stop) { expect(submodule).to(beAnInstanceOf(GTSubmodule.class)); @@ -67,8 +67,7 @@ expect(submodule).notTo(beNil()); expect(@(git_submodule_url(submodule.git_submodule))).notTo(equal(testURLString)); - git_submodule_set_url(submodule.git_submodule, testURLString.UTF8String); - git_submodule_save(submodule.git_submodule); + git_submodule_set_url(repo.git_repository, git_submodule_name(submodule.git_submodule), testURLString.UTF8String); __block NSError *error = nil; expect(@([submodule writeToParentConfigurationDestructively:YES error:&error])).to(beTruthy()); @@ -79,26 +78,6 @@ expect(@(git_submodule_url(submodule.git_submodule))).to(equal(testURLString)); }); -it(@"should reload all submodules", ^{ - GTSubmodule *submodule = [repo submoduleWithName:@"new_submodule" error:NULL]; - expect(submodule).to(beNil()); - - NSURL *gitmodulesURL = [repo.fileURL URLByAppendingPathComponent:@".gitmodules"]; - NSMutableString *gitmodules = [NSMutableString stringWithContentsOfURL:gitmodulesURL usedEncoding:NULL error:NULL]; - expect(gitmodules).notTo(beNil()); - - [gitmodules appendString:@"[submodule \"new_submodule\"]\n\turl = some_url\n\tpath = new_submodule_path"]; - expect(@([gitmodules writeToURL:gitmodulesURL atomically:YES encoding:NSUTF8StringEncoding error:NULL])).to(beTruthy()); - - __block NSError *error = nil; - expect(@([repo reloadSubmodules:&error])).to(beTruthy()); - expect(error).to(beNil()); - - submodule = [repo submoduleWithName:@"new_submodule" error:NULL]; - expect(submodule).notTo(beNil()); - expect(submodule.path).to(equal(@"new_submodule_path")); -}); - it(@"should add its HEAD to its parent's index", ^{ GTSubmodule *submodule = [repo submoduleWithName:@"Test_App" error:NULL]; expect(submodule).notTo(beNil()); From 084e99139b23e145ca15a89f5687279cade8e3bf Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 2 Jul 2015 11:24:01 -0400 Subject: [PATCH 5/7] ++libgit2 --- External/libgit2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/External/libgit2 b/External/libgit2 index aa92c318a..eb94199fe 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit aa92c318a235cc6a5230682b9c071eb35f9c5f4c +Subproject commit eb94199fe46f01ebefeaf71cd408a1bd9f1e64fc From 054cebb399e7723befa8f2efe5c3bdd3439416ad Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 2 Jul 2015 11:24:08 -0400 Subject: [PATCH 6/7] Unfocus the test. --- ObjectiveGitTests/GTSubmoduleSpec.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ObjectiveGitTests/GTSubmoduleSpec.m b/ObjectiveGitTests/GTSubmoduleSpec.m index 79a236203..8b27192b7 100644 --- a/ObjectiveGitTests/GTSubmoduleSpec.m +++ b/ObjectiveGitTests/GTSubmoduleSpec.m @@ -21,7 +21,7 @@ expect(repo).notTo(beNil()); }); -fit(@"should enumerate top-level submodules", ^{ +it(@"should enumerate top-level submodules", ^{ NSMutableSet *names = [NSMutableSet set]; [repo enumerateSubmodulesRecursively:NO usingBlock:^(GTSubmodule *submodule, NSError *error, BOOL *stop) { expect(submodule).to(beAnInstanceOf(GTSubmodule.class)); From 67444fd24479f8160841726f34ed7ac263f25a78 Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 2 Jul 2015 11:24:16 -0400 Subject: [PATCH 7/7] Reload after setting the ignore rule. --- ObjectiveGit/GTSubmodule.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ObjectiveGit/GTSubmodule.m b/ObjectiveGit/GTSubmodule.m index 6189c43c1..b6b8c5eee 100644 --- a/ObjectiveGit/GTSubmodule.m +++ b/ObjectiveGit/GTSubmodule.m @@ -27,6 +27,10 @@ - (GTSubmoduleIgnoreRule)ignoreRule { - (void)setIgnoreRule:(GTSubmoduleIgnoreRule)ignoreRule { git_submodule_set_ignore(self.parentRepository.git_repository, git_submodule_name(self.git_submodule), (git_submodule_ignore_t)ignoreRule); + + // The docs for `git_submodule_set_ignore` note "This does not affect any + // currently-loaded instances." So we need to reload. + git_submodule_reload(self.git_submodule, 0); } - (GTOID *)indexOID {