summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2016-09-05 20:08:08 +0000
committerJunio C Hamano <gitster@pobox.com>2016-09-07 12:59:43 -0700
commit8f6dc7e32eee2944d1490ff9bf12ec329f3b33c2 (patch)
tree6d04aad2e1144fdd97b1c394b88e2bfcd5158e45 /refs.c
parent151b2911c1279f3ea4b5bcc069a04348aeb9d811 (diff)
downloadgit-8f6dc7e32eee2944d1490ff9bf12ec329f3b33c2.tar.gz
refs: add an update_ref_oid function.
Several places around the codebase want to pass update_ref data from struct object_id, but update_ref may also be passed NULL pointers. Instead of checking and dereferencing in every caller, create an update_ref_oid which wraps update_ref and provides this functionality. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/refs.c b/refs.c
index b4e7cac7b2..f567a78ee8 100644
--- a/refs.c
+++ b/refs.c
@@ -858,6 +858,14 @@ int ref_transaction_verify(struct ref_transaction *transaction,
flags, NULL, err);
}
+int update_ref_oid(const char *msg, const char *refname,
+ const struct object_id *new_oid, const struct object_id *old_oid,
+ unsigned int flags, enum action_on_err onerr)
+{
+ return update_ref(msg, refname, new_oid ? new_oid->hash : NULL,
+ old_oid ? old_oid->hash : NULL, flags, onerr);
+}
+
int update_ref(const char *msg, const char *refname,
const unsigned char *new_sha1, const unsigned char *old_sha1,
unsigned int flags, enum action_on_err onerr)