]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: convert resolve_refdup and refs_resolve_refdup to struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 15 Oct 2017 22:06:55 +0000 (22:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Oct 2017 02:05:50 +0000 (11:05 +0900)
All of the callers already pass the hash member of struct object_id, so
update them to pass a pointer to the struct directly,

This transformation was done with an update to declaration and
definition and the following semantic patch:

@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3.hash, E4)
+ resolve_refdup(E1, E2, &E3, E4)

@@
expression E1, E2, E3, E4;
@@
- resolve_refdup(E1, E2, E3->hash, E4)
+ resolve_refdup(E1, E2, E3, E4)

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
12 files changed:
builtin/am.c
builtin/branch.c
builtin/checkout.c
builtin/clone.c
builtin/fmt-merge-msg.c
builtin/merge.c
builtin/notes.c
builtin/show-branch.c
builtin/submodule--helper.c
refs.c
refs.h
submodule.c

index 32120f42df1a3d25342228d99ab6a8d4ab2eed09..c9bb14a6c2c3873b82ce161a0240a88666eaab3c 100644 (file)
@@ -2135,7 +2135,7 @@ static void am_abort(struct am_state *state)
 
        am_rerere_clear();
 
-       curr_branch = resolve_refdup("HEAD", 0, curr_head.hash, NULL);
+       curr_branch = resolve_refdup("HEAD", 0, &curr_head, NULL);
        has_curr_head = curr_branch && !is_null_oid(&curr_head);
        if (!has_curr_head)
                hashcpy(curr_head.hash, EMPTY_TREE_SHA1_BIN);
index f5237541a224f97a2e35cd232b522de9a5b16ea7..c5f88b59efb531681583dc610e25c0624269343f 100644 (file)
@@ -125,7 +125,7 @@ static int branch_merged(int kind, const char *name,
                if (upstream &&
                    (reference_name = reference_name_to_free =
                     resolve_refdup(upstream, RESOLVE_REF_READING,
-                                   oid.hash, NULL)) != NULL)
+                                   &oid, NULL)) != NULL)
                        reference_rev = lookup_commit_reference(&oid);
        }
        if (!reference_rev)
@@ -241,7 +241,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                                        RESOLVE_REF_READING
                                        | RESOLVE_REF_NO_RECURSE
                                        | RESOLVE_REF_ALLOW_BAD_NAME,
