| 2743 | } |
| 2744 | |
| 2745 | int ref_transaction_commit(struct ref_transaction *transaction, |
| 2746 | struct strbuf *err) |
| 2747 | { |
| 2748 | struct ref_store *refs = transaction->ref_store; |
| 2749 | int ret; |
| 2750 | |
| 2751 | switch (transaction->state) { |
| 2752 | case REF_TRANSACTION_OPEN: |
| 2753 | /* Need to prepare first. */ |
| 2754 | ret = ref_transaction_prepare(transaction, err); |
| 2755 | if (ret) |
| 2756 | return ret; |
| 2757 | break; |
| 2758 | case REF_TRANSACTION_PREPARED: |
| 2759 | /* Fall through to finish. */ |
| 2760 | break; |
| 2761 | case REF_TRANSACTION_CLOSED: |
| 2762 | BUG("commit called on a closed reference transaction"); |
| 2763 | break; |
| 2764 | default: |
| 2765 | BUG("unexpected reference transaction state"); |
| 2766 | break; |
| 2767 | } |
| 2768 | |
| 2769 | ret = refs->be->transaction_finish(refs, transaction, err); |
| 2770 | if (!ret && !(transaction->flags & REF_TRANSACTION_FLAG_INITIAL)) |
| 2771 | run_transaction_hook(transaction, "committed"); |
| 2772 | return ret; |
| 2773 | } |
| 2774 | |
| 2775 | enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs, |
| 2776 | const struct string_list *refnames, |
no test coverage detected