From ae077771b09fac4d663e3f8c039318a97eb3a15b Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:06:51 +0000 Subject: refs: convert update_ref and refs_update_ref to use struct object_id Convert update_ref, refs_update_ref, and write_pseudoref to use struct object_id. Update the existing callers as well. Remove update_ref_oid, as it is no longer needed. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- sequencer.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index e258bb6469..cc3c0da3a5 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1115,11 +1115,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit, * write it at all. */ if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) && - update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.oid.hash, NULL, + update_ref(NULL, "CHERRY_PICK_HEAD", &commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) res = -1; if (command == TODO_REVERT && ((opts->no_commit && res == 0) || res == 1) && - update_ref(NULL, "REVERT_HEAD", commit->object.oid.hash, NULL, + update_ref(NULL, "REVERT_HEAD", &commit->object.oid, NULL, REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) res = -1; @@ -2124,8 +2124,8 @@ cleanup_head_ref: } msg = reflog_message(opts, "finish", "%s onto %s", head_ref.buf, buf.buf); - if (update_ref(msg, head_ref.buf, head.hash, orig.hash, - REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) { + if (update_ref(msg, head_ref.buf, &head, &orig, + REF_NODEREF, UPDATE_REFS_MSG_ON_ERR)) { res = error(_("could not update %s"), head_ref.buf); goto cleanup_head_ref; -- cgit v1.2.3 From 89f3bbdd3b1f46a5747aa5618b7742f7b3f2adef Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:06:53 +0000 Subject: refs: update ref transactions to use struct object_id Update the ref transaction code to use struct object_id. Remove one NULL pointer check which was previously inserted around a dereference; since we now pass a pointer to struct object_id directly through, the code we're calling handles this for us. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index cc3c0da3a5..d26985a6ed 100644 --- a/sequencer.c +++ b/sequencer.c @@ -393,7 +393,7 @@ static int fast_forward_to(const struct object_id *to, const struct object_id *f transaction = ref_transaction_begin(&err); if (!transaction || ref_transaction_update(transaction, "HEAD", - to->hash, unborn ? null_sha1 : from->hash, + to, unborn ? &null_oid : from, 0, sb.buf, &err) || ref_transaction_commit(transaction, &err)) { ref_transaction_free(transaction); -- cgit v1.2.3 From 34c290a6fc8b1f6705d2646d726df2260927da0f Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:06:56 +0000 Subject: refs: convert read_ref and read_ref_full to object_id All but two of the call sites already have parameters using the hash parameter of struct object_id, so convert them to take a pointer to the struct directly. Also convert refs_read_refs_full, the underlying implementation. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index d26985a6ed..3031e7364d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1630,7 +1630,7 @@ static int rollback_single_pick(void) if (!file_exists(git_path_cherry_pick_head()) && !file_exists(git_path_revert_head())) return error(_("no cherry-pick or revert in progress")); - if (read_ref_full("HEAD", 0, head_oid.hash, NULL)) + if (read_ref_full("HEAD", 0, &head_oid, NULL)) return error(_("cannot resolve HEAD")); if (is_null_oid(&head_oid)) return error(_("cannot abort from a branch yet to be born")); -- cgit v1.2.3 From 49e61479be913f67e66bb3fdf8de9475c41b58bd Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sun, 15 Oct 2017 22:07:09 +0000 Subject: refs: convert resolve_ref_unsafe to struct object_id Convert resolve_ref_unsafe to take a pointer to struct object_id by converting one remaining caller to use struct object_id, removing the temporary NULL pointer check in expand_ref, converting the declaration and definition, and applying the following semantic patch: @@ expression E1, E2, E3, E4; @@ - resolve_ref_unsafe(E1, E2, E3.hash, E4) + resolve_ref_unsafe(E1, E2, &E3, E4) @@ expression E1, E2, E3, E4; @@ - resolve_ref_unsafe(E1, E2, E3->hash, E4) + resolve_ref_unsafe(E1, E2, E3, E4) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index 3031e7364d..0d20ac760a 100644 --- a/sequencer.c +++ b/sequencer.c @@ -489,7 +489,7 @@ static int is_index_unchanged(void) struct object_id head_oid; struct commit *head_commit; - if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL)) + if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, &head_oid, NULL)) return error(_("could not resolve HEAD commit\n")); head_commit = lookup_commit(&head_oid); -- cgit v1.2.3