Convert lookup_commit* to struct object_id
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 6 May 2017 22:10:10 +0000 (22:10 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2017 06:12:57 +0000 (15:12 +0900)
Convert lookup_commit, lookup_commit_or_die,
lookup_commit_reference, and lookup_commit_reference_gently to take
struct object_id arguments.

Introduce a temporary in parse_object buffer in order to convert this
function. This is required since in order to convert parse_object and
parse_object_buffer, lookup_commit_reference_gently and
lookup_commit_or_die would need to be converted. Not introducing a
temporary would therefore require that lookup_commit_or_die take a
struct object_id *, but lookup_commit would take unsigned char *,
leaving a confusing and hard-to-use interface.

parse_object_buffer will lose this temporary in a later patch.

This commit was created with manual changes to commit.c, commit.h, and
object.c, plus the following semantic patch:

@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1.hash, E2)
+ lookup_commit_reference_gently(&E1, E2)

@@
expression E1, E2;
@@
- lookup_commit_reference_gently(E1->hash, E2)
+ lookup_commit_reference_gently(E1, E2)

@@
expression E1;
@@
- lookup_commit_reference(E1.hash)
+ lookup_commit_reference(&E1)

@@
expression E1;
@@
- lookup_commit_reference(E1->hash)
+ lookup_commit_reference(E1)

@@
expression E1;
@@
- lookup_commit(E1.hash)
+ lookup_commit(&E1)

@@
expression E1;
@@
- lookup_commit(E1->hash)
+ lookup_commit(E1)

@@
expression E1, E2;
@@
- lookup_commit_or_die(E1.hash, E2)
+ lookup_commit_or_die(&E1, E2)

