diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2017-05-22 16:17:43 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-23 14:29:55 +0900 |
commit | 8d4240d3c8a2d31b7bedda8408c0b3c217c76998 (patch) | |
tree | bc9227ce8e4e3c8e29426f6cbbe2f60f934cdd20 /refs.c | |
parent | c0ca9357640ae5efbdbfed4c5b476c820a839e85 (diff) | |
download | git-8d4240d3c8a2d31b7bedda8408c0b3c217c76998.tar.gz |
ref_transaction_commit(): check for valid `transaction->state`
Move the check that `transaction->state` is valid from
`files_transaction_commit()` to `ref_transaction_commit()`, where
other future reference backends can benefit from it as well.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -1694,6 +1694,18 @@ int ref_transaction_commit(struct ref_transaction *transaction, { struct ref_store *refs = transaction->ref_store; + switch (transaction->state) { + case REF_TRANSACTION_OPEN: + /* Good. */ + break; + case REF_TRANSACTION_CLOSED: + die("BUG: prepare called on a closed reference transaction"); + break; + default: + die("BUG: unexpected reference transaction state"); + break; + } + if (getenv(GIT_QUARANTINE_ENVIRONMENT)) { strbuf_addstr(err, _("ref updates forbidden inside quarantine environment")); |