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

Function midx_compaction_step_exec_compact

repack-midx.c:485–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485static int midx_compaction_step_exec_compact(struct midx_compaction_step *step,
486 struct repack_write_midx_opts *opts)
487{
488 struct child_process cmd = CHILD_PROCESS_INIT;
489 struct strbuf buf = STRBUF_INIT;
490 FILE *out = NULL;
491 int ret;
492
493 repack_prepare_midx_command(&cmd, opts, "compact");
494 strvec_pushl(&cmd.args, "--incremental", "--no-write-chain-file",
495 midx_get_checksum_hex(step->u.compact.from),
496 midx_get_checksum_hex(step->u.compact.to), NULL);
497
498 cmd.out = -1;
499
500 ret = start_command(&cmd);
501 if (ret)
502 goto out;
503
504 out = xfdopen(cmd.out, "r");
505 while (strbuf_getline_lf(&buf, out) != EOF) {
506 if (step->csum) {
507 ret = error(_("unexpected MIDX output: '%s'"), buf.buf);
508 fclose(out);
509 out = NULL;
510 finish_command(&cmd);
511 goto out;
512 }
513 step->csum = strbuf_detach(&buf, NULL);
514 }
515
516 ret = finish_command(&cmd);
517
518out:
519 if (out)
520 fclose(out);
521 strbuf_release(&buf);
522
523 return ret;
524}
525
526static int midx_compaction_step_exec(struct midx_compaction_step *step,
527 struct repack_write_midx_opts *opts,

Callers 1

Calls 10

strvec_pushlFunction · 0.85
midx_get_checksum_hexFunction · 0.85
start_commandFunction · 0.85
xfdopenFunction · 0.85
strbuf_getline_lfFunction · 0.85
errorFunction · 0.85
finish_commandFunction · 0.85
strbuf_detachFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected