Skip to content

Commit d4eccdb

Browse files
matheustavaresgitster
authored andcommitted
checkout-index: add parallel checkout support
Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ddb4af commit d4eccdb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

builtin/checkout-index.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "cache-tree.h"
1313
#include "parse-options.h"
1414
#include "entry.h"
15+
#include "parallel-checkout.h"
1516

1617
#define CHECKOUT_ALL 4
1718
static int nul_term_line;
@@ -160,6 +161,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
160161
int prefix_length;
161162
int force = 0, quiet = 0, not_new = 0;
162163
int index_opt = 0;
164+
int pc_workers, pc_threshold;
163165
struct option builtin_checkout_index_options[] = {
164166
OPT_BOOL('a', "all", &all,
165167
N_("check out all files in the index")),
@@ -214,6 +216,14 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
214216
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
215217
}
216218

219+
if (!to_tempfile)
220+
get_parallel_checkout_configs(&pc_workers, &pc_threshold);
221+
else
222+
pc_workers = 1;
223+
224+
if (pc_workers > 1)
225+
init_parallel_checkout();
226+
217227
/* Check out named files first */
218228
for (i = 0; i < argc; i++) {
219229
const char *arg = argv[i];
@@ -256,6 +266,12 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix)
256266
if (all)
257267
checkout_all(prefix, prefix_length);
258268

269+
if (pc_workers > 1) {
270+
/* Errors were already reported */
271+
run_parallel_checkout(&state, pc_workers, pc_threshold,
272+
NULL, NULL);
273+
}
274+
259275
if (is_lock_file_locked(&lock_file) &&
260276
write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
261277
die("Unable to write new index file");

0 commit comments

Comments
 (0)