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

Function ref_transaction_prepare

refs.c:2667–2716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2665}
2666
2667int ref_transaction_prepare(struct ref_transaction *transaction,
2668 struct strbuf *err)
2669{
2670 struct ref_store *refs = transaction->ref_store;
2671 int ret;
2672
2673 switch (transaction->state) {
2674 case REF_TRANSACTION_OPEN:
2675 /* Good. */
2676 break;
2677 case REF_TRANSACTION_PREPARED:
2678 BUG("prepare called twice on reference transaction");
2679 break;
2680 case REF_TRANSACTION_CLOSED:
2681 BUG("prepare called on a closed reference transaction");
2682 break;
2683 default:
2684 BUG("unexpected reference transaction state");
2685 break;
2686 }
2687
2688 if (refs->repo->disable_ref_updates) {
2689 strbuf_addstr(err,
2690 _("ref updates forbidden inside quarantine environment"));
2691 return -1;
2692 }
2693
2694 string_list_sort(&transaction->refnames);
2695 if (ref_update_reject_duplicates(&transaction->refnames, err))
2696 return REF_TRANSACTION_ERROR_GENERIC;
2697
2698 /* Preparing checks before locking references */
2699 ret = run_transaction_hook(transaction, "preparing");
2700 if (ret) {
2701 ref_transaction_abort(transaction, err);
2702 die(_(abort_by_ref_transaction_hook), "preparing");
2703 }
2704
2705 ret = refs->be->transaction_prepare(refs, transaction, err);
2706 if (ret)
2707 return ret;
2708
2709 ret = run_transaction_hook(transaction, "prepared");
2710 if (ret) {
2711 ref_transaction_abort(transaction, err);
2712 die(_(abort_by_ref_transaction_hook), "prepared");
2713 }
2714
2715 return 0;
2716}
2717
2718int ref_transaction_abort(struct ref_transaction *transaction,
2719 struct strbuf *err)

Callers 6

ref_transaction_commitFunction · 0.85
parse_cmd_prepareFunction · 0.85
mvFunction · 0.85

Calls 6

strbuf_addstrFunction · 0.85
run_transaction_hookFunction · 0.85
ref_transaction_abortFunction · 0.85
string_list_sortFunction · 0.70
dieFunction · 0.70

Tested by

no test coverage detected