Skip to content

Update libgit2 #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion External/libgit2
Submodule libgit2 updated 85 files
+190 −90 CHANGELOG.md
+4 −2 CMakeLists.txt
+14 −1 README.md
+15 −6 THREADING.md
+19 −0 appveyor.yml
+0 −44 cmake/Modules/FindLIBSSH2.cmake
+9 −3 examples/network/clone.c
+0 −1 include/git2.h
+8 −0 include/git2/merge.h
+0 −110 include/git2/push.h
+30 −1 include/git2/remote.h
+1 −1 include/git2/revert.h
+80 −1 include/git2/submodule.h
+49 −22 include/git2/sys/hashsig.h
+2 −2 include/git2/sys/index.h
+10 −12 include/git2/sys/openssl.h
+11 −0 include/git2/sys/refs.h
+1 −1 include/git2/tree.h
+3 −3 include/git2/version.h
+3 −1 src/attr_file.c
+2 −1 src/buffer.c
+1 −1 src/checkout.c
+5 −7 src/config_file.c
+2 −0 src/crlf.c
+6 −2 src/describe.c
+1 −0 src/diff.c
+15 −22 src/diff_tform.c
+1 −1 src/global.c
+12 −15 src/hashsig.c
+2 −0 src/ident.c
+4 −4 src/index.c
+4 −8 src/merge.c
+1 −1 src/notes.c
+1 −0 src/pack.c
+1 −1 src/path.c
+110 −0 src/push.h
+4 −2 src/rebase.c
+237 −16 src/remote.c
+2 −0 src/remote.h
+7 −3 src/repository.c
+229 −18 src/submodule.c
+61 −2 src/transports/local.c
+5 −3 src/transports/smart_protocol.c
+2 −2 src/tree.c
+14 −3 src/util.h
+2 −0 src/win32/mingw-compat.h
+2 −0 src/win32/path_w32.h
+31 −0 tests/buf/oom.c
+80 −13 tests/checkout/tree.c
+5 −0 tests/clar_libgit2.c
+1 −0 tests/clar_libgit2.h
+35 −19 tests/diff/rename.c
+8 −0 tests/index/tests.c
+363 −0 tests/network/fetchlocal.c
+14 −21 tests/network/remote/local.c
+9 −5 tests/network/remote/remotes.c
+3 −4 tests/object/tree/attributes.c
+1 −1 tests/object/tree/duplicateentries.c
+10 −10 tests/object/tree/write.c
+16 −28 tests/online/push.c
+15 −0 tests/path/core.c
+40 −9 tests/repo/init.c
+1 −1 tests/repo/iterator.c
+3 −0 tests/resources/submodule_simple/.gitmodules
+1 −0 tests/resources/submodule_simple/.gitted/HEAD
+8 −0 tests/resources/submodule_simple/.gitted/config
+1 −0 tests/resources/submodule_simple/.gitted/description
+ tests/resources/submodule_simple/.gitted/index
+ tests/resources/submodule_simple/.gitted/objects/22/9cea838964f435d4fc2c11561ddb7447003609
+ tests/resources/submodule_simple/.gitted/objects/5b/19f7523fbf55c96153ff5a94875583f1115a36
+ tests/resources/submodule_simple/.gitted/objects/a8/575e6aaececba78823993e4f11abbc6172aabd
+ tests/resources/submodule_simple/.gitted/objects/b4/f28943fad380f4ee3a9c6b95259b28204cc25a
+ tests/resources/submodule_simple/.gitted/objects/d6/9ff504a3ba631f2fdb35bff93cc8cb8e85f4f8
+3 −0 tests/resources/submodule_simple/.gitted/packed-refs
+1 −0 tests/resources/submodule_simple/.gitted/refs/heads/alternate_1
+1 −0 tests/resources/submodule_simple/.gitted/refs/heads/master
+0 −1 tests/resources/template/hooks/link.sample
+5 −0 tests/structinit/structinit.c
+115 −0 tests/submodule/init.c
+1 −1 tests/submodule/lookup.c
+5 −5 tests/submodule/modify.c
+1 −0 tests/submodule/repository_init.c
+14 −0 tests/submodule/submodule_helpers.c
+1 −0 tests/submodule/submodule_helpers.h
+380 −0 tests/submodule/update.c
30 changes: 0 additions & 30 deletions ObjectiveGit/GTRepository+RemoteOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,4 @@ extern NSString *const GTRepositoryRemoteOptionsCredentialProvider;
/// Retruns an array with GTFetchHeadEntry objects
- (NSArray *)fetchHeadEntriesWithError:(NSError **)error;

