diff options
author | Ronnie Sahlberg <sahlberg@google.com> | 2014-05-19 10:42:34 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-12 13:39:30 -0700 |
commit | 4c06433f4ec6d0d8cc4ca9757f80505324dab0b6 (patch) | |
tree | 04407853da141088e3018969f14cc7eda0384564 | |
parent | d7a6a0082d6bdf46876aadbc0da783cb20887fca (diff) | |
download | git-4c06433f4ec6d0d8cc4ca9757f80505324dab0b6.tar.gz |
refs.c: make ref_transaction_begin take an err argument
Add an err argument to _begin so that on non-fatal failures in future ref
backends we can report a nice error back to the caller.
While _begin can currently never fail for other reasons than OOM, in which
case we die() anyway, we may add other types of backends in the future.
For example, a hypothetical MySQL backend could fail in _being with
"Can not connect to MySQL server. No route to host".
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
-rw-r--r-- | builtin/update-ref.c | 2 | ||||
-rw-r--r-- | refs.c | 2 | ||||
-rw-r--r-- | refs.h | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 7c9c248e54..c6ad0be377 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -365,7 +365,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) die("Refusing to perform update with empty message."); if (read_stdin) { - transaction = ref_transaction_begin(); + transaction = ref_transaction_begin(&err); if (delete || no_deref || argc > 0) usage_with_options(git_update_ref_usage, options); if (end_null) @@ -3420,7 +3420,7 @@ struct ref_transaction { size_t nr; }; -struct ref_transaction *ref_transaction_begin(void) +struct ref_transaction *ref_transaction_begin(struct strbuf *err) { return xcalloc(1, sizeof(struct ref_transaction)); } @@ -268,7 +268,7 @@ enum action_on_err { * Begin a reference transaction. The reference transaction must * be freed by calling ref_transaction_free(). */ -struct ref_transaction *ref_transaction_begin(void); +struct ref_transaction *ref_transaction_begin(struct strbuf *err); /* * The following functions add a reference check or update to a |