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

Function reftable_stack_init_addition

reftable/stack.c:658–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656}
657
658static int reftable_stack_init_addition(struct reftable_addition *add,
659 struct reftable_stack *st,
660 unsigned int flags)
661{
662 struct reftable_buf lock_file_name = REFTABLE_BUF_INIT;
663 int err;
664
665 memset(add, 0, sizeof(*add));
666 add->stack = st;
667
668 err = flock_acquire(&add->tables_list_lock, st->list_file,
669 st->opts.lock_timeout_ms);
670 if (err < 0)
671 goto done;
672
673 if (st->opts.default_permissions) {
674 if (chmod(add->tables_list_lock.path,
675 st->opts.default_permissions) < 0) {
676 err = REFTABLE_IO_ERROR;
677 goto done;
678 }
679 }
680
681 err = stack_uptodate(st);
682 if (err < 0)
683 goto done;
684 if (err > 0 && flags & REFTABLE_STACK_NEW_ADDITION_RELOAD) {
685 err = reftable_stack_reload_maybe_reuse(add->stack, 1);
686 if (err)
687 goto done;
688 }
689 if (err > 0) {
690 err = REFTABLE_OUTDATED_ERROR;
691 goto done;
692 }
693
694 add->next_update_index = reftable_stack_next_update_index(st);
695done:
696 if (err)
697 reftable_addition_close(add);
698 reftable_buf_release(&lock_file_name);
699 return err;
700}
701
702static int stack_try_add(struct reftable_stack *st,
703 int (*write_table)(struct reftable_writer *wr,

Callers 2

stack_try_addFunction · 0.85

Calls 6

flock_acquireFunction · 0.85
stack_uptodateFunction · 0.85
reftable_addition_closeFunction · 0.85
reftable_buf_releaseFunction · 0.85

Tested by

no test coverage detected