#pragma mark - Push

/// Push a single branch to a remote.
///
/// branch - The branch to push.
/// remote - The remote to push to.
/// options - Options applied to the push operation.
/// Recognized options are:
/// `GTRepositoryRemoteOptionsCredentialProvider`
/// error - The error if one occurred. Can be NULL.
/// progressBlock - An optional callback for monitoring progress.
///
/// Returns YES if the push was successful, NO otherwise (and `error`, if provided,
/// will point to an error describing what happened).
- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;

/// Push an array of branches to a remote.
///
/// branches - An array of branches to push.
/// remote - The remote to push to.
/// options - Options applied to the push operation.
/// Recognized options are:
/// `GTRepositoryRemoteOptionsCredentialProvider`
/// error - The error if one occurred. Can be NULL.
/// progressBlock - An optional callback for monitoring progress.
///
/// Returns YES if the push was successful, NO otherwise (and `error`, if provided,
/// will point to an error describing what happened).
- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;

@end
134 changes: 0 additions & 134 deletions ObjectiveGit/GTRepository+RemoteOperations.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ int GTRemotePushTransferProgressCallback(unsigned int current, unsigned int tota
return (stop == YES ? GIT_EUSER : 0);
}

static int GTRemotePushRefspecStatusCallback(const char *ref, const char *msg, void *data) {
if (msg != NULL) {
return GIT_ERROR;
}

return GIT_OK;
}

#pragma mark -
#pragma mark Fetch

Expand Down Expand Up @@ -167,130 +159,4 @@ - (NSArray *)fetchHeadEntriesWithError:(NSError **)error {
return entries;
}

#pragma mark - Push (Public)

- (BOOL)pushBranch:(GTBranch *)branch toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
NSParameterAssert(branch != nil);
NSParameterAssert(remote != nil);

return [self pushBranches:@[ branch ] toRemote:remote withOptions:options error:error progress:progressBlock];
}

- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
NSParameterAssert(branches != nil);
NSParameterAssert(branches.count != 0);
NSParameterAssert(remote != nil);

NSMutableArray *refspecs = nil;
// Build refspecs for the passed in branches
refspecs = [NSMutableArray arrayWithCapacity:branches.count];
for (GTBranch *branch in branches) {
// Default remote reference for when branch doesn't exist on remote - create with same short name
NSString *remoteBranchReference = [NSString stringWithFormat:@"refs/heads/%@", branch.shortName];

BOOL success = NO;
GTBranch *trackingBranch = [branch trackingBranchWithError:error success:&success];

if (success && trackingBranch) {
// Use remote branch short name from trackingBranch, which could be different
// (e.g. refs/heads/master:refs/heads/my_master)
remoteBranchReference = [NSString stringWithFormat:@"refs/heads/%@", trackingBranch.shortName];
}

[refspecs addObject:[NSString stringWithFormat:@"refs/heads/%@:%@", branch.shortName, remoteBranchReference]];
}

return [self pushRefspecs:refspecs toRemote:remote withOptions:options error:error progress:progressBlock];
}

#pragma mark - Push (Private)

- (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
int gitError;
GTCredentialProvider *credProvider = options[GTRepositoryRemoteOptionsCredentialProvider];

GTRemoteConnectionInfo connectionInfo = {
.credProvider = { .credProvider = credProvider },
.direction = GIT_DIRECTION_PUSH,
.pushProgressBlock = progressBlock,
};

git_remote_callbacks remote_callbacks = GIT_REMOTE_CALLBACKS_INIT;
remote_callbacks.credentials = (credProvider != nil ? GTCredentialAcquireCallback : NULL),
remote_callbacks.transfer_progress = GTRemoteFetchTransferProgressCallback,
remote_callbacks.payload = &connectionInfo,

gitError = git_remote_set_callbacks(remote.git_remote, &remote_callbacks);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to set callbacks on remote"];
return NO;
}

gitError = git_remote_connect(remote.git_remote, GIT_DIRECTION_PUSH);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to connect remote"];
return NO;
}
@onExit {
git_remote_disconnect(remote.git_remote);
// Clear out callbacks by overwriting with an effectively empty git_remote_callbacks struct
git_remote_set_callbacks(remote.git_remote, &((git_remote_callbacks)GIT_REMOTE_CALLBACKS_INIT));
};

git_push *push;
gitError = git_push_new(&push, remote.git_remote);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Push object creation failed" failureReason:@"Failed to create push object for remote \"%@\"", self];
return NO;
}
@onExit {
git_push_free(push);
};

