diff options
author | Ronnie Sahlberg <sahlberg@google.com> | 2014-04-17 00:27:45 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-03 19:04:08 +0200 |
commit | 8c8bdc0d3582e42c13815a191344b1aa3e06c792 (patch) | |
tree | 8303c86ee46b8e76a2082f67fa275ec0149fde0e /refs.c | |
parent | refs.c: change ref_transaction_create to do error checking and return status (diff) | |
download | git-8c8bdc0d3582e42c13815a191344b1aa3e06c792.tar.xz git-8c8bdc0d3582e42c13815a191344b1aa3e06c792.zip |
refs.c: update ref_transaction_delete to check for error and return status
Change ref_transaction_delete() to do basic error checking and return
non-zero on error. Update all callers to check the return for
ref_transaction_delete(). There are currently no conditions in _delete that
will return error but there will be in the future. Add an err argument that
will be updated on failure.
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -3469,19 +3469,25 @@ int ref_transaction_create(struct ref_transaction *transaction, return 0; } -void ref_transaction_delete(struct ref_transaction *transaction, - const char *refname, - const unsigned char *old_sha1, - int flags, int have_old) +int ref_transaction_delete(struct ref_transaction *transaction, + const char *refname, + const unsigned char *old_sha1, + int flags, int have_old, + struct strbuf *err) { - struct ref_update *update = add_update(transaction, refname); + struct ref_update *update; + if (have_old && !old_sha1) + die("BUG: have_old is true but old_sha1 is NULL"); + + update = add_update(transaction, refname); update->flags = flags; update->have_old = have_old; if (have_old) { assert(!is_null_sha1(old_sha1)); hashcpy(update->old_sha1, old_sha1); } + return 0; } int update_ref(const char *action, const char *refname, |