Skip to content

Commit af1cdca

Browse files
committed
Fix clone progress & simplify fetch options init
1 parent 04835f7 commit af1cdca

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

ObjectiveGit/GTRepository+RemoteOperations.m

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,11 @@ - (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error
7878
.payload = &connectionInfo,
7979
};
8080

81-
git_fetch_options fetch_options;
82-
int gitError = git_fetch_init_options(&fetch_options, GIT_FETCH_OPTIONS_VERSION);
83-
if (gitError != GIT_OK) {
84-
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to init fetch options"];
85-
return NO;
86-
}
87-
88-
fetch_options.callbacks = remote_callbacks;
81+
git_fetch_options fetchOptions = GIT_FETCH_OPTIONS_INIT;
82+
fetchOptions.callbacks = remote_callbacks;
8983

9084
__block git_strarray refspecs;
91-
gitError = git_remote_get_fetch_refspecs(&refspecs, remote.git_remote);
85+
int gitError = git_remote_get_fetch_refspecs(&refspecs, remote.git_remote);
9286
if (gitError != GIT_OK) {
9387
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to get fetch refspecs for remote"];
9488
return NO;
@@ -100,7 +94,7 @@ - (BOOL)fetchRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error
10094

10195
NSString *reflog_message = [NSString stringWithFormat:@"fetching remote %@", remote.name];
10296

103-
gitError = git_remote_fetch(remote.git_remote, &refspecs, &fetch_options, reflog_message.UTF8String);
97+
gitError = git_remote_fetch(remote.git_remote, &refspecs, &fetchOptions, reflog_message.UTF8String);
10498
if (gitError != GIT_OK) {
10599
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to fetch from remote"];
106100
return NO;

ObjectiveGit/GTRepository.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ + (instancetype)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)work
242242
};
243243

244244
git_fetch_options fetchOptions = GIT_FETCH_OPTIONS_INIT;
245-
246245
fetchOptions.callbacks.version = GIT_REMOTE_CALLBACKS_VERSION;
247246

248247
if (provider) {
@@ -253,7 +252,7 @@ + (instancetype)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)work
253252

254253
fetchOptions.callbacks.transfer_progress = transferProgressCallback;
255254
fetchOptions.callbacks.payload = &payload;
256-
255+
cloneOptions.fetch_opts = fetchOptions;
257256
cloneOptions.remote_cb = remoteCreate;
258257

259258
BOOL localClone = [options[GTRepositoryCloneOptionsCloneLocal] boolValue];

0 commit comments

Comments
 (0)