git_push_options push_options = GIT_PUSH_OPTIONS_INIT;

gitError = git_push_set_options(push, &push_options);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to add options"];
return NO;
}

GTRemoteConnectionInfo payload = {
.pushProgressBlock = progressBlock,
};
gitError = git_push_set_callbacks(push, NULL, NULL, GTRemotePushTransferProgressCallback, &payload);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Setting push callbacks failed"];
return NO;
}

for (NSString *refspec in refspecs) {
gitError = git_push_add_refspec(push, refspec.UTF8String);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Adding reference failed" failureReason:@"Failed to add refspec \"%@\" to push object", refspec];
return NO;
}
}

gitError = git_push_finish(push);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Push to remote failed"];
return NO;
}

gitError = git_push_update_tips(push, self.userSignatureForNow.git_signature, NULL);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Update tips failed"];
return NO;
}

gitError = git_push_status_foreach(push, GTRemotePushRefspecStatusCallback, NULL);
if (gitError != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"One or references failed to update"];
return NO;
}

return YES;
}

@end
2 changes: 1 addition & 1 deletion ObjectiveGit/GTTreeBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (id)initWithTree:(GTTree *)treeOrNil repository:(GTRepository *)repository err
self = [super init];
if (self == nil) return nil;

int status = git_treebuilder_create(&_git_treebuilder, repository.git_repository, treeOrNil.git_tree);
int status = git_treebuilder_new(&_git_treebuilder, repository.git_repository, treeOrNil.git_tree);
if (status != GIT_OK) {
if (error != NULL) *error = [NSError git_errorFor:status description:@"Failed to create tree builder with tree %@.", treeOrNil.SHA];
return nil;
Expand Down
4 changes: 0 additions & 4 deletions ObjectiveGitFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@
DD3D9513182A81E1004AF532 /* GTBlame.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3D9511182A81E1004AF532 /* GTBlame.m */; };
DD3D951C182AB25C004AF532 /* GTBlameHunk.h in Headers */ = {isa = PBXBuildFile; fileRef = DD3D951A182AB25C004AF532 /* GTBlameHunk.h */; settings = {ATTRIBUTES = (Public, ); }; };
DD3D951D182AB25C004AF532 /* GTBlameHunk.m in Sources */ = {isa = PBXBuildFile; fileRef = DD3D951B182AB25C004AF532 /* GTBlameHunk.m */; };
F8E4A2911A170CA6006485A8 /* GTRemotePushSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = F8E4A2901A170CA6006485A8 /* GTRemotePushSpec.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -568,7 +567,6 @@
DD3D951B182AB25C004AF532 /* GTBlameHunk.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTBlameHunk.m; sourceTree = "<group>"; };
E46931A7172740D300F2077D /* update_libgit2 */ = {isa = PBXFileReference; lastKnownFileType = text; name = update_libgit2; path = script/update_libgit2; sourceTree = "<group>"; };
E46931A8172740D300F2077D /* update_libgit2_ios */ = {isa = PBXFileReference; lastKnownFileType = text; name = update_libgit2_ios; path = script/update_libgit2_ios; sourceTree = "<group>"; };
F8E4A2901A170CA6006485A8 /* GTRemotePushSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTRemotePushSpec.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -719,7 +717,6 @@
88F05AA816011FFD00B7AD1D /* GTObjectSpec.m */,
D00F6815175D373C004DB9D6 /* GTReferenceSpec.m */,
88215482171499BE00D76B76 /* GTReflogSpec.m */,
F8E4A2901A170CA6006485A8 /* GTRemotePushSpec.m */,
4DBA4A3117DA73CE006CD5F5 /* GTRemoteSpec.m */,
200578C418932A82001C06C3 /* GTBlameSpec.m */,
D0AC906B172F941F00347DC4 /* GTRepositorySpec.m */,
Expand Down Expand Up @@ -1268,7 +1265,6 @@
88E353061982EA6B0051001F /* GTRepositoryAttributesSpec.m in Sources */,
88234B2618F2FE260039972E /* GTRepositoryResetSpec.m in Sources */,
5BE612931745EEBC00266D8C /* GTTreeBuilderSpec.m in Sources */,
F8E4A2911A170CA6006485A8 /* GTRemotePushSpec.m in Sources */,
D06D9E011755D10000558C17 /* GTEnumeratorSpec.m in Sources */,
D03B7C411756AB370034A610 /* GTSubmoduleSpec.m in Sources */,
D00F6816175D373C004DB9D6 /* GTReferenceSpec.m in Sources */,
Expand Down
Loading