MCPcopy Create free account
hub / github.com/git/git / midx_compaction_step_exec_write

Function midx_compaction_step_exec_write

repack-midx.c:433–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431}
432
433static int midx_compaction_step_exec_write(struct midx_compaction_step *step,
434 struct repack_write_midx_opts *opts,
435 const char *base)
436{
437 struct child_process cmd = CHILD_PROCESS_INIT;
438 struct string_list hash = STRING_LIST_INIT_DUP;
439 struct string_list_item *item;
440 const char *preferred_pack = NULL;
441 int ret = 0;
442
443 if (!step->u.write.nr) {
444 ret = error(_("no packs to write MIDX during compaction"));
445 goto out;
446 }
447
448 for_each_string_list_item(item, &step->u.write) {
449 if (item->util)
450 preferred_pack = item->string;
451 }
452
453 repack_prepare_midx_command(&cmd, opts, "write");
454 strvec_pushl(&cmd.args, "--incremental", "--no-write-chain-file", NULL);
455 strvec_pushf(&cmd.args, "--base=%s", base ? base : "none");
456
457 if (preferred_pack) {
458 struct strbuf buf = STRBUF_INIT;
459
460 strbuf_addstr(&buf, preferred_pack);
461 strbuf_strip_suffix(&buf, ".idx");
462 strbuf_addstr(&buf, ".pack");
463
464 strvec_pushf(&cmd.args, "--preferred-pack=%s", buf.buf);
465
466 strbuf_release(&buf);
467 }
468
469 ret = repack_fill_midx_stdin_packs(&cmd, &step->u.write, &hash);
470 if (hash.nr != 1) {
471 ret = error(_("expected exactly one line during MIDX write, "
472 "got: %"PRIuMAX),
473 (uintmax_t)hash.nr);
474 goto out;
475 }
476
477 step->csum = xstrdup(hash.items[0].string);
478
479out:
480 string_list_clear(&hash, 0);
481
482 return ret;
483}
484
485static int midx_compaction_step_exec_compact(struct midx_compaction_step *step,
486 struct repack_write_midx_opts *opts)

Callers 1

Calls 10

errorFunction · 0.85
strvec_pushlFunction · 0.85
strvec_pushfFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_strip_suffixFunction · 0.85
strbuf_releaseFunction · 0.85
xstrdupFunction · 0.85
string_list_clearFunction · 0.85

Tested by

no test coverage detected