MCPcopy Index your code
hub / github.com/git/git / reftable_new_stack

Function reftable_new_stack

reftable/stack.c:503–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501}
502
503int reftable_new_stack(struct reftable_stack **dest, const char *dir,
504 const struct reftable_write_options *_opts)
505{
506 struct reftable_buf list_file_name = REFTABLE_BUF_INIT;
507 struct reftable_write_options opts = { 0 };
508 struct reftable_stack *p;
509 int err;
510
511 p = reftable_calloc(1, sizeof(*p));
512 if (!p) {
513 err = REFTABLE_OUT_OF_MEMORY_ERROR;
514 goto out;
515 }
516
517 if (_opts)
518 opts = *_opts;
519 if (opts.hash_id == 0)
520 opts.hash_id = REFTABLE_HASH_SHA1;
521
522 *dest = NULL;
523
524 reftable_buf_reset(&list_file_name);
525 if ((err = reftable_buf_addstr(&list_file_name, dir)) < 0 ||
526 (err = reftable_buf_addstr(&list_file_name, "/tables.list")) < 0)
527 goto out;
528
529 p->list_file = reftable_buf_detach(&list_file_name);
530 p->list_fd = -1;
531 p->opts = opts;
532 p->reftable_dir = reftable_strdup(dir);
533 if (!p->reftable_dir) {
534 err = REFTABLE_OUT_OF_MEMORY_ERROR;
535 goto out;
536 }
537
538 err = reftable_stack_reload_maybe_reuse(p, 1);
539 if (err < 0)
540 goto out;
541
542 *dest = p;
543 err = 0;
544
545out:
546 if (err < 0)
547 reftable_stack_destroy(p);
548 return err;
549}
550
551/*
552 * Check whether the given stack is up-to-date with what we have in memory.

Calls 7

reftable_callocFunction · 0.85
reftable_buf_resetFunction · 0.85
reftable_buf_addstrFunction · 0.85
reftable_buf_detachFunction · 0.85
reftable_strdupFunction · 0.85
reftable_stack_destroyFunction · 0.85