diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pack-objects.c | 7 | ||||
-rw-r--r-- | src/push.c | 21 | ||||
-rw-r--r-- | src/push.h | 3 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/pack-objects.c b/src/pack-objects.c index a76f8a111..e4b67192d 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -144,7 +144,14 @@ on_error: unsigned int git_packbuilder_set_threads(git_packbuilder *pb, unsigned int n) { assert(pb); + +#ifdef GIT_THREADS pb->nr_threads = n; +#else + GIT_UNUSED(n); + assert(1 == pb->nr_threads); +#endif + return pb->nr_threads; } diff --git a/src/push.c b/src/push.c index 64aaead6e..628df7ac4 100644 --- a/src/push.c +++ b/src/push.c @@ -40,6 +40,7 @@ int git_push_new(git_push **out, git_remote *remote) p->repo = remote->repo; p->remote = remote; p->report_status = 1; + p->pb_parallelism = 1; if (git_vector_init(&p->specs, 0, push_spec_rref_cmp) < 0) { git__free(p); @@ -56,6 +57,18 @@ int git_push_new(git_push **out, git_remote *remote) return 0; } +int git_push_set_options(git_push *push, const git_push_options *opts) +{ + if (!push || !opts) + return -1; + + GITERR_CHECK_VERSION(opts, GIT_PUSH_OPTIONS_VERSION, "git_push_options"); + + push->pb_parallelism = opts->pb_parallelism; + + return 0; +} + static void free_refspec(push_spec *spec) { if (spec == NULL) @@ -449,8 +462,12 @@ static int do_push(git_push *push) * objects. In this case the client MUST send an empty pack-file. */ - if ((error = git_packbuilder_new(&push->pb, push->repo)) < 0 || - (error = calculate_work(push)) < 0 || + if ((error = git_packbuilder_new(&push->pb, push->repo)) < 0) + goto on_error; + + git_packbuilder_set_threads(push->pb, push->pb_parallelism); + + if ((error = calculate_work(push)) < 0 || (error = queue_objects(push)) < 0 || (error = transport->push(transport, push)) < 0) goto on_error; diff --git a/src/push.h b/src/push.h index 0ac8ef947..629583189 100644 --- a/src/push.h +++ b/src/push.h @@ -36,6 +36,9 @@ struct git_push { /* report-status */ bool unpack_ok; git_vector status; + + /* options */ + unsigned pb_parallelism; }; #endif |