@@
expression E1, E2;
@@
- lookup_commit_or_die(E1->hash, E2)
+ lookup_commit_or_die(E1, E2)

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
50 files changed:
archive.c
bisect.c
branch.c
builtin/am.c
builtin/blame.c
builtin/branch.c
builtin/checkout.c
builtin/clone.c
builtin/commit-tree.c
builtin/commit.c
builtin/describe.c
builtin/diff-tree.c
builtin/fast-export.c
builtin/fetch.c
builtin/fmt-merge-msg.c
builtin/log.c
builtin/merge-base.c
builtin/merge.c
builtin/notes.c
builtin/pull.c
builtin/reflog.c
builtin/replace.c
builtin/reset.c
builtin/rev-parse.c
builtin/show-branch.c
builtin/tag.c
builtin/verify-commit.c
bundle.c
commit.c
commit.h
fast-import.c
fetch-pack.c
http-push.c
log-tree.c
notes-cache.c
notes-merge.c
notes-utils.c
object.c
parse-options-cb.c
ref-filter.c
remote.c
revision.c
sequencer.c
sha1_name.c
shallow.c
submodule.c
tag.c
tree.c
walker.c
wt-status.c
index 60b889198656f42a1d073503c4da5886bf0a0526..54701e8bb20dced0db67dd944d96f1b77ceff032 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -360,7 +360,7 @@ static void parse_treeish_arg(const char **argv,
        if (get_sha1(name, oid.hash))
                die("Not a valid object name");
 
-       commit = lookup_commit_reference_gently(oid.hash, 1);
+       commit = lookup_commit_reference_gently(&oid, 1);
        if (commit) {
                commit_sha1 = commit->object.oid.hash;
                archive_time = commit->date;
index 08c9fb7266c3b2ff8b970c21d350be4adfe7b0fc..bb5af3ea3d6761d4fe67086abc69401e44835275 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -705,7 +705,7 @@ static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)
 
 static struct commit *get_commit_reference(const struct object_id *oid)
 {
-       struct commit *r = lookup_commit_reference(oid->hash);
+       struct commit *r = lookup_commit_reference(oid);
        if (!r)
                die(_("Not a valid commit name %s"), oid_to_hex(oid));
        return r;
index 1758c9708604608f9a40097a18b5468a8f1a8451..4899144f5dc1e1518174e6d874fc4b4c76efdb40 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -286,7 +286,7 @@ void create_branch(const char *name, const char *start_name,
                break;
        }
 
-       if ((commit = lookup_commit_reference(oid.hash)) == NULL)
+       if ((commit = lookup_commit_reference(&oid)) == NULL)
                die(_("Not a valid branch point: '%s'."), start_name);
        oidcpy(&oid, &commit->object.oid);
 
index a95dd8b4e6c793d9e51658e2ccbe535cf5a5af45..650269ac5e0b17a4c2e50470e5d32db55e23de01 100644 (file)
@@ -1488,7 +1488,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
        if (get_mail_commit_oid(&commit_oid, mail) < 0)
                die(_("could not parse %s"), mail);
 
-       commit = lookup_commit_or_die(commit_oid.hash, mail);
+       commit = lookup_commit_or_die(&commit_oid, mail);
 
        get_commit_info(state, commit);
 
@@ -1683,7 +1683,7 @@ static void do_commit(const struct am_state *state)
 
        if (!get_sha1_commit("HEAD", parent.hash)) {
                old_oid = &parent;
-               commit_list_insert(lookup_commit(parent.hash), &parents);
+               commit_list_insert(lookup_commit(&parent), &parents);
        } else {
                old_oid = NULL;
                say(state, stderr, _("applying to an empty history"));
index 7d644d092543c65b712eae0da6daed988e3f8d3c..58bb274d0234607400d23fdb02488b8f8c99bfce 100644 (file)
@@ -2253,7 +2253,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc
 {
        struct commit *parent;
 
-       parent = lookup_commit_reference(oid->hash);
+       parent = lookup_commit_reference(oid);
        if (!parent)
                die("no such commit %s", oid_to_hex(oid));
        return &commit_list_insert(parent, tail)->next;
@@ -2475,7 +2475,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)
        /* Do we have HEAD? */
        if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
                return NULL;
-       head_commit = lookup_commit_reference_gently(head_oid.hash, 1);
+       head_commit = lookup_commit_reference_gently(&head_oid, 1);
        if (!head_commit)
                return NULL;
 
index 48a513a84dbf6cf2516a10cbcced267369bc747c..83fcda43dceec0255c6164eb42a35d3d89011efb 100644 (file)
@@ -124,7 +124,7 @@ static int branch_merged(int kind, const char *name,
                    (reference_name = reference_name_to_free =
                     resolve_refdup(upstream, RESOLVE_REF_READING,
                                    oid.hash, NULL)) != NULL)
-                       reference_rev = lookup_commit_reference(oid.hash);
+                       reference_rev = lookup_commit_reference(&oid);
        }
        if (!reference_rev)
                reference_rev = head_rev;
@@ -157,7 +157,7 @@ static int check_branch_commit(const char *branchname, const char *refname,
                               const struct object_id *oid, struct commit *head_rev,
                               int kinds, int force)
 {
-       struct commit *rev = lookup_commit_reference(oid->hash);
+       struct commit *rev = lookup_commit_reference(oid);
        if (!rev) {
                error(_("Couldn't look up commit object for '%s'"), refname);
                return -1;
@@ -211,7 +211,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
        }
 
        if (!force) {
-               head_rev = lookup_commit_reference(head_oid.hash);
+               head_rev = lookup_commit_reference(&head_oid);
                if (!head_rev)
                        die(_("Couldn't look up commit object for HEAD"));
        }
index bfa5419f335dc1db98059869de24f152cffb9aa6..afa99fb8a02ef9118cb99df0233393ab5721bfe4 100644 (file)
@@ -393,7 +393,7 @@ static int checkout_paths(const struct checkout_opts *opts,
                die(_("unable to write new index file"));
 
        read_ref_full("HEAD", 0, rev.hash, NULL);
-       head = lookup_commit_reference_gently(rev.hash, 1);
+       head = lookup_commit_reference_gently(&rev, 1);
 
        errs |= post_checkout_hook(head, head, 0);
        return errs;
@@ -833,7 +833,7 @@ static int switch_branches(const struct checkout_opts *opts,
        int flag, writeout_error = 0;
        memset(&old, 0, sizeof(old));
        old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
-       old.commit = lookup_commit_reference_gently(rev.hash, 1);
+       old.commit = lookup_commit_reference_gently(&rev, 1);
        if (!(flag & REF_ISSYMREF))
                old.path = NULL;
 
@@ -1047,7 +1047,7 @@ static int parse_branchname_arg(int argc, const char **argv,
        else
                new->path = NULL; /* not an existing branch */
 
-       new->commit = lookup_commit_reference_gently(rev->hash, 1);
+       new->commit = lookup_commit_reference_gently(rev, 1);
        if (!new->commit) {
                /* not a commit */
                *source_tree = parse_tree_indirect(rev->hash);
index de85b85254e49ba0211ea6476179fc6d4c774ca9..646f2879258e5a023e83117a5d247c7c2d05aec1 100644 (file)
@@ -682,7 +682,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
                        install_branch_config(0, head, option_origin, our->name);
                }
        } else if (our) {
-               struct commit *c = lookup_commit_reference(our->old_oid.hash);
+               struct commit *c = lookup_commit_reference(&our->old_oid);
                /* --branch specifies a non-branch (i.e. tags), detach HEAD */
                update_ref(msg, "HEAD", c->object.oid.hash,
                           NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
index 605017261c38dea1f5ada18c7d5b12446d6ea44f..f39c2b27375fcd70f050e56174b0966053652eef 100644 (file)
@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
                        if (get_sha1_commit(argv[i], oid.hash))
                                die("Not a valid object name %s", argv[i]);
                        assert_sha1_type(oid.hash, OBJ_COMMIT);
-                       new_parent(lookup_commit(oid.hash), &parents);
+                       new_parent(lookup_commit(&oid), &parents);
                        continue;
                }
 
index 8685c888f0cb0c7f3d9e54622456489725e5326e..e69f466d5b0e58a85faeb3b6a474b30b949816a9 100644 (file)
@@ -1430,7 +1430,7 @@ static void print_summary(const char *prefix, const struct object_id *oid,
        struct strbuf author_ident = STRBUF_INIT;
        struct strbuf committer_ident = STRBUF_INIT;
 
-       commit = lookup_commit(oid->hash);
+       commit = lookup_commit(oid);
        if (!commit)
                die(_("couldn't look up newly created commit"));
        if (parse_commit(commit))
@@ -1654,7 +1654,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        if (get_sha1("HEAD", oid.hash))
                current_head = NULL;
        else {
-               current_head = lookup_commit_or_die(oid.hash, "HEAD");
+               current_head = lookup_commit_or_die(&oid, "HEAD");
                if (parse_commit(current_head))
                        die(_("could not parse HEAD commit"));
        }
index a5cd8c513f96baaaa0d9a310e2bf02b8db41199b..f6032f593cb6a08e27411a0973cf01c4d8e43fa8 100644 (file)
@@ -281,7 +281,7 @@ static void describe(const char *arg, int last_one)
 
        if (get_oid(arg, &oid))
                die(_("Not a valid object name %s"), arg);
-       cmit = lookup_commit_reference(oid.hash);
+       cmit = lookup_commit_reference(&oid);
        if (!cmit)
                die(_("%s is not a valid '%s' object"), arg, commit_type);
 
@@ -309,7 +309,7 @@ static void describe(const char *arg, int last_one)
                struct commit *c;
                struct commit_name *n = hashmap_iter_first(&names, &iter);
                for (; n; n = hashmap_iter_next(&iter)) {
-                       c = lookup_commit_reference_gently(n->peeled.hash, 1);
+                       c = lookup_commit_reference_gently(&n->peeled, 1);
                        if (c)
                                c->util = n;
                }
index 326f88b6576d6c02e9a0bcecb5a0b402bb257372..e85a449df1305a4c29b398e35b42cc7fd8367830 100644 (file)
@@ -9,7 +9,7 @@ static struct rev_info log_tree_opt;
 
 static int diff_tree_commit_sha1(const struct object_id *oid)
 {
-       struct commit *commit = lookup_commit_reference(oid->hash);
+       struct commit *commit = lookup_commit_reference(oid);
        if (!commit)
                return -1;
        return log_tree_commit(&log_tree_opt, commit);
@@ -23,7 +23,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)
 
        /* Graft the fake parents locally to the commit */
        while (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {
-               struct commit *parent = lookup_commit(oid.hash);
+               struct commit *parent = lookup_commit(&oid);
                if (!pptr) {
                        /* Free the real parent list */
                        free_commit_list(commit->parents);
index e0220630d00cf2c069ce1a43e9511df57685acd2..b4521cb6274422ca79ada685c845a6b330a07024 100644 (file)
@@ -938,7 +938,7 @@ static void import_marks(char *input_file)
                        /* only commits */
                        continue;
 
-               commit = lookup_commit(oid.hash);
+               commit = lookup_commit(&oid);
                if (!commit)
                        die("not a commit? can't happen: %s", oid_to_hex(&oid));
 
index 5f2c2ab23e4cde17747147f23dcedaebe66c74a3..d4d573b98585b5780f9b2e52df42cc6594e3dc54 100644 (file)
@@ -636,8 +636,8 @@ static int update_local_ref(struct ref *ref,
                return r;
        }
 
-       current = lookup_commit_reference_gently(ref->old_oid.hash, 1);
-       updated = lookup_commit_reference_gently(ref->new_oid.hash, 1);
+       current = lookup_commit_reference_gently(&ref->old_oid, 1);
+       updated = lookup_commit_reference_gently(&ref->new_oid, 1);
        if (!current || !updated) {
                const char *msg;
                const char *what;
@@ -770,7 +770,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
                                continue;
                        }
 
-                       commit = lookup_commit_reference_gently(rm->old_oid.hash, 1);
+                       commit = lookup_commit_reference_gently(&rm->old_oid,
+                                                               1);
                        if (!commit)
                                rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;
 
index 6faa3c0d2424600a5e69dd20466aa763d95b586c..91dd753dd9fe8b6aeaec43a074e97f794dc00c3d 100644 (file)
@@ -566,7 +566,7 @@ static void find_merge_parents(struct merge_parents *result,
                commit_list_insert(parent, &parents);
                add_merge_parent(result, &obj->oid, &parent->object.oid);
        }
-       head_commit = lookup_commit(head->hash);
+       head_commit = lookup_commit(head);
        if (head_commit)
                commit_list_insert(head_commit, &parents);
        parents = reduce_heads(parents);
@@ -633,7 +633,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
                struct commit *head;
                struct rev_info rev;
 
-               head = lookup_commit_or_die(head_oid.hash, "HEAD");
+               head = lookup_commit_or_die(&head_oid, "HEAD");
                init_revisions(&rev, NULL);
                rev.commit_format = CMIT_FMT_ONELINE;
                rev.ignore_merges = 1;
index b3b10cc1edba2f6d77fdf4b12c328a7968fb5499..d8b56ea4102e4c652c58d70e8883d2e6ee34d20f 100644 (file)
@@ -878,8 +878,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
        o2 = rev->pending.objects[1].item;
        flags1 = o1->flags;
        flags2 = o2->flags;
-       c1 = lookup_commit_reference(o1->oid.hash);
-       c2 = lookup_commit_reference(o2->oid.hash);
+       c1 = lookup_commit_reference(&o1->oid);
+       c2 = lookup_commit_reference(&o2->oid);
 
        if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
                die(_("Not a range."));
@@ -1263,7 +1263,7 @@ static struct commit *get_base_commit(const char *base_commit,
 
                        if (get_oid(upstream, &oid))
                                die(_("Failed to resolve '%s' as a valid ref."), upstream);
-                       commit = lookup_commit_or_die(oid.hash, "upstream base");
+                       commit = lookup_commit_or_die(&oid, "upstream base");
                        base_list = get_merge_bases_many(commit, total, list);
                        /* There should be one and only one merge base. */
                        if (!base_list || base_list->next)
@@ -1819,7 +1819,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
 {
        struct object_id oid;
        if (get_oid(arg, &oid) == 0) {
-               struct commit *commit = lookup_commit_reference(oid.hash);
+               struct commit *commit = lookup_commit_reference(&oid);
                if (commit) {
                        commit->object.flags |= flags;
                        add_pending_object(revs, &commit->object, arg);
index cfe2a796f85ecf8dfbbb35d3232893929670b492..5c74ce249b8a6d0ba3e783febf2a1b2a200143b3 100644 (file)
@@ -41,7 +41,7 @@ static struct commit *get_commit_reference(const char *arg)
 
        if (get_oid(arg, &revkey))
                die("Not a valid object name %s", arg);
-       r = lookup_commit_reference(revkey.hash);
+       r = lookup_commit_reference(&revkey);
        if (!r)
                die("Not a valid commit name %s", arg);
 
@@ -120,7 +120,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
        if (is_null_oid(oid))
                return;
 
-       commit = lookup_commit(oid->hash);
+       commit = lookup_commit(oid);
        if (!commit ||
            (commit->object.flags & TMP_MARK) ||
            parse_commit(commit))
@@ -168,7 +168,7 @@ static int handle_fork_point(int argc, const char **argv)
        if (get_oid(commitname, &oid))
                die("Not a valid object name: '%s'", commitname);
 
-       derived = lookup_commit_reference(oid.hash);
+       derived = lookup_commit_reference(&oid);
        memset(&revs, 0, sizeof(revs));
        revs.initial = 1;
        for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
index 703827f00668ca0df807f35e300f0927d00075cd..f11b5f3de4f7cd849b8e8901bc1711464b2f8c8c 100644 (file)
@@ -1123,7 +1123,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        if (!branch || is_null_oid(&head_oid))
                head_commit = NULL;
        else
-               head_commit = lookup_commit_or_die(head_oid.hash, "HEAD");
+               head_commit = lookup_commit_or_die(&head_oid, "HEAD");
 
        init_diff_ui_defaults();
        git_config(git_merge_config, NULL);
index 7b891471c461ddc3cd2b9d3186cc8b005f68ca2b..f2847c41e00996f6ff129774961b5fafca513972 100644 (file)
@@ -706,7 +706,7 @@ static int merge_commit(struct notes_merge_options *o)
 
        if (get_oid("NOTES_MERGE_PARTIAL", &oid))
                die(_("failed to read ref NOTES_MERGE_PARTIAL"));
-       else if (!(partial = lookup_commit_reference(oid.hash)))
+       else if (!(partial = lookup_commit_reference(&oid)))
                die(_("could not find commit from NOTES_MERGE_PARTIAL."));
        else if (parse_commit(partial))
                die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
index dd1a4a94e41ed31617d31c80e097cbc044b3e3f3..2ffb6569a9b81dfc55088762447a7493bfc38463 100644 (file)
@@ -698,10 +698,10 @@ static int get_octopus_merge_base(struct object_id *merge_base,
 {
        struct commit_list *revs = NULL, *result;
 
-       commit_list_insert(lookup_commit_reference(curr_head->hash), &revs);
-       commit_list_insert(lookup_commit_reference(merge_head->hash), &revs);
+       commit_list_insert(lookup_commit_reference(curr_head), &revs);
+       commit_list_insert(lookup_commit_reference(merge_head), &revs);
        if (!is_null_oid(fork_point))
-               commit_list_insert(lookup_commit_reference(fork_point->hash), &revs);
+               commit_list_insert(lookup_commit_reference(fork_point), &revs);
 
        result = reduce_heads(get_octopus_merge_bases(revs));
        free_commit_list(revs);
@@ -865,9 +865,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
                struct commit_list *list = NULL;
                struct commit *merge_head, *head;
 
-               head = lookup_commit_reference(orig_head.hash);
+               head = lookup_commit_reference(&orig_head);
                commit_list_insert(head, &list);
-               merge_head = lookup_commit_reference(merge_heads.oid[0].hash);
+               merge_head = lookup_commit_reference(&merge_heads.oid[0]);
                if (is_descendant_of(merge_head, list)) {
                        /* we can fast-forward this without invoking rebase */
                        opt_ff = "--ff-only";
index d6718d326c68c556f11cfa3f9813134fa64c3563..4831116ea3058ba8a631f7822691dede386234a5 100644 (file)
@@ -192,7 +192,7 @@ static int keep_entry(struct commit **it, struct object_id *oid)
 
        if (is_null_oid(oid))
                return 1;
-       commit = lookup_commit_reference_gently(oid->hash, 1);
+       commit = lookup_commit_reference_gently(oid, 1);
        if (!commit)
                return 0;
 
@@ -261,7 +261,7 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit
                if (is_null_oid(oid))
                        return 0;
 
-               commit = lookup_commit_reference_gently(oid->hash, 1);
+               commit = lookup_commit_reference_gently(oid, 1);
 
                /* Not a commit -- keep it */
                if (!commit)
@@ -318,7 +318,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,
        struct commit *tip_commit;
        if (flags & REF_ISSYMREF)
                return 0;
-       tip_commit = lookup_commit_reference_gently(oid->hash, 1);
+       tip_commit = lookup_commit_reference_gently(oid, 1);
        if (!tip_commit)
                return 0;
        commit_list_insert(tip_commit, list);
@@ -335,7 +335,7 @@ static void reflog_expiry_prepare(const char *refname,
                cb->tip_commit = NULL;
                cb->unreachable_expire_kind = UE_HEAD;
        } else {
-               cb->tip_commit = lookup_commit_reference_gently(oid->hash, 1);
+               cb->tip_commit = lookup_commit_reference_gently(oid, 1);
                if (!cb->tip_commit)
                        cb->unreachable_expire_kind = UE_ALWAYS;
                else
index ab17668f4330a5e688d423a60c138768b9955e1b..3c44ef750e73f663e78dd81d18f85f67d31b891a 100644 (file)
@@ -328,7 +328,7 @@ static void replace_parents(struct strbuf *buf, int argc, const char **argv)
                struct object_id oid;
                if (get_oid(argv[i], &oid) < 0)
                        die(_("Not a valid object name: '%s'"), argv[i]);
-               lookup_commit_or_die(oid.hash, argv[i]);
+               lookup_commit_or_die(&oid, argv[i]);
                strbuf_addf(&new_parents, "parent %s\n", oid_to_hex(&oid));
        }
 
@@ -394,7 +394,7 @@ static int create_graft(int argc, const char **argv, int force)
 
        if (get_oid(old_ref, &old) < 0)
                die(_("Not a valid object name: '%s'"), old_ref);
-       commit = lookup_commit_or_die(old.hash, old_ref);
+       commit = lookup_commit_or_die(&old, old_ref);
 
        buffer = get_commit_buffer(commit, &size);
        strbuf_add(&buf, buffer, size);
index fc3b906c47bbcbefdc35b178016c031e46c06691..0be52fa36af414227a0069e50f7901640ade94d0 100644 (file)
@@ -303,7 +303,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
                struct commit *commit;
                if (get_sha1_committish(rev, oid.hash))
                        die(_("Failed to resolve '%s' as a valid revision."), rev);
-               commit = lookup_commit_reference(oid.hash);
+               commit = lookup_commit_reference(&oid);
                if (!commit)
                        die(_("Could not parse object '%s'."), rev);
                oidcpy(&oid, &commit->object.oid);
@@ -380,7 +380,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
                update_ref_status = reset_refs(rev, &oid);
 
                if (reset_type == HARD && !update_ref_status && !quiet)
-                       print_new_head_line(lookup_commit_reference(oid.hash));
+                       print_new_head_line(lookup_commit_reference(&oid));
        }
        if (!pathspec.nr)
                remove_branch_state();
index 4af122264444059a22788f29226c4712c311fdde..f650188ef353897898b133047d6f88f71cb17b00 100644 (file)
@@ -279,8 +279,8 @@ static int try_difference(const char *arg)
                if (symmetric) {
                        struct commit_list *exclude;
                        struct commit *a, *b;
-                       a = lookup_commit_reference(oid.hash);
-                       b = lookup_commit_reference(end.hash);
+                       a = lookup_commit_reference(&oid);
+                       b = lookup_commit_reference(&end);
                        exclude = get_merge_bases(a, b);
                        while (exclude) {
                                struct commit *commit = pop_commit(&exclude);
@@ -332,7 +332,7 @@ static int try_parent_shorthands(const char *arg)
                return 0;
        }
 
-       commit = lookup_commit_reference(oid.hash);
+       commit = lookup_commit_reference(&oid);
        if (exclude_parent &&
            exclude_parent > commit_list_count(commit->parents)) {
                *dotdot = '^';
index 19756595d57f27c35c72449d03a95cefd55aef15..71b6f3c17977d53312e52c729a860a8588f2a90d 100644 (file)
@@ -358,7 +358,7 @@ static void sort_ref_range(int bottom, int top)
 static int append_ref(const char *refname, const struct object_id *oid,
                      int allow_dups)
 {
-       struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
+       struct commit *commit = lookup_commit_reference_gently(oid, 1);
        int i;
 
        if (!commit)
@@ -816,7 +816,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                               MAX_REVS), MAX_REVS);
                if (get_sha1(ref_name[num_rev], revkey.hash))
                        die(_("'%s' is not a valid ref."), ref_name[num_rev]);
-               commit = lookup_commit_reference(revkey.hash);
+               commit = lookup_commit_reference(&revkey);
                if (!commit)
                        die(_("cannot find commit %s (%s)"),
                            ref_name[num_rev], oid_to_hex(&revkey));
index 597c925e38fce5ecc3b248af9047596746f6406b..d0070b37c215ca209c31ae1d9e774fe4944f806e 100644 (file)
@@ -328,7 +328,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
                }
                free(buf);
 
-               if ((c = lookup_commit_reference(oid->hash)) != NULL)
+               if ((c = lookup_commit_reference(oid)) != NULL)
                        strbuf_addf(sb, ", %s", show_date(c->date, 0, DATE_MODE(SHORT)));
                break;
        case OBJ_TREE:
index a5db1c427f55f8c636e7d1aadcf1499add04e81d..05b734e6d1bd469b63aa7b51921622a590730b6d 100644 (file)
@@ -25,7 +25,7 @@ static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned
 
        memset(&signature_check, 0, sizeof(signature_check));
 
-       ret = check_commit_signature(lookup_commit(oid->hash), &signature_check);
+       ret = check_commit_signature(lookup_commit(oid), &signature_check);
        print_signature_buffer(&signature_check, flags);
 
        signature_check_clear(&signature_check);
index 6e181bb3d851fc7178aa10a4b2a5a0a592de9285..3386dba3be424ecaa831acf0d48ae7697a7d8412 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -367,7 +367,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
                         * in terms of a tag (e.g. v2.0 from the range
                         * "v1.0..v2.0")?
                         */
-                       struct commit *one = lookup_commit_reference(oid.hash);
+                       struct commit *one = lookup_commit_reference(&oid);
                        struct object *obj;
 
                        if (e->item == &(one->object)) {
index ec41ba5e09f2b0fb7204219f00f3af85537b20cd..0f6c9b6bf3ad275edcce2690579c5d480df64e13 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -18,38 +18,38 @@ int save_commit_buffer = 1;
 
 const char *commit_type = "commit";
 
-struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
+struct commit *lookup_commit_reference_gently(const struct object_id *oid,
                                              int quiet)
 {
-       struct object *obj = deref_tag(parse_object(sha1), NULL, 0);
+       struct object *obj = deref_tag(parse_object(oid->hash), NULL, 0);
 
        if (!obj)
                return NULL;
        return object_as_type(obj, OBJ_COMMIT, quiet);
 }
 
-struct commit *lookup_commit_reference(const unsigned char *sha1)
+struct commit *lookup_commit_reference(const struct object_id *oid)
 {
-       return lookup_commit_reference_gently(sha1, 0);
+       return lookup_commit_reference_gently(oid, 0);
 }
 
-struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name)
+struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)
 {
-       struct commit *c = lookup_commit_reference(sha1);
+       struct commit *c = lookup_commit_reference(oid);
        if (!c)
                die(_("could not parse %s"), ref_name);
-       if (hashcmp(sha1, c->object.oid.hash)) {
+       if (oidcmp(oid, &c->object.oid)) {
                warning(_("%s %s is not a commit!"),
-                       ref_name, sha1_to_hex(sha1));
+                       ref_name, oid_to_hex(oid));
        }
        return c;
 }
 
-struct commit *lookup_commit(const unsigned char *sha1)
+struct commit *lookup_commit(const struct object_id *oid)
 {
-       struct object *obj = lookup_object(sha1);
+       struct object *obj = lookup_object(oid->hash);
        if (!obj)
-               return create_object(sha1, alloc_commit_node());
+               return create_object(oid->hash, alloc_commit_node());
        return object_as_type(obj, OBJ_COMMIT, 0);
 }
 
@@ -60,7 +60,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
 
        if (get_sha1_committish(name, oid.hash))
                return NULL;
-       commit = lookup_commit_reference(oid.hash);
+       commit = lookup_commit_reference(&oid);
        if (parse_commit(commit))
                return NULL;
        return commit;
@@ -350,7 +350,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
                 */
                if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
                        continue;
-               new_parent = lookup_commit(parent.hash);
+               new_parent = lookup_commit(&parent);
                if (new_parent)
                        pptr = &commit_list_insert(new_parent, pptr)->next;
        }
@@ -358,7 +358,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
                int i;
                struct commit *new_parent;
                for (i = 0; i < graft->nr_parent; i++) {
-                       new_parent = lookup_commit(graft->parent[i].hash);
+                       new_parent = lookup_commit(&graft->parent[i]);
                        if (!new_parent)
                                continue;
                        pptr = &commit_list_insert(new_parent, pptr)->next;
@@ -562,7 +562,7 @@ void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark)
 
        for (i = 0; i < a->nr; i++) {
                object = a->objects[i].item;
-               commit = lookup_commit_reference_gently(object->oid.hash, 1);
+               commit = lookup_commit_reference_gently(&object->oid, 1);
                if (commit)
                        clear_commit_marks(commit, mark);
        }
index 884177b8fa8b035cf76f03c9a9fa9044b78e4a6f..3488a285b1ddace67c0a36925268fcb62f8cc5e3 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -45,18 +45,18 @@ enum decoration_type {
 void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);
 const struct name_decoration *get_name_decoration(const struct object *obj);
 
-struct commit *lookup_commit(const unsigned char *sha1);
-struct commit *lookup_commit_reference(const unsigned char *sha1);
-struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
+struct commit *lookup_commit(const struct object_id *oid);
+struct commit *lookup_commit_reference(const struct object_id *oid);
+struct commit *lookup_commit_reference_gently(const struct object_id *oid,
                                              int quiet);
 struct commit *lookup_commit_reference_by_name(const char *name);
 
 /*
- * Look up object named by "sha1", dereference tag as necessary,
- * get a commit and return it. If "sha1" does not dereference to
+ * Look up object named by "oid", dereference tag as necessary,
+ * get a commit and return it. If "oid" does not dereference to
  * a commit, use ref_name to report an error and die.
  */
-struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name);
+struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);
 
 int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size);
 int parse_commit_gently(struct commit *item, int quiet_on_missing);
index ba886c9e7e2036f6d533ae2ed754b06e4bd0958f..585d5d6e856443d6961dc21bc59a9447ebb0a37f 100644 (file)
@@ -1763,8 +1763,8 @@ static int update_branch(struct branch *b)
        if (!force_update && !is_null_oid(&old_oid)) {
                struct commit *old_cmit, *new_cmit;
 
-               old_cmit = lookup_commit_reference_gently(old_oid.hash, 0);
-               new_cmit = lookup_commit_reference_gently(b->oid.hash, 0);
+               old_cmit = lookup_commit_reference_gently(&old_oid, 0);
+               new_cmit = lookup_commit_reference_gently(&b->oid, 0);
                if (!old_cmit || !new_cmit)
                        return error("Branch %s is missing commits.", b->name);
 
index d455ef97af276fdf7e7dbd78e62eef9d110e2d97..7ec75f278291a5b975afd22890214fc98ee7cebe 100644 (file)
@@ -483,7 +483,7 @@ static int find_common(struct fetch_pack_args *args,
                                case ACK_ready:
                                case ACK_continue: {
                                        struct commit *commit =
-                                               lookup_commit(result_oid->hash);
+                                               lookup_commit(result_oid);
                                        if (!commit)
                                                die(_("invalid commit %s"), oid_to_hex(result_oid));
                                        if (args->stateless_rpc
index f3dd0a5606b0b1cd115924ee46baf3ce292a416d..04568e4fbd4e6f8d7bca074331d19977f9c9dc28 100644 (file)
@@ -1569,8 +1569,9 @@ static void fetch_symref(const char *path, char **symref, struct object_id *oid)
 
 static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
 {
-       struct commit *head = lookup_commit_or_die(head_oid->hash, "HEAD");
-       struct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);
+       struct commit *head = lookup_commit_or_die(head_oid, "HEAD");
+       struct commit *branch = lookup_commit_or_die(&remote->old_oid,
+                                                    remote->name);
 
        return in_merge_bases(branch, head);
 }
index 4618dd04ca1b6bd2bf53481f39851fb4e5d02336..7fb1a85d2de3f0369829957f0aeb3382667c6482 100644 (file)
@@ -140,7 +140,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
 
 static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
 {
-       struct commit *commit = lookup_commit(graft->oid.hash);
+       struct commit *commit = lookup_commit(&graft->oid);
        if (!commit)
                return 0;
        add_name_decoration(DECORATION_GRAFTED, "grafted", &commit->object);
index 1cdd4984a4c53b86aad398a241f7a630b7758b36..2843e985760ae2b48f2f8103c573cee92fc1c350 100644 (file)
@@ -14,7 +14,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
        if (read_ref(ref, oid.hash) < 0)
                return 0;
 
-       commit = lookup_commit_reference_gently(oid.hash, 1);
+       commit = lookup_commit_reference_gently(&oid, 1);
        if (!commit)
                return 0;
 
index 06d8be9cbfc578e2e89d7d3d5d700296b08b577f..6244f6af9c655203953d91977f08dc982393ce78 100644 (file)
@@ -554,7 +554,7 @@ int notes_merge(struct notes_merge_options *o,
        else if (!check_refname_format(o->local_ref, 0) &&
                is_null_oid(&local_oid))
                local = NULL; /* local_sha1 == null_sha1 indicates unborn ref */
-       else if (!(local = lookup_commit_reference(local_oid.hash)))
+       else if (!(local = lookup_commit_reference(&local_oid)))
                die("Could not parse local commit %s (%s)",
                    oid_to_hex(&local_oid), o->local_ref);
        trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
@@ -572,7 +572,7 @@ int notes_merge(struct notes_merge_options *o,
                        die("Failed to resolve remote notes ref '%s'",
                            o->remote_ref);
                }
-       } else if (!(remote = lookup_commit_reference(remote_oid.hash))) {
+       } else if (!(remote = lookup_commit_reference(&remote_oid))) {
                die("Could not parse remote commit %s (%s)",
                    oid_to_hex(&remote_oid), o->remote_ref);
        }
index 36c1490aa782dfda49bccc416b8cc733adeafc70..325ff3daa37c5a0ce26c608b2e7bfd8a94b7f396 100644 (file)
@@ -18,7 +18,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
                /* Deduce parent commit from t->ref */
                struct object_id parent_oid;
                if (!read_ref(t->ref, parent_oid.hash)) {
-                       struct commit *parent = lookup_commit(parent_oid.hash);
+                       struct commit *parent = lookup_commit(&parent_oid);
                        if (parse_commit(parent))
                                die("Failed to find/parse commit %s", t->ref);
                        commit_list_insert(parent, &parents);
index e680d881a45756eb234a80a9909c24a7b146c1f7..fe222235668c125c5baec251d5c8c7ba9d509b02 100644 (file)
--- a/object.c
+++ b/object.c
@@ -182,9 +182,12 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
 
 struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
 {
+       struct object_id oid;
        struct object *obj;
        *eaten_p = 0;
 
+       hashcpy(oid.hash, sha1);
+
        obj = NULL;
        if (type == OBJ_BLOB) {
                struct blob *blob = lookup_blob(sha1);
@@ -206,7 +209,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
                        }
                }
        } else if (type == OBJ_COMMIT) {
-               struct commit *commit = lookup_commit(sha1);
+               struct commit *commit = lookup_commit(&oid);
                if (commit) {
                        if (parse_commit_buffer(commit, buffer, size))
                                return NULL;
index 35a941fddcc805e3c2f7115a142745f26a94ce77..8dd57cf6eacb818ec1693d0ab90d8708a53089f5 100644 (file)
@@ -87,7 +87,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)
                return -1;
        if (get_oid(arg, &oid))
                return error("malformed object name %s", arg);
-       commit = lookup_commit_reference(oid.hash);
+       commit = lookup_commit_reference(&oid);
        if (!commit)
                return error("no such commit %s", arg);
        commit_list_insert(commit, opt->value);
index 47cce0a1845cfc34b92c4cb65dbd77c94ffcae75..e1d18ac0d144806c1ea703e173ee2021b50cc4b0 100644 (file)
@@ -1782,7 +1782,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
         * non-commits early. The actual filtering is done later.
         */
        if (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {
-               commit = lookup_commit_reference_gently(oid->hash, 1);
+               commit = lookup_commit_reference_gently(oid, 1);
                if (!commit)
                        return 0;
                /* We perform the filtering for the '--contains' option... */
@@ -2108,7 +2108,7 @@ int parse_opt_merge_filter(const struct option *opt, const char *arg, int unset)
        if (get_oid(arg, &oid))
                die(_("malformed object name %s"), arg);
 
-       rf->merge_commit = lookup_commit_reference_gently(oid.hash, 0);
+       rf->merge_commit = lookup_commit_reference_gently(&oid, 0);
        if (!rf->merge_commit)
                return opterror(opt, "must point to a commit", 0);
 
index 801137c72ebb2edf196811a8031db603c61f376d..bf9a47d95b636a4d3161128e6a20175e79315272 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1296,7 +1296,7 @@ static void add_to_tips(struct tips *tips, const struct object_id *oid)
 
        if (is_null_oid(oid))
                return;
-       commit = lookup_commit_reference_gently(oid->hash, 1);
+       commit = lookup_commit_reference_gently(oid, 1);
        if (!commit || (commit->object.flags & TMP_MARK))
                return;
        commit->object.flags |= TMP_MARK;
@@ -1358,7 +1358,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
 
                        if (is_null_oid(&ref->new_oid))
                                continue;
-                       commit = lookup_commit_reference_gently(ref->new_oid.hash, 1);
+                       commit = lookup_commit_reference_gently(&ref->new_oid,
+                                                               1);
                        if (!commit)
                                /* not pushing a commit, which is not an error */
                                continue;
@@ -1585,8 +1586,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
                                reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
                        else if (!has_object_file(&ref->old_oid))
                                reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
-                       else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
-                                !lookup_commit_reference_gently(ref->new_oid.hash, 1))
+                       else if (!lookup_commit_reference_gently(&ref->old_oid, 1) ||
+                                !lookup_commit_reference_gently(&ref->new_oid, 1))
                                reject_reason = REF_STATUS_REJECT_NEEDS_FORCE;
                        else if (!ref_newer(&ref->new_oid, &ref->old_oid))
                                reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
@@ -2009,13 +2010,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
        /* Cannot stat if what we used to build on no longer exists */
        if (read_ref(base, oid.hash))
                return -1;
-       theirs = lookup_commit_reference(oid.hash);
+       theirs = lookup_commit_reference(&oid);
        if (!theirs)
                return -1;
 
        if (read_ref(branch->refname, oid.hash))
                return -1;
-       ours = lookup_commit_reference(oid.hash);
+       ours = lookup_commit_reference(&oid);
        if (!ours)
                return -1;
 
index 94536703417a73048dd8106f929a2626eee77ced..f8e0dee6d566af78eafab1b1044b2087d56f6732 100644 (file)
@@ -1395,10 +1395,10 @@ static void prepare_show_merge(struct rev_info *revs)
 
        if (get_oid("HEAD", &oid))
                die("--merge without HEAD?");
-       head = lookup_commit_or_die(oid.hash, "HEAD");
+       head = lookup_commit_or_die(&oid, "HEAD");
        if (get_oid("MERGE_HEAD", &oid))
                die("--merge without MERGE_HEAD?");
-       other = lookup_commit_or_die(oid.hash, "MERGE_HEAD");
+       other = lookup_commit_or_die(&oid, "MERGE_HEAD");
        add_pending_object(revs, &head->object, "HEAD");
        add_pending_object(revs, &other->object, "MERGE_HEAD");
        bases = get_merge_bases(head, other);
@@ -1500,10 +1500,10 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
 
                                a = (a_obj->type == OBJ_COMMIT
                                     ? (struct commit *)a_obj
-                                    : lookup_commit_reference(a_obj->oid.hash));
+                                    : lookup_commit_reference(&a_obj->oid));
                                b = (b_obj->type == OBJ_COMMIT
                                     ? (struct commit *)b_obj
-                                    : lookup_commit_reference(b_obj->oid.hash));
+                                    : lookup_commit_reference(&b_obj->oid));
                                if (!a || !b)
                                        goto missing;
                                exclude = get_merge_bases(a, b);
index e44c015b2c925bc3ee001097c9a181ffd66f2081..08676336026de0c82735f1bed4689f6b9673cbd6 100644 (file)
@@ -488,7 +488,7 @@ static int is_index_unchanged(void)
        if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
                return error(_("could not resolve HEAD commit\n"));
 
-       head_commit = lookup_commit(head_oid.hash);
+       head_commit = lookup_commit(&head_oid);
 
        /*
         * If head_commit is NULL, check_commit, called from
@@ -841,7 +841,7 @@ static int update_squash_messages(enum todo_command command,
 
                if (get_oid("HEAD", &head))
                        return error(_("need a HEAD to fixup"));
-               if (!(head_commit = lookup_commit_reference(head.hash)))
+               if (!(head_commit = lookup_commit_reference(&head)))
                        return error(_("could not read HEAD"));
                if (!(head_message = get_commit_buffer(head_commit, NULL)))
                        return error(_("could not read HEAD's commit message"));
@@ -1280,7 +1280,7 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
        if (status < 0)
                return -1;
 
-       item->commit = lookup_commit_reference(commit_oid.hash);
+       item->commit = lookup_commit_reference(&commit_oid);
        return !item->commit;
 }
 
@@ -2297,7 +2297,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
                        continue;
 
                if (!get_oid(name, &oid)) {
-                       if (!lookup_commit_reference_gently(oid.hash, 1)) {
+                       if (!lookup_commit_reference_gently(&oid, 1)) {
                                enum object_type type = sha1_object_info(oid.hash, NULL);
                                return error(_("%s: can't cherry-pick a %s"),
                                        name, typename(type));
index 8889190a90b89bf54350ccb21d778a60d79bea0f..390a09c41a1db40a3aca88df9e581804c57b891b 100644 (file)
@@ -354,7 +354,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
 
        type = sha1_object_info(oid->hash, NULL);
        if (type == OBJ_COMMIT) {
-               struct commit *commit = lookup_commit(oid->hash);
+               struct commit *commit = lookup_commit(oid);
                if (commit) {
                        struct pretty_print_context pp = {0};
                        pp.date_mode.type = DATE_SHORT;
@@ -729,7 +729,7 @@ static int get_parent(const char *name, int len,
 
        if (ret)
                return ret;
-       commit = lookup_commit_reference(oid.hash);
+       commit = lookup_commit_reference(&oid);
        if (parse_commit(commit))
                return -1;
        if (!idx) {
@@ -757,7 +757,7 @@ static int get_nth_ancestor(const char *name, int len,
        ret = get_sha1_1(name, len, oid.hash, GET_SHA1_COMMITTISH);
        if (ret)
                return ret;
-       commit = lookup_commit_reference(oid.hash);
+       commit = lookup_commit_reference(&oid);
        if (!commit)
                return -1;
 
@@ -1136,13 +1136,13 @@ int get_oid_mb(const char *name, struct object_id *oid)
        }
        if (st)
                return st;
-       one = lookup_commit_reference_gently(oid_tmp.hash, 0);
+       one = lookup_commit_reference_gently(&oid_tmp, 0);
        if (!one)
                return -1;
 
        if (get_sha1_committish(dots[3] ? (dots + 3) : "HEAD", oid_tmp.hash))
                return -1;
-       two = lookup_commit_reference_gently(oid_tmp.hash, 0);
+       two = lookup_commit_reference_gently(&oid_tmp, 0);
        if (!two)
                return -1;
        mbs = get_merge_bases(one, two);
index 1327ee16fc2d11c24cd58095d77141affe703d7f..6950cc24f02bd03480321eeaa0a36a32a460ed99 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -31,7 +31,7 @@ int register_shallow(const struct object_id *oid)
 {
        struct commit_graft *graft =
                xmalloc(sizeof(struct commit_graft));
-       struct commit *commit = lookup_commit(oid->hash);
+       struct commit *commit = lookup_commit(oid);
 
        oidcpy(&graft->oid, oid);
        graft->nr_parent = -1;
@@ -241,7 +241,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
        if (graft->nr_parent != -1)
                return 0;
        if (data->flags & SEEN_ONLY) {
-               struct commit *c = lookup_commit(graft->oid.hash);
+               struct commit *c = lookup_commit(&graft->oid);
                if (!c || !(c->object.flags & SEEN)) {
                        if (data->flags & VERBOSE)
                                printf("Removing %s from .git/shallow\n",
@@ -475,7 +475,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
        size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
        uint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */
        uint32_t *bitmap = paint_alloc(info);
-       struct commit *c = lookup_commit_reference_gently(oid->hash, 1);
+       struct commit *c = lookup_commit_reference_gently(oid, 1);
        if (!c)
                return;
        memset(bitmap, 0, bitmap_size);
@@ -531,7 +531,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
 static int mark_uninteresting(const char *refname, const struct object_id *oid,
                              int flags, void *cb_data)
 {
-       struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
+       struct commit *commit = lookup_commit_reference_gently(oid, 1);
        if (!commit)
                return 0;
        commit->object.flags |= UNINTERESTING;
@@ -599,7 +599,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
 
        /* Mark potential bottoms so we won't go out of bound */
        for (i = 0; i < nr_shallow; i++) {
-               struct commit *c = lookup_commit(oid[shallow[i]].hash);
+               struct commit *c = lookup_commit(&oid[shallow[i]]);
                c->object.flags |= BOTTOM;
        }
 
@@ -610,7 +610,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
                int bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);
                memset(used, 0, sizeof(*used) * info->shallow->nr);
                for (i = 0; i < nr_shallow; i++) {
-                       const struct commit *c = lookup_commit(oid[shallow[i]].hash);
+                       const struct commit *c = lookup_commit(&oid[shallow[i]]);
                        uint32_t **map = ref_bitmap_at(&pi.ref_bitmap, c);
                        if (*map)
                                used[shallow[i]] = xmemdupz(*map, bitmap_size);
@@ -641,7 +641,7 @@ static int add_ref(const char *refname, const struct object_id *oid,
 {
        struct commit_array *ca = cb_data;
        ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
-       ca->commits[ca->nr] = lookup_commit_reference_gently(oid->hash, 1);
+       ca->commits[ca->nr] = lookup_commit_reference_gently(oid, 1);
        if (ca->commits[ca->nr])
                ca->nr++;
        return 0;
@@ -679,7 +679,7 @@ static void post_assign_shallow(struct shallow_info *info,
        for (i = dst = 0; i < info->nr_theirs; i++) {
                if (i != dst)
                        info->theirs[dst] = info->theirs[i];
-               c = lookup_commit(oid[info->theirs[i]].hash);
+               c = lookup_commit(&oid[info->theirs[i]]);
                bitmap = ref_bitmap_at(ref_bitmap, c);
                if (!*bitmap)
                        continue;
@@ -700,7 +700,7 @@ static void post_assign_shallow(struct shallow_info *info,
        for (i = dst = 0; i < info->nr_ours; i++) {
                if (i != dst)
                        info->ours[dst] = info->ours[i];
-               c = lookup_commit(oid[info->ours[i]].hash);
+               c = lookup_commit(&oid[info->ours[i]]);
                bitmap = ref_bitmap_at(ref_bitmap, c);
                if (!*bitmap)
                        continue;
@@ -722,7 +722,7 @@ static void post_assign_shallow(struct shallow_info *info,
 int delayed_reachability_test(struct shallow_info *si, int c)
 {
        if (si->need_reachability_test[c]) {
-               struct commit *commit = lookup_commit(si->shallow->oid[c].hash);
+               struct commit *commit = lookup_commit(&si->shallow->oid[c]);
 
                if (!si->commits) {
                        struct commit_array ca;
index d5c28b9f1bde32442392076d0094b2f2bac85583..ba5429be15c9f21369366585ce067e8e1263552e 100644 (file)
@@ -447,8 +447,8 @@ static void show_submodule_header(FILE *f, const char *path,
         * Attempt to lookup the commit references, and determine if this is
         * a fast forward or fast backwards update.
         */
-       *left = lookup_commit_reference(one->hash);
-       *right = lookup_commit_reference(two->hash);
+       *left = lookup_commit_reference(one);
+       *right = lookup_commit_reference(two);
 
        /*
         * Warn about missing commits in the submodule project, but only if
@@ -634,7 +634,7 @@ static int check_has_commit(const struct object_id *oid, void *data)
 {
        int *has_commit = data;
 
-       if (!lookup_commit_reference(oid->hash))
+       if (!lookup_commit_reference(oid))
                *has_commit = 0;
 
        return 0;
@@ -899,7 +899,7 @@ int push_unpushed_submodules(struct oid_array *commits,
 static int is_submodule_commit_present(const char *path, struct object_id *oid)
 {
        int is_present = 0;
-       if (!add_submodule_odb(path) && lookup_commit_reference(oid->hash)) {
+       if (!add_submodule_odb(path) && lookup_commit_reference(oid)) {
                /* Even if the submodule is checked out and the commit is
                 * present, make sure it is reachable from a ref. */
                struct child_process cp = CHILD_PROCESS_INIT;
@@ -1592,9 +1592,9 @@ int merge_submodule(struct object_id *result, const char *path,
                return 0;
        }
 
-       if (!(commit_base = lookup_commit_reference(base->hash)) ||
-           !(commit_a = lookup_commit_reference(a->hash)) ||
-           !(commit_b = lookup_commit_reference(b->hash))) {
+       if (!(commit_base = lookup_commit_reference(base)) ||
+           !(commit_a = lookup_commit_reference(a)) ||
+           !(commit_b = lookup_commit_reference(b))) {
                MERGE_WARNING(path, "commits not present");
                return 0;
        }
diff --git a/tag.c b/tag.c
index 625f5cd71eacf1248cd809fdfda95af13fc02985..79b78d358331a3ca4a340f978bf85d3e7249c00b 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -146,7 +146,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
        } else if (!strcmp(type, tree_type)) {
                item->tagged = &lookup_tree(oid.hash)->object;
        } else if (!strcmp(type, commit_type)) {
-               item->tagged = &lookup_commit(oid.hash)->object;
+               item->tagged = &lookup_commit(&oid)->object;
        } else if (!strcmp(type, tag_type)) {
                item->tagged = &lookup_tag(oid.hash)->object;
        } else {
diff --git a/tree.c b/tree.c
index ce345c551117215882062f99c931b2182a63931a..33fa7ee7176474d4a3c218a76a7b238a86f720d6 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -91,7 +91,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
                else if (S_ISGITLINK(entry.mode)) {
                        struct commit *commit;
 
-                       commit = lookup_commit(entry.oid->hash);
+                       commit = lookup_commit(entry.oid);
                        if (!commit)
                                die("Commit %s in submodule path %s%s not found",
                                    oid_to_hex(entry.oid),
index 2c86e406f92d9bf0063e6be4f9d76fdbbac17c89..b499fcb7290ec690d61cd7601f9675100ce50312 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -206,7 +206,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
 static int mark_complete(const char *path, const struct object_id *oid,
                         int flag, void *cb_data)
 {
-       struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
+       struct commit *commit = lookup_commit_reference_gently(oid, 1);
 
        if (commit) {
                commit->object.flags |= COMPLETE;
index 03754849626d1bf117e3821fb7cdffcd594f694f..e5854ba6f8256663197cfe07b23debd046df395c 100644 (file)
@@ -1428,7 +1428,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
            /* sha1 is a commit? match without further lookup */
            (!oidcmp(&cb.noid, &oid) ||
             /* perhaps sha1 is a tag, try to dereference to a commit */
-            ((commit = lookup_commit_reference_gently(oid.hash, 1)) != NULL &&
+            ((commit = lookup_commit_reference_gently(&oid, 1)) != NULL &&
              !oidcmp(&cb.noid, &commit->object.oid)))) {
                const char *from = ref;
                if (!skip_prefix(from, "refs/tags/", &from))