diff --git a/External/libgit2 b/External/libgit2 index 0c34fa509..eb94199fe 160000 --- a/External/libgit2 +++ b/External/libgit2 @@ -1 +1 @@ -Subproject commit 0c34fa5094ba624ebe398d1b154fd27c207108cb +Subproject commit eb94199fe46f01ebefeaf71cd408a1bd9f1e64fc 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/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); 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, diff --git a/ObjectiveGit/GTSubmodule.m b/ObjectiveGit/GTSubmodule.m index ed7593e6b..b6b8c5eee 100644 --- a/ObjectiveGit/GTSubmodule.m +++ b/ObjectiveGit/GTSubmodule.m @@ -26,7 +26,11 @@ - (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); + + // 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 { @@ -96,7 +100,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..8b27192b7 100644 --- a/ObjectiveGitTests/GTSubmoduleSpec.m +++ b/ObjectiveGitTests/GTSubmoduleSpec.m @@ -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());