summaryrefslogtreecommitdiff
path: root/refs.h
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-06-20 07:43:00 -0700
committerJunio C Hamano <gitster@pobox.com>2014-07-14 11:54:42 -0700
commit8e34800e5bce1dc6f1ab5520a4c866a2a73639de (patch)
treee868c5deecd615291d84ae6c3900dbf70b133876 /refs.h
parent01319837c53050109c60e6740dfa9462327161f0 (diff)
downloadgit-8e34800e5bce1dc6f1ab5520a4c866a2a73639de.tar.gz
refs.c: change ref_transaction_update() to do error checking and return statusrs/ref-transaction-0
Update ref_transaction_update() do some basic error checking and return non-zero on error. Update all callers to check ref_transaction_update() for error. There are currently no conditions in _update that will return error but there will be in the future. Add an err argument that will be updated on failure. In future patches we will start doing both locking and checking for name conflicts in _update instead of _commit at which time this function will start returning errors for these conditions. Also check for BUGs during update and die(BUG:...) if we are calling _update with have_old but the old_sha1 pointer is NULL. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
Diffstat (limited to 'refs.h')
-rw-r--r--refs.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/refs.h b/refs.h
index 163b45c50a..c5376cee8d 100644
--- a/refs.h
+++ b/refs.h
@@ -246,12 +246,16 @@ struct ref_transaction *ref_transaction_begin(void);
* be deleted. If have_old is true, then old_sha1 holds the value
* that the reference should have had before the update, or zeros if
* it must not have existed beforehand.
+ * Function returns 0 on success and non-zero on failure. A failure to update
+ * means that the transaction as a whole has failed and will need to be
+ * rolled back. On failure the err buffer will be updated.
*/
-void ref_transaction_update(struct ref_transaction *transaction,
- const char *refname,
- const unsigned char *new_sha1,
- const unsigned char *old_sha1,
- int flags, int have_old);
+int ref_transaction_update(struct ref_transaction *transaction,
+ const char *refname,
+ const unsigned char *new_sha1,
+ const unsigned char *old_sha1,
+ int flags, int have_old,
+ struct strbuf *err);
/*
* Add a reference creation to transaction. new_sha1 is the value