-                                       oid.hash, &flags);
+                                       &oid, &flags);
                if (!target) {
                        error(remote_branch
                              ? _("remote-tracking branch '%s' not found.")
@@ -636,7 +636,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 
        track = git_branch_track;
 
-       head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
+       head = resolve_refdup("HEAD", 0, &head_oid, NULL);
        if (!head)
                die(_("Failed to resolve HEAD as a valid ref."));
        if (!strcmp(head, "HEAD"))
index 2bb009ec0e68c74f54d252d8797356e6e91d2cfb..c33dbb70fb683353a70b833fc78dc39e7a09c115 100644 (file)
@@ -827,7 +827,7 @@ static int switch_branches(const struct checkout_opts *opts,
        struct object_id rev;
        int flag, writeout_error = 0;
        memset(&old, 0, sizeof(old));
-       old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
+       old.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
        if (old.path)
                old.commit = lookup_commit_reference_gently(&rev, 1);
        if (!(flag & REF_ISSYMREF))
index 5cd1b02d531cfb8dc6be145683e856e1f32f8de2..695bdd70468a7e54af84a0ac2e813e0c2f808cfe 100644 (file)
@@ -715,7 +715,7 @@ static int checkout(int submodule_progress)
        if (option_no_checkout)
                return 0;
 
-       head = resolve_refdup("HEAD", RESOLVE_REF_READING, oid.hash, NULL);
+       head = resolve_refdup("HEAD", RESOLVE_REF_READING, &oid, NULL);
        if (!head) {
                warning(_("remote HEAD refers to nonexistent ref, "
                          "unable to checkout.\n"));
index e99b5ddbf9a51be17bc0d976c942c29afe6563cd..b69f7d3be2bd4585a6233d0f8361c55a76ae0a5d 100644 (file)
@@ -603,7 +603,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
 
        /* get current branch */
        current_branch = current_branch_to_free =
-               resolve_refdup("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL);
+               resolve_refdup("HEAD", RESOLVE_REF_READING, &head_oid, NULL);
        if (!current_branch)
                die("No current branch");
        if (starts_with(current_branch, "refs/heads/"))
index 99d4b873f00ce8c4311f6b441b35f390e2e08d62..99d2df965fd54c789b3979f02429090701e4387d 100644 (file)
@@ -1142,7 +1142,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
         * Check if we are _not_ on a detached HEAD, i.e. if there is a
         * current branch.
         */
-       branch = branch_to_free = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
+       branch = branch_to_free = resolve_refdup("HEAD", 0, &head_oid, NULL);
        if (branch)
                skip_prefix(branch, "refs/heads/", &branch);
        if (!branch || is_null_oid(&head_oid))
index 8276af419bb058fc131b2dfc11832fdf1abaf853..12afdf19075f3e3de39d487a5f6b2b7e2bbe922e 100644 (file)
@@ -724,7 +724,7 @@ static int merge_commit(struct notes_merge_options *o)
        init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
 
        o->local_ref = local_ref_to_free =
-               resolve_refdup("NOTES_MERGE_REF", 0, oid.hash, NULL);
+               resolve_refdup("NOTES_MERGE_REF", 0, &oid, NULL);
        if (!o->local_ref)
                die(_("failed to resolve NOTES_MERGE_REF"));
 
index 84547d6fba07cb7770d94e80cda170c391d04a21..0237be4975eb1f1f50a1e39835eab086f9256097 100644 (file)
@@ -705,8 +705,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                        static const char *fake_av[2];
 
                        fake_av[0] = resolve_refdup("HEAD",
-                                                   RESOLVE_REF_READING,
-                                                   oid.hash, NULL);
+                                                   RESOLVE_REF_READING, &oid,
+                                                   NULL);
                        fake_av[1] = NULL;
                        av = fake_av;
                        ac = 1;
@@ -775,7 +775,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
        }
 
        head = resolve_refdup("HEAD", RESOLVE_REF_READING,
-                             head_oid.hash, NULL);
+                             &head_oid, NULL);
 
        if (with_current_branch && head) {
                int has_head = 0;
index 06ed02f99402be6a7edb36ff0eb08b903c513c6c..5946a7ca93b19846c66bbbb1669ef762deea629c 100644 (file)
@@ -1144,7 +1144,7 @@ static int push_check(int argc, const char **argv, const char *prefix)
        argv++;
        argc--;
        /* Get the submodule's head ref and determine if it is detached */
-       head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
+       head = resolve_refdup("HEAD", 0, &head_oid, NULL);
        if (!head)
                die(_("Failed to resolve HEAD as a valid ref."));
        if (!strcmp(head, "HEAD"))
diff --git a/refs.c b/refs.c
index db4988ab3ca4160dfc2f006dbcd41ea6df0f9db5..3bca4c273bc4dd587ed01fa832db32f3235418ba 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -194,21 +194,21 @@ int ref_resolves_to_object(const char *refname,
 
 char *refs_resolve_refdup(struct ref_store *refs,
                          const char *refname, int resolve_flags,
-                         unsigned char *sha1, int *flags)
+                         struct object_id *oid, int *flags)
 {
        const char *result;
 
        result = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
-                                        sha1, flags);
+                                        oid->hash, flags);
        return xstrdup_or_null(result);
 }
 
 char *resolve_refdup(const char *refname, int resolve_flags,
-                    unsigned char *sha1, int *flags)
+                    struct object_id *oid, int *flags)
 {
        return refs_resolve_refdup(get_main_ref_store(),
                                   refname, resolve_flags,
-                                  sha1, flags);
+                                  oid, flags);
 }
 
 /* The argument to filter_refs */
diff --git a/refs.h b/refs.h
index 1fee56d132ed161f51edeb48b1135546c43eecca..8dd39eab7205fdd8128b8f2bb7cd3ff4db6fad81 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -69,9 +69,9 @@ const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
 
 char *refs_resolve_refdup(struct ref_store *refs,
                          const char *refname, int resolve_flags,
-                         unsigned char *sha1, int *flags);
+                         struct object_id *oid, int *flags);
 char *resolve_refdup(const char *refname, int resolve_flags,
-                    unsigned char *sha1, int *flags);
+                    struct object_id *oid, int *flags);
 
 int refs_read_ref_full(struct ref_store *refs, const char *refname,
                       int resolve_flags, unsigned char *sha1, int *flags);
index 63e7094e1620c2c3eb7dda0a8c38a833ae2d1c5a..3b7be4cafea323b1a29b6100e21661900634a121 100644 (file)
@@ -1016,7 +1016,7 @@ int push_unpushed_submodules(struct oid_array *commits,
                char *head;
                struct object_id head_oid;
 
-               head = resolve_refdup("HEAD", 0, head_oid.hash, NULL);
+               head = resolve_refdup("HEAD", 0, &head_oid, NULL);
                if (!head)
                        die(_("Failed to resolve HEAD as a valid ref."));