summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@google.com>2014-04-29 20:42:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-09-03 17:04:17 (GMT)
commit04ad6223ec1163163c4f39308149bee852ee245f (patch)
tree0f5078ca8e36b079d3fc69d7f6f3290144cf7c36 /refs.c
parent45421e24e8322184a35a32a9072f04afabe33880 (diff)
downloadgit-04ad6223ec1163163c4f39308149bee852ee245f.zip
git-04ad6223ec1163163c4f39308149bee852ee245f.tar.gz
git-04ad6223ec1163163c4f39308149bee852ee245f.tar.bz2
refs.c: remove the update_ref_write function
Since we only call update_ref_write from a single place and we only call it with onerr==QUIET_ON_ERR we can just as well get rid of it and just call write_ref_sha1 directly. This changes the return status for _commit from 1 to -1 on failures when writing to the ref. Eventually we will want _commit to start returning more detailed error conditions than the current simple success/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.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/refs.c b/refs.c
index a4445a1..a6b39ec 100644
--- a/refs.c
+++ b/refs.c
@@ -3336,25 +3336,6 @@ int for_each_reflog(each_ref_fn fn, void *cb_data)
return retval;
}
-static int update_ref_write(const char *action, const char *refname,
- const unsigned char *sha1, struct ref_lock *lock,
- struct strbuf *err, enum action_on_err onerr)
-{
- if (write_ref_sha1(lock, sha1, action) < 0) {
- const char *str = "Cannot update the ref '%s'.";
- if (err)
- strbuf_addf(err, str, refname);
-
- switch (onerr) {
- case UPDATE_REFS_MSG_ON_ERR: error(str, refname); break;
- case UPDATE_REFS_DIE_ON_ERR: die(str, refname); break;
- case UPDATE_REFS_QUIET_ON_ERR: break;
- }
- return 1;
- }
- return 0;
-}
-
/**
* Information needed for a single ref update. Set new_sha1 to the
* new value or to zero to delete the ref. To check the old value
@@ -3605,14 +3586,15 @@ int ref_transaction_commit(struct ref_transaction *transaction,
struct ref_update *update = updates[i];
if (!is_null_sha1(update->new_sha1)) {
- ret = update_ref_write(msg,
- update->refname,
- update->new_sha1,
- update->lock, err,
- UPDATE_REFS_QUIET_ON_ERR);
- update->lock = NULL; /* freed by update_ref_write */
- if (ret)
+ ret = write_ref_sha1(update->lock, update->new_sha1,
+ msg);
+ update->lock = NULL; /* freed by write_ref_sha1 */
+ if (ret) {
+ if (err)
+ strbuf_addf(err, "Cannot update the ref '%s'.",
+ update->refname);
goto cleanup;
+ }
}
}