Convert lookup_commit* to struct object_id

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>

brian m. carlson committed May 6, 2017 at 22:10 UTC bc83266abe36905cade4719cbaeb8a62d0a382da
50 files changed +138 -132
archive.c
+1 -1
@@ -360,7 +360,7 @@ static void parse_treeish_arg(const char **argv,
360 if (get_sha1(name, oid.hash))
361 die("Not a valid object name");
362
363 - commit = lookup_commit_reference_gently(oid.hash, 1);
363 + commit = lookup_commit_reference_gently(&oid, 1);
364 if (commit) {
365 commit_sha1 = commit->object.oid.hash;
366 archive_time = commit->date;
bisect.c
+1 -1
@@ -705,7 +705,7 @@ static int bisect_checkout(const unsigned char *bisect_rev, int no_checkout)
705
706 static struct commit *get_commit_reference(const struct object_id *oid)
707 {
708 - struct commit *r = lookup_commit_reference(oid->hash);
708 + struct commit *r = lookup_commit_reference(oid);
709 if (!r)
710 die(_("Not a valid commit name %s"), oid_to_hex(oid));
711 return r;
branch.c
+1 -1
@@ -286,7 +286,7 @@ void create_branch(const char *name, const char *start_name,
286 break;
287 }
288
289 - if ((commit = lookup_commit_reference(oid.hash)) == NULL)
289 + if ((commit = lookup_commit_reference(&oid)) == NULL)
290 die(_("Not a valid branch point: '%s'."), start_name);
291 oidcpy(&oid, &commit->object.oid);
292
builtin/am.c
+2 -2
@@ -1488,7 +1488,7 @@ static int parse_mail_rebase(struct am_state *state, const char *mail)
1488 if (get_mail_commit_oid(&commit_oid, mail) < 0)
1489 die(_("could not parse %s"), mail);
1490
1491 - commit = lookup_commit_or_die(commit_oid.hash, mail);
1491 + commit = lookup_commit_or_die(&commit_oid, mail);
1492
1493 get_commit_info(state, commit);
1494
@@ -1683,7 +1683,7 @@ static void do_commit(const struct am_state *state)
1683
1684 if (!get_sha1_commit("HEAD", parent.hash)) {
1685 old_oid = &parent;
1686 - commit_list_insert(lookup_commit(parent.hash), &parents);
1686 + commit_list_insert(lookup_commit(&parent), &parents);
1687 } else {
1688 old_oid = NULL;
1689 say(state, stderr, _("applying to an empty history"));
builtin/blame.c
+2 -2
@@ -2253,7 +2253,7 @@ static struct commit_list **append_parent(struct commit_list **tail, const struc
2253 {
2254 struct commit *parent;
2255
2256 - parent = lookup_commit_reference(oid->hash);
2256 + parent = lookup_commit_reference(oid);
2257 if (!parent)
2258 die("no such commit %s", oid_to_hex(oid));
2259 return &commit_list_insert(parent, tail)->next;
@@ -2475,7 +2475,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb)
2475 /* Do we have HEAD? */
2476 if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
2477 return NULL;
2478 - head_commit = lookup_commit_reference_gently(head_oid.hash, 1);
2478 + head_commit = lookup_commit_reference_gently(&head_oid, 1);
2479 if (!head_commit)
2480 return NULL;
2481
builtin/branch.c
+3 -3
@@ -124,7 +124,7 @@ static int branch_merged(int kind, const char *name,
124 (reference_name = reference_name_to_free =
125 resolve_refdup(upstream, RESOLVE_REF_READING,
126 oid.hash, NULL)) != NULL)
127 - reference_rev = lookup_commit_reference(oid.hash);
127 + reference_rev = lookup_commit_reference(&oid);
128 }
129 if (!reference_rev)
130 reference_rev = head_rev;
@@ -157,7 +157,7 @@ static int check_branch_commit(const char *branchname, const char *refname,
157 const struct object_id *oid, struct commit *head_rev,
158 int kinds, int force)
159 {
160 - struct commit *rev = lookup_commit_reference(oid->hash);
160 + struct commit *rev = lookup_commit_reference(oid);
161 if (!rev) {
162 error(_("Couldn't look up commit object for '%s'"), refname);
163 return -1;
@@ -211,7 +211,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
211 }
212
213 if (!force) {
214 - head_rev = lookup_commit_reference(head_oid.hash);
214 + head_rev = lookup_commit_reference(&head_oid);
215 if (!head_rev)
216 die(_("Couldn't look up commit object for HEAD"));
217 }
builtin/checkout.c
+3 -3
@@ -393,7 +393,7 @@ static int checkout_paths(const struct checkout_opts *opts,
393 die(_("unable to write new index file"));
394
395 read_ref_full("HEAD", 0, rev.hash, NULL);
396 - head = lookup_commit_reference_gently(rev.hash, 1);
396 + head = lookup_commit_reference_gently(&rev, 1);
397
398 errs |= post_checkout_hook(head, head, 0);
399 return errs;
@@ -833,7 +833,7 @@ static int switch_branches(const struct checkout_opts *opts,
833 int flag, writeout_error = 0;
834 memset(&old, 0, sizeof(old));
835 old.path = path_to_free = resolve_refdup("HEAD", 0, rev.hash, &flag);
836 - old.commit = lookup_commit_reference_gently(rev.hash, 1);
836 + old.commit = lookup_commit_reference_gently(&rev, 1);
837 if (!(flag & REF_ISSYMREF))
838 old.path = NULL;
839
@@ -1047,7 +1047,7 @@ static int parse_branchname_arg(int argc, const char **argv,
1047 else
1048 new->path = NULL; /* not an existing branch */
1049
1050 - new->commit = lookup_commit_reference_gently(rev->hash, 1);
1050 + new->commit = lookup_commit_reference_gently(rev, 1);
1051 if (!new->commit) {
1052 /* not a commit */
1053 *source_tree = parse_tree_indirect(rev->hash);
builtin/clone.c
+1 -1
@@ -682,7 +682,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
682 install_branch_config(0, head, option_origin, our->name);
683 }
684 } else if (our) {
685 - struct commit *c = lookup_commit_reference(our->old_oid.hash);
685 + struct commit *c = lookup_commit_reference(&our->old_oid);
686 /* --branch specifies a non-branch (i.e. tags), detach HEAD */
687 update_ref(msg, "HEAD", c->object.oid.hash,
688 NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
builtin/commit-tree.c
+1 -1
@@ -58,7 +58,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
58 if (get_sha1_commit(argv[i], oid.hash))
59 die("Not a valid object name %s", argv[i]);
60 assert_sha1_type(oid.hash, OBJ_COMMIT);
61 - new_parent(lookup_commit(oid.hash), &parents);
61 + new_parent(lookup_commit(&oid), &parents);
62 continue;
63 }
64
builtin/commit.c
+2 -2
@@ -1430,7 +1430,7 @@ static void print_summary(const char *prefix, const struct object_id *oid,
1430 struct strbuf author_ident = STRBUF_INIT;
1431 struct strbuf committer_ident = STRBUF_INIT;
1432
1433 - commit = lookup_commit(oid->hash);
1433 + commit = lookup_commit(oid);
1434 if (!commit)
1435 die(_("couldn't look up newly created commit"));
1436 if (parse_commit(commit))
@@ -1654,7 +1654,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
1654 if (get_sha1("HEAD", oid.hash))
1655 current_head = NULL;
1656 else {
1657 - current_head = lookup_commit_or_die(oid.hash, "HEAD");
1657 + current_head = lookup_commit_or_die(&oid, "HEAD");
1658 if (parse_commit(current_head))
1659 die(_("could not parse HEAD commit"));
1660 }
builtin/describe.c
+2 -2
@@ -281,7 +281,7 @@ static void describe(const char *arg, int last_one)
281
282 if (get_oid(arg, &oid))
283 die(_("Not a valid object name %s"), arg);
284 - cmit = lookup_commit_reference(oid.hash);
284 + cmit = lookup_commit_reference(&oid);
285 if (!cmit)
286 die(_("%s is not a valid '%s' object"), arg, commit_type);
287
@@ -309,7 +309,7 @@ static void describe(const char *arg, int last_one)
309 struct commit *c;
310 struct commit_name *n = hashmap_iter_first(&names, &iter);
311 for (; n; n = hashmap_iter_next(&iter)) {
312 - c = lookup_commit_reference_gently(n->peeled.hash, 1);
312 + c = lookup_commit_reference_gently(&n->peeled, 1);
313 if (c)
314 c->util = n;
315 }
builtin/diff-tree.c
+2 -2
@@ -9,7 +9,7 @@ static struct rev_info log_tree_opt;
9
10 static int diff_tree_commit_sha1(const struct object_id *oid)
11 {
12 - struct commit *commit = lookup_commit_reference(oid->hash);
12 + struct commit *commit = lookup_commit_reference(oid);
13 if (!commit)
14 return -1;
15 return log_tree_commit(&log_tree_opt, commit);
@@ -23,7 +23,7 @@ static int stdin_diff_commit(struct commit *commit, const char *p)
23
24 /* Graft the fake parents locally to the commit */
25 while (isspace(*p++) && !parse_oid_hex(p, &oid, &p)) {
26 - struct commit *parent = lookup_commit(oid.hash);
26 + struct commit *parent = lookup_commit(&oid);
27 if (!pptr) {
28 /* Free the real parent list */
29 free_commit_list(commit->parents);
builtin/fast-export.c
+1 -1
@@ -938,7 +938,7 @@ static void import_marks(char *input_file)
938 /* only commits */
939 continue;
940
941 - commit = lookup_commit(oid.hash);
941 + commit = lookup_commit(&oid);
942 if (!commit)
943 die("not a commit? can't happen: %s", oid_to_hex(&oid));
944
builtin/fetch.c
+4 -3
@@ -636,8 +636,8 @@ static int update_local_ref(struct ref *ref,
636 return r;
637 }
638
639 - current = lookup_commit_reference_gently(ref->old_oid.hash, 1);
640 - updated = lookup_commit_reference_gently(ref->new_oid.hash, 1);
639 + current = lookup_commit_reference_gently(&ref->old_oid, 1);
640 + updated = lookup_commit_reference_gently(&ref->new_oid, 1);
641 if (!current || !updated) {
642 const char *msg;
643 const char *what;
@@ -770,7 +770,8 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
770 continue;
771 }
772
773 - commit = lookup_commit_reference_gently(rm->old_oid.hash, 1);
773 + commit = lookup_commit_reference_gently(&rm->old_oid,
774 + 1);
775 if (!commit)
776 rm->fetch_head_status = FETCH_HEAD_NOT_FOR_MERGE;
777
builtin/fmt-merge-msg.c
+2 -2
@@ -566,7 +566,7 @@ static void find_merge_parents(struct merge_parents *result,
566 commit_list_insert(parent, &parents);
567 add_merge_parent(result, &obj->oid, &parent->object.oid);
568 }
569 - head_commit = lookup_commit(head->hash);
569 + head_commit = lookup_commit(head);
570 if (head_commit)
571 commit_list_insert(head_commit, &parents);
572 parents = reduce_heads(parents);
@@ -633,7 +633,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
633 struct commit *head;
634 struct rev_info rev;
635
636 - head = lookup_commit_or_die(head_oid.hash, "HEAD");
636 + head = lookup_commit_or_die(&head_oid, "HEAD");
637 init_revisions(&rev, NULL);
638 rev.commit_format = CMIT_FMT_ONELINE;
639 rev.ignore_merges = 1;
builtin/log.c
+4 -4
@@ -878,8 +878,8 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
878 o2 = rev->pending.objects[1].item;
879 flags1 = o1->flags;
880 flags2 = o2->flags;
881 - c1 = lookup_commit_reference(o1->oid.hash);
882 - c2 = lookup_commit_reference(o2->oid.hash);
881 + c1 = lookup_commit_reference(&o1->oid);
882 + c2 = lookup_commit_reference(&o2->oid);
883
884 if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
885 die(_("Not a range."));
@@ -1263,7 +1263,7 @@ static struct commit *get_base_commit(const char *base_commit,
1263
1264 if (get_oid(upstream, &oid))
1265 die(_("Failed to resolve '%s' as a valid ref."), upstream);
1266 - commit = lookup_commit_or_die(oid.hash, "upstream base");
1266 + commit = lookup_commit_or_die(&oid, "upstream base");
1267 base_list = get_merge_bases_many(commit, total, list);
1268 /* There should be one and only one merge base. */
1269 if (!base_list || base_list->next)
@@ -1819,7 +1819,7 @@ static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)
1819 {
1820 struct object_id oid;
1821 if (get_oid(arg, &oid) == 0) {
1822 - struct commit *commit = lookup_commit_reference(oid.hash);
1822 + struct commit *commit = lookup_commit_reference(&oid);
1823 if (commit) {
1824 commit->object.flags |= flags;
1825 add_pending_object(revs, &commit->object, arg);
builtin/merge-base.c
+3 -3
@@ -41,7 +41,7 @@ static struct commit *get_commit_reference(const char *arg)
41
42 if (get_oid(arg, &revkey))
43 die("Not a valid object name %s", arg);
44 - r = lookup_commit_reference(revkey.hash);
44 + r = lookup_commit_reference(&revkey);
45 if (!r)
46 die("Not a valid commit name %s", arg);
47
@@ -120,7 +120,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
120 if (is_null_oid(oid))
121 return;
122
123 - commit = lookup_commit(oid->hash);
123 + commit = lookup_commit(oid);
124 if (!commit ||
125 (commit->object.flags & TMP_MARK) ||
126 parse_commit(commit))
@@ -168,7 +168,7 @@ static int handle_fork_point(int argc, const char **argv)
168 if (get_oid(commitname, &oid))
169 die("Not a valid object name: '%s'", commitname);
170
171 - derived = lookup_commit_reference(oid.hash);
171 + derived = lookup_commit_reference(&oid);
172 memset(&revs, 0, sizeof(revs));
173 revs.initial = 1;
174 for_each_reflog_ent(refname, collect_one_reflog_ent, &revs);
builtin/merge.c
+1 -1
@@ -1123,7 +1123,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1123 if (!branch || is_null_oid(&head_oid))
1124 head_commit = NULL;
1125 else
1126 - head_commit = lookup_commit_or_die(head_oid.hash, "HEAD");
1126 + head_commit = lookup_commit_or_die(&head_oid, "HEAD");
1127
1128 init_diff_ui_defaults();
1129 git_config(git_merge_config, NULL);
builtin/notes.c
+1 -1
@@ -706,7 +706,7 @@ static int merge_commit(struct notes_merge_options *o)
706
707 if (get_oid("NOTES_MERGE_PARTIAL", &oid))
708 die(_("failed to read ref NOTES_MERGE_PARTIAL"));
709 - else if (!(partial = lookup_commit_reference(oid.hash)))
709 + else if (!(partial = lookup_commit_reference(&oid)))
710 die(_("could not find commit from NOTES_MERGE_PARTIAL."));
711 else if (parse_commit(partial))
712 die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
builtin/pull.c
+5 -5
@@ -698,10 +698,10 @@ static int get_octopus_merge_base(struct object_id *merge_base,
698 {
699 struct commit_list *revs = NULL, *result;
700
701 - commit_list_insert(lookup_commit_reference(curr_head->hash), &revs);
702 - commit_list_insert(lookup_commit_reference(merge_head->hash), &revs);
701 + commit_list_insert(lookup_commit_reference(curr_head), &revs);
702 + commit_list_insert(lookup_commit_reference(merge_head), &revs);
703 if (!is_null_oid(fork_point))
704 - commit_list_insert(lookup_commit_reference(fork_point->hash), &revs);
704 + commit_list_insert(lookup_commit_reference(fork_point), &revs);
705
706 result = reduce_heads(get_octopus_merge_bases(revs));
707 free_commit_list(revs);
@@ -865,9 +865,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
865 struct commit_list *list = NULL;
866 struct commit *merge_head, *head;
867
868 - head = lookup_commit_reference(orig_head.hash);
868 + head = lookup_commit_reference(&orig_head);
869 commit_list_insert(head, &list);
870 - merge_head = lookup_commit_reference(merge_heads.oid[0].hash);
870 + merge_head = lookup_commit_reference(&merge_heads.oid[0]);
871 if (is_descendant_of(merge_head, list)) {
872 /* we can fast-forward this without invoking rebase */
873 opt_ff = "--ff-only";
builtin/reflog.c
+4 -4
@@ -192,7 +192,7 @@ static int keep_entry(struct commit **it, struct object_id *oid)
192
193 if (is_null_oid(oid))
194 return 1;
195 - commit = lookup_commit_reference_gently(oid->hash, 1);
195 + commit = lookup_commit_reference_gently(oid, 1);
196 if (!commit)
197 return 0;
198
@@ -261,7 +261,7 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit
261 if (is_null_oid(oid))
262 return 0;
263
264 - commit = lookup_commit_reference_gently(oid->hash, 1);
264 + commit = lookup_commit_reference_gently(oid, 1);
265
266 /* Not a commit -- keep it */
267 if (!commit)
@@ -318,7 +318,7 @@ static int push_tip_to_list(const char *refname, const struct object_id *oid,
318 struct commit *tip_commit;
319 if (flags & REF_ISSYMREF)
320 return 0;
321 - tip_commit = lookup_commit_reference_gently(oid->hash, 1);
321 + tip_commit = lookup_commit_reference_gently(oid, 1);
322 if (!tip_commit)
323 return 0;
324 commit_list_insert(tip_commit, list);
@@ -335,7 +335,7 @@ static void reflog_expiry_prepare(const char *refname,
335 cb->tip_commit = NULL;
336 cb->unreachable_expire_kind = UE_HEAD;
337 } else {
338 - cb->tip_commit = lookup_commit_reference_gently(oid->hash, 1);
338 + cb->tip_commit = lookup_commit_reference_gently(oid, 1);
339 if (!cb->tip_commit)
340 cb->unreachable_expire_kind = UE_ALWAYS;
341 else
builtin/replace.c
+2 -2
@@ -328,7 +328,7 @@ static void replace_parents(struct strbuf *buf, int argc, const char **argv)
328 struct object_id oid;
329 if (get_oid(argv[i], &oid) < 0)
330 die(_("Not a valid object name: '%s'"), argv[i]);
331 - lookup_commit_or_die(oid.hash, argv[i]);
331 + lookup_commit_or_die(&oid, argv[i]);
332 strbuf_addf(&new_parents, "parent %s\n", oid_to_hex(&oid));
333 }
334
@@ -394,7 +394,7 @@ static int create_graft(int argc, const char **argv, int force)
394
395 if (get_oid(old_ref, &old) < 0)
396 die(_("Not a valid object name: '%s'"), old_ref);
397 - commit = lookup_commit_or_die(old.hash, old_ref);
397 + commit = lookup_commit_or_die(&old, old_ref);
398
399 buffer = get_commit_buffer(commit, &size);
400 strbuf_add(&buf, buffer, size);
builtin/reset.c
+2 -2
@@ -303,7 +303,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
303 struct commit *commit;
304 if (get_sha1_committish(rev, oid.hash))
305 die(_("Failed to resolve '%s' as a valid revision."), rev);
306 - commit = lookup_commit_reference(oid.hash);
306 + commit = lookup_commit_reference(&oid);
307 if (!commit)
308 die(_("Could not parse object '%s'."), rev);
309 oidcpy(&oid, &commit->object.oid);
@@ -380,7 +380,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
380 update_ref_status = reset_refs(rev, &oid);
381
382 if (reset_type == HARD && !update_ref_status && !quiet)
383 - print_new_head_line(lookup_commit_reference(oid.hash));
383 + print_new_head_line(lookup_commit_reference(&oid));
384 }
385 if (!pathspec.nr)
386 remove_branch_state();
builtin/rev-parse.c
+3 -3
@@ -279,8 +279,8 @@ static int try_difference(const char *arg)
279 if (symmetric) {
280 struct commit_list *exclude;
281 struct commit *a, *b;
282 - a = lookup_commit_reference(oid.hash);
283 - b = lookup_commit_reference(end.hash);
282 + a = lookup_commit_reference(&oid);
283 + b = lookup_commit_reference(&end);
284 exclude = get_merge_bases(a, b);
285 while (exclude) {
286 struct commit *commit = pop_commit(&exclude);
@@ -332,7 +332,7 @@ static int try_parent_shorthands(const char *arg)
332 return 0;
333 }
334
335 - commit = lookup_commit_reference(oid.hash);
335 + commit = lookup_commit_reference(&oid);
336 if (exclude_parent &&
337 exclude_parent > commit_list_count(commit->parents)) {
338 *dotdot = '^';
builtin/show-branch.c
+2 -2
@@ -358,7 +358,7 @@ static void sort_ref_range(int bottom, int top)
358 static int append_ref(const char *refname, const struct object_id *oid,
359 int allow_dups)
360 {
361 - struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
361 + struct commit *commit = lookup_commit_reference_gently(oid, 1);
362 int i;
363
364 if (!commit)
@@ -816,7 +816,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
816 MAX_REVS), MAX_REVS);
817 if (get_sha1(ref_name[num_rev], revkey.hash))
818 die(_("'%s' is not a valid ref."), ref_name[num_rev]);
819 - commit = lookup_commit_reference(revkey.hash);
819 + commit = lookup_commit_reference(&revkey);
820 if (!commit)
821 die(_("cannot find commit %s (%s)"),
822 ref_name[num_rev], oid_to_hex(&revkey));
builtin/tag.c
+1 -1
@@ -328,7 +328,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
328 }
329 free(buf);
330
331 - if ((c = lookup_commit_reference(oid->hash)) != NULL)
331 + if ((c = lookup_commit_reference(oid)) != NULL)
332 strbuf_addf(sb, ", %s", show_date(c->date, 0, DATE_MODE(SHORT)));
333 break;
334 case OBJ_TREE:
builtin/verify-commit.c
+1 -1
@@ -25,7 +25,7 @@ static int run_gpg_verify(const struct object_id *oid, const char *buf, unsigned
25
26 memset(&signature_check, 0, sizeof(signature_check));
27
28 - ret = check_commit_signature(lookup_commit(oid->hash), &signature_check);
28 + ret = check_commit_signature(lookup_commit(oid), &signature_check);
29 print_signature_buffer(&signature_check, flags);
30
31 signature_check_clear(&signature_check);
bundle.c
+1 -1
@@ -367,7 +367,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
367 * in terms of a tag (e.g. v2.0 from the range
368 * "v1.0..v2.0")?
369 */
370 - struct commit *one = lookup_commit_reference(oid.hash);
370 + struct commit *one = lookup_commit_reference(&oid);
371 struct object *obj;
372
373 if (e->item == &(one->object)) {
commit.c
+15 -15
@@ -18,38 +18,38 @@ int save_commit_buffer = 1;
18
19 const char *commit_type = "commit";
20
21 -struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
21 +struct commit *lookup_commit_reference_gently(const struct object_id *oid,
22 int quiet)
23 {
24 - struct object *obj = deref_tag(parse_object(sha1), NULL, 0);
24 + struct object *obj = deref_tag(parse_object(oid->hash), NULL, 0);
25
26 if (!obj)
27 return NULL;
28 return object_as_type(obj, OBJ_COMMIT, quiet);
29 }
30
31 -struct commit *lookup_commit_reference(const unsigned char *sha1)
31 +struct commit *lookup_commit_reference(const struct object_id *oid)
32 {
33 - return lookup_commit_reference_gently(sha1, 0);
33 + return lookup_commit_reference_gently(oid, 0);
34 }
35
36 -struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name)
36 +struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name)
37 {
38 - struct commit *c = lookup_commit_reference(sha1);
38 + struct commit *c = lookup_commit_reference(oid);
39 if (!c)
40 die(_("could not parse %s"), ref_name);
41 - if (hashcmp(sha1, c->object.oid.hash)) {
41 + if (oidcmp(oid, &c->object.oid)) {
42 warning(_("%s %s is not a commit!"),
43 - ref_name, sha1_to_hex(sha1));
43 + ref_name, oid_to_hex(oid));
44 }
45 return c;
46 }
47
48 -struct commit *lookup_commit(const unsigned char *sha1)
48 +struct commit *lookup_commit(const struct object_id *oid)
49 {
50 - struct object *obj = lookup_object(sha1);
50 + struct object *obj = lookup_object(oid->hash);
51 if (!obj)
52 - return create_object(sha1, alloc_commit_node());
52 + return create_object(oid->hash, alloc_commit_node());
53 return object_as_type(obj, OBJ_COMMIT, 0);
54 }
55
@@ -60,7 +60,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
60
61 if (get_sha1_committish(name, oid.hash))
62 return NULL;
63 - commit = lookup_commit_reference(oid.hash);
63 + commit = lookup_commit_reference(&oid);
64 if (parse_commit(commit))
65 return NULL;
66 return commit;
@@ -350,7 +350,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
350 */
351 if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
352 continue;
353 - new_parent = lookup_commit(parent.hash);
353 + new_parent = lookup_commit(&parent);
354 if (new_parent)
355 pptr = &commit_list_insert(new_parent, pptr)->next;
356 }
@@ -358,7 +358,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
358 int i;
359 struct commit *new_parent;
360 for (i = 0; i < graft->nr_parent; i++) {
361 - new_parent = lookup_commit(graft->parent[i].hash);
361 + new_parent = lookup_commit(&graft->parent[i]);
362 if (!new_parent)
363 continue;
364 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)
562
563 for (i = 0; i < a->nr; i++) {
564 object = a->objects[i].item;
565 - commit = lookup_commit_reference_gently(object->oid.hash, 1);
565 + commit = lookup_commit_reference_gently(&object->oid, 1);
566 if (commit)
567 clear_commit_marks(commit, mark);
568 }
commit.h
+6 -6
@@ -45,18 +45,18 @@ enum decoration_type {
45 void add_name_decoration(enum decoration_type type, const char *name, struct object *obj);
46 const struct name_decoration *get_name_decoration(const struct object *obj);
47
48 -struct commit *lookup_commit(const unsigned char *sha1);
49 -struct commit *lookup_commit_reference(const unsigned char *sha1);
50 -struct commit *lookup_commit_reference_gently(const unsigned char *sha1,
48 +struct commit *lookup_commit(const struct object_id *oid);
49 +struct commit *lookup_commit_reference(const struct object_id *oid);
50 +struct commit *lookup_commit_reference_gently(const struct object_id *oid,
51 int quiet);
52 struct commit *lookup_commit_reference_by_name(const char *name);
53
54 /*
55 - * Look up object named by "sha1", dereference tag as necessary,
56 - * get a commit and return it. If "sha1" does not dereference to
55 + * Look up object named by "oid", dereference tag as necessary,
56 + * get a commit and return it. If "oid" does not dereference to
57 * a commit, use ref_name to report an error and die.
58 */
59 -struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name);
59 +struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);
60
61 int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size);
62 int parse_commit_gently(struct commit *item, int quiet_on_missing);
fast-import.c
+2 -2
@@ -1763,8 +1763,8 @@ static int update_branch(struct branch *b)
1763 if (!force_update && !is_null_oid(&old_oid)) {
1764 struct commit *old_cmit, *new_cmit;
1765
1766 - old_cmit = lookup_commit_reference_gently(old_oid.hash, 0);
1767 - new_cmit = lookup_commit_reference_gently(b->oid.hash, 0);
1766 + old_cmit = lookup_commit_reference_gently(&old_oid, 0);
1767 + new_cmit = lookup_commit_reference_gently(&b->oid, 0);
1768 if (!old_cmit || !new_cmit)
1769 return error("Branch %s is missing commits.", b->name);
1770
fetch-pack.c
+1 -1
@@ -483,7 +483,7 @@ static int find_common(struct fetch_pack_args *args,
483 case ACK_ready:
484 case ACK_continue: {
485 struct commit *commit =
486 - lookup_commit(result_oid->hash);
486 + lookup_commit(result_oid);
487 if (!commit)
488 die(_("invalid commit %s"), oid_to_hex(result_oid));
489 if (args->stateless_rpc
http-push.c
+3 -2
@@ -1569,8 +1569,9 @@ static void fetch_symref(const char *path, char **symref, struct object_id *oid)
1569
1570 static int verify_merge_base(struct object_id *head_oid, struct ref *remote)
1571 {
1572 - struct commit *head = lookup_commit_or_die(head_oid->hash, "HEAD");
1573 - struct commit *branch = lookup_commit_or_die(remote->old_oid.hash, remote->name);
1572 + struct commit *head = lookup_commit_or_die(head_oid, "HEAD");
1573 + struct commit *branch = lookup_commit_or_die(&remote->old_oid,
1574 + remote->name);
1575
1576 return in_merge_bases(branch, head);
1577 }
log-tree.c
+1 -1
@@ -140,7 +140,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid,
140
141 static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
142 {
143 - struct commit *commit = lookup_commit(graft->oid.hash);
143 + struct commit *commit = lookup_commit(&graft->oid);
144 if (!commit)
145 return 0;
146 add_name_decoration(DECORATION_GRAFTED, "grafted", &commit->object);
notes-cache.c
+1 -1
@@ -14,7 +14,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)
14 if (read_ref(ref, oid.hash) < 0)
15 return 0;
16
17 - commit = lookup_commit_reference_gently(oid.hash, 1);
17 + commit = lookup_commit_reference_gently(&oid, 1);
18 if (!commit)
19 return 0;
20
notes-merge.c
+2 -2
@@ -554,7 +554,7 @@ int notes_merge(struct notes_merge_options *o,
554 else if (!check_refname_format(o->local_ref, 0) &&
555 is_null_oid(&local_oid))
556 local = NULL; /* local_sha1 == null_sha1 indicates unborn ref */
557 - else if (!(local = lookup_commit_reference(local_oid.hash)))
557 + else if (!(local = lookup_commit_reference(&local_oid)))
558 die("Could not parse local commit %s (%s)",
559 oid_to_hex(&local_oid), o->local_ref);
560 trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
@@ -572,7 +572,7 @@ int notes_merge(struct notes_merge_options *o,
572 die("Failed to resolve remote notes ref '%s'",
573 o->remote_ref);
574 }
575 - } else if (!(remote = lookup_commit_reference(remote_oid.hash))) {
575 + } else if (!(remote = lookup_commit_reference(&remote_oid))) {
576 die("Could not parse remote commit %s (%s)",
577 oid_to_hex(&remote_oid), o->remote_ref);
578 }
notes-utils.c
+1 -1
@@ -18,7 +18,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
18 /* Deduce parent commit from t->ref */
19 struct object_id parent_oid;
20 if (!read_ref(t->ref, parent_oid.hash)) {
21 - struct commit *parent = lookup_commit(parent_oid.hash);
21 + struct commit *parent = lookup_commit(&parent_oid);
22 if (parse_commit(parent))
23 die("Failed to find/parse commit %s", t->ref);
24 commit_list_insert(parent, &parents);
object.c
+4 -1
@@ -182,9 +182,12 @@ struct object *lookup_unknown_object(const unsigned char *sha1)
182
183 struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p)
184 {
185 + struct object_id oid;
186 struct object *obj;
187 *eaten_p = 0;
188
189 + hashcpy(oid.hash, sha1);
190 +
191 obj = NULL;
192 if (type == OBJ_BLOB) {
193 struct blob *blob = lookup_blob(sha1);
@@ -206,7 +209,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t
209 }
210 }
211 } else if (type == OBJ_COMMIT) {
209 - struct commit *commit = lookup_commit(sha1);
212 + struct commit *commit = lookup_commit(&oid);
213 if (commit) {
214 if (parse_commit_buffer(commit, buffer, size))
215 return NULL;
parse-options-cb.c
+1 -1
@@ -87,7 +87,7 @@ int parse_opt_commits(const struct option *opt, const char *arg, int unset)
87 return -1;
88 if (get_oid(arg, &oid))
89 return error("malformed object name %s", arg);
90 - commit = lookup_commit_reference(oid.hash);
90 + commit = lookup_commit_reference(&oid);
91 if (!commit)
92 return error("no such commit %s", arg);
93 commit_list_insert(commit, opt->value);
ref-filter.c
+2 -2
@@ -1782,7 +1782,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
1782 * non-commits early. The actual filtering is done later.
1783 */
1784 if (filter->merge_commit || filter->with_commit || filter->no_commit || filter->verbose) {
1785 - commit = lookup_commit_reference_gently(oid->hash, 1);
1785 + commit = lookup_commit_reference_gently(oid, 1);
1786 if (!commit)
1787 return 0;
1788 /* 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)
2108 if (get_oid(arg, &oid))
2109 die(_("malformed object name %s"), arg);
2110
2111 - rf->merge_commit = lookup_commit_reference_gently(oid.hash, 0);
2111 + rf->merge_commit = lookup_commit_reference_gently(&oid, 0);
2112 if (!rf->merge_commit)
2113 return opterror(opt, "must point to a commit", 0);
2114
remote.c
+7 -6
@@ -1296,7 +1296,7 @@ static void add_to_tips(struct tips *tips, const struct object_id *oid)
1296
1297 if (is_null_oid(oid))
1298 return;
1299 - commit = lookup_commit_reference_gently(oid->hash, 1);
1299 + commit = lookup_commit_reference_gently(oid, 1);
1300 if (!commit || (commit->object.flags & TMP_MARK))
1301 return;
1302 commit->object.flags |= TMP_MARK;
@@ -1358,7 +1358,8 @@ static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***ds
1358
1359 if (is_null_oid(&ref->new_oid))
1360 continue;
1361 - commit = lookup_commit_reference_gently(ref->new_oid.hash, 1);
1361 + commit = lookup_commit_reference_gently(&ref->new_oid,
1362 + 1);
1363 if (!commit)
1364 /* not pushing a commit, which is not an error */
1365 continue;
@@ -1585,8 +1586,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
1586 reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
1587 else if (!has_object_file(&ref->old_oid))
1588 reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
1588 - else if (!lookup_commit_reference_gently(ref->old_oid.hash, 1) ||
1589 - !lookup_commit_reference_gently(ref->new_oid.hash, 1))
1589 + else if (!lookup_commit_reference_gently(&ref->old_oid, 1) ||
1590 + !lookup_commit_reference_gently(&ref->new_oid, 1))
1591 reject_reason = REF_STATUS_REJECT_NEEDS_FORCE;
1592 else if (!ref_newer(&ref->new_oid, &ref->old_oid))
1593 reject_reason = REF_STATUS_REJECT_NONFASTFORWARD;
@@ -2009,13 +2010,13 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
2010 /* Cannot stat if what we used to build on no longer exists */
2011 if (read_ref(base, oid.hash))
2012 return -1;
2012 - theirs = lookup_commit_reference(oid.hash);
2013 + theirs = lookup_commit_reference(&oid);
2014 if (!theirs)
2015 return -1;
2016
2017 if (read_ref(branch->refname, oid.hash))
2018 return -1;
2018 - ours = lookup_commit_reference(oid.hash);
2019 + ours = lookup_commit_reference(&oid);
2020 if (!ours)
2021 return -1;
2022
revision.c
+4 -4
@@ -1395,10 +1395,10 @@ static void prepare_show_merge(struct rev_info *revs)
1395
1396 if (get_oid("HEAD", &oid))
1397 die("--merge without HEAD?");
1398 - head = lookup_commit_or_die(oid.hash, "HEAD");
1398 + head = lookup_commit_or_die(&oid, "HEAD");
1399 if (get_oid("MERGE_HEAD", &oid))
1400 die("--merge without MERGE_HEAD?");
1401 - other = lookup_commit_or_die(oid.hash, "MERGE_HEAD");
1401 + other = lookup_commit_or_die(&oid, "MERGE_HEAD");
1402 add_pending_object(revs, &head->object, "HEAD");
1403 add_pending_object(revs, &other->object, "MERGE_HEAD");
1404 bases = get_merge_bases(head, other);
@@ -1500,10 +1500,10 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1500
1501 a = (a_obj->type == OBJ_COMMIT
1502 ? (struct commit *)a_obj
1503 - : lookup_commit_reference(a_obj->oid.hash));
1503 + : lookup_commit_reference(&a_obj->oid));
1504 b = (b_obj->type == OBJ_COMMIT
1505 ? (struct commit *)b_obj
1506 - : lookup_commit_reference(b_obj->oid.hash));
1506 + : lookup_commit_reference(&b_obj->oid));
1507 if (!a || !b)
1508 goto missing;
1509 exclude = get_merge_bases(a, b);
sequencer.c
+4 -4
@@ -488,7 +488,7 @@ static int is_index_unchanged(void)
488 if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL))
489 return error(_("could not resolve HEAD commit\n"));
490
491 - head_commit = lookup_commit(head_oid.hash);
491 + head_commit = lookup_commit(&head_oid);
492
493 /*
494 * If head_commit is NULL, check_commit, called from
@@ -841,7 +841,7 @@ static int update_squash_messages(enum todo_command command,
841
842 if (get_oid("HEAD", &head))
843 return error(_("need a HEAD to fixup"));
844 - if (!(head_commit = lookup_commit_reference(head.hash)))
844 + if (!(head_commit = lookup_commit_reference(&head)))
845 return error(_("could not read HEAD"));
846 if (!(head_message = get_commit_buffer(head_commit, NULL)))
847 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)
1280 if (status < 0)
1281 return -1;
1282
1283 - item->commit = lookup_commit_reference(commit_oid.hash);
1283 + item->commit = lookup_commit_reference(&commit_oid);
1284 return !item->commit;
1285 }
1286
@@ -2297,7 +2297,7 @@ int sequencer_pick_revisions(struct replay_opts *opts)
2297 continue;
2298
2299 if (!get_oid(name, &oid)) {
2300 - if (!lookup_commit_reference_gently(oid.hash, 1)) {
2300 + if (!lookup_commit_reference_gently(&oid, 1)) {
2301 enum object_type type = sha1_object_info(oid.hash, NULL);
2302 return error(_("%s: can't cherry-pick a %s"),
2303 name, typename(type));
sha1_name.c
+5 -5
@@ -354,7 +354,7 @@ static int show_ambiguous_object(const struct object_id *oid, void *data)
354
355 type = sha1_object_info(oid->hash, NULL);
356 if (type == OBJ_COMMIT) {
357 - struct commit *commit = lookup_commit(oid->hash);
357 + struct commit *commit = lookup_commit(oid);
358 if (commit) {
359 struct pretty_print_context pp = {0};
360 pp.date_mode.type = DATE_SHORT;
@@ -729,7 +729,7 @@ static int get_parent(const char *name, int len,
729
730 if (ret)
731 return ret;
732 - commit = lookup_commit_reference(oid.hash);
732 + commit = lookup_commit_reference(&oid);
733 if (parse_commit(commit))
734 return -1;
735 if (!idx) {
@@ -757,7 +757,7 @@ static int get_nth_ancestor(const char *name, int len,
757 ret = get_sha1_1(name, len, oid.hash, GET_SHA1_COMMITTISH);
758 if (ret)
759 return ret;
760 - commit = lookup_commit_reference(oid.hash);
760 + commit = lookup_commit_reference(&oid);
761 if (!commit)
762 return -1;
763
@@ -1136,13 +1136,13 @@ int get_oid_mb(const char *name, struct object_id *oid)
1136 }
1137 if (st)
1138 return st;
1139 - one = lookup_commit_reference_gently(oid_tmp.hash, 0);
1139 + one = lookup_commit_reference_gently(&oid_tmp, 0);
1140 if (!one)
1141 return -1;
1142
1143 if (get_sha1_committish(dots[3] ? (dots + 3) : "HEAD", oid_tmp.hash))
1144 return -1;
1145 - two = lookup_commit_reference_gently(oid_tmp.hash, 0);
1145 + two = lookup_commit_reference_gently(&oid_tmp, 0);
1146 if (!two)
1147 return -1;
1148 mbs = get_merge_bases(one, two);
shallow.c
+10 -10
@@ -31,7 +31,7 @@ int register_shallow(const struct object_id *oid)
31 {
32 struct commit_graft *graft =
33 xmalloc(sizeof(struct commit_graft));
34 - struct commit *commit = lookup_commit(oid->hash);
34 + struct commit *commit = lookup_commit(oid);
35
36 oidcpy(&graft->oid, oid);
37 graft->nr_parent = -1;
@@ -241,7 +241,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
241 if (graft->nr_parent != -1)
242 return 0;
243 if (data->flags & SEEN_ONLY) {
244 - struct commit *c = lookup_commit(graft->oid.hash);
244 + struct commit *c = lookup_commit(&graft->oid);
245 if (!c || !(c->object.flags & SEEN)) {
246 if (data->flags & VERBOSE)
247 printf("Removing %s from .git/shallow\n",
@@ -475,7 +475,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
475 size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
476 uint32_t *tmp = xmalloc(bitmap_size); /* to be freed before return */
477 uint32_t *bitmap = paint_alloc(info);
478 - struct commit *c = lookup_commit_reference_gently(oid->hash, 1);
478 + struct commit *c = lookup_commit_reference_gently(oid, 1);
479 if (!c)
480 return;
481 memset(bitmap, 0, bitmap_size);
@@ -531,7 +531,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
531 static int mark_uninteresting(const char *refname, const struct object_id *oid,
532 int flags, void *cb_data)
533 {
534 - struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
534 + struct commit *commit = lookup_commit_reference_gently(oid, 1);
535 if (!commit)
536 return 0;
537 commit->object.flags |= UNINTERESTING;
@@ -599,7 +599,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
599
600 /* Mark potential bottoms so we won't go out of bound */
601 for (i = 0; i < nr_shallow; i++) {
602 - struct commit *c = lookup_commit(oid[shallow[i]].hash);
602 + struct commit *c = lookup_commit(&oid[shallow[i]]);
603 c->object.flags |= BOTTOM;
604 }
605
@@ -610,7 +610,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
610 int bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);
611 memset(used, 0, sizeof(*used) * info->shallow->nr);
612 for (i = 0; i < nr_shallow; i++) {
613 - const struct commit *c = lookup_commit(oid[shallow[i]].hash);
613 + const struct commit *c = lookup_commit(&oid[shallow[i]]);
614 uint32_t **map = ref_bitmap_at(&pi.ref_bitmap, c);
615 if (*map)
616 used[shallow[i]] = xmemdupz(*map, bitmap_size);
@@ -641,7 +641,7 @@ static int add_ref(const char *refname, const struct object_id *oid,
641 {
642 struct commit_array *ca = cb_data;
643 ALLOC_GROW(ca->commits, ca->nr + 1, ca->alloc);
644 - ca->commits[ca->nr] = lookup_commit_reference_gently(oid->hash, 1);
644 + ca->commits[ca->nr] = lookup_commit_reference_gently(oid, 1);
645 if (ca->commits[ca->nr])
646 ca->nr++;
647 return 0;
@@ -679,7 +679,7 @@ static void post_assign_shallow(struct shallow_info *info,
679 for (i = dst = 0; i < info->nr_theirs; i++) {
680 if (i != dst)
681 info->theirs[dst] = info->theirs[i];
682 - c = lookup_commit(oid[info->theirs[i]].hash);
682 + c = lookup_commit(&oid[info->theirs[i]]);
683 bitmap = ref_bitmap_at(ref_bitmap, c);
684 if (!*bitmap)
685 continue;
@@ -700,7 +700,7 @@ static void post_assign_shallow(struct shallow_info *info,
700 for (i = dst = 0; i < info->nr_ours; i++) {
701 if (i != dst)
702 info->ours[dst] = info->ours[i];
703 - c = lookup_commit(oid[info->ours[i]].hash);
703 + c = lookup_commit(&oid[info->ours[i]]);
704 bitmap = ref_bitmap_at(ref_bitmap, c);
705 if (!*bitmap)
706 continue;
@@ -722,7 +722,7 @@ static void post_assign_shallow(struct shallow_info *info,
722 int delayed_reachability_test(struct shallow_info *si, int c)
723 {
724 if (si->need_reachability_test[c]) {
725 - struct commit *commit = lookup_commit(si->shallow->oid[c].hash);
725 + struct commit *commit = lookup_commit(&si->shallow->oid[c]);
726
727 if (!si->commits) {
728 struct commit_array ca;
submodule.c
+7 -7
@@ -447,8 +447,8 @@ static void show_submodule_header(FILE *f, const char *path,
447 * Attempt to lookup the commit references, and determine if this is
448 * a fast forward or fast backwards update.
449 */
450 - *left = lookup_commit_reference(one->hash);
451 - *right = lookup_commit_reference(two->hash);
450 + *left = lookup_commit_reference(one);
451 + *right = lookup_commit_reference(two);
452
453 /*
454 * 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)
634 {
635 int *has_commit = data;
636
637 - if (!lookup_commit_reference(oid->hash))
637 + if (!lookup_commit_reference(oid))
638 *has_commit = 0;
639
640 return 0;
@@ -899,7 +899,7 @@ int push_unpushed_submodules(struct oid_array *commits,
899 static int is_submodule_commit_present(const char *path, struct object_id *oid)
900 {
901 int is_present = 0;
902 - if (!add_submodule_odb(path) && lookup_commit_reference(oid->hash)) {
902 + if (!add_submodule_odb(path) && lookup_commit_reference(oid)) {
903 /* Even if the submodule is checked out and the commit is
904 * present, make sure it is reachable from a ref. */
905 struct child_process cp = CHILD_PROCESS_INIT;
@@ -1592,9 +1592,9 @@ int merge_submodule(struct object_id *result, const char *path,
1592 return 0;
1593 }
1594
1595 - if (!(commit_base = lookup_commit_reference(base->hash)) ||
1596 - !(commit_a = lookup_commit_reference(a->hash)) ||
1597 - !(commit_b = lookup_commit_reference(b->hash))) {
1595 + if (!(commit_base = lookup_commit_reference(base)) ||
1596 + !(commit_a = lookup_commit_reference(a)) ||
1597 + !(commit_b = lookup_commit_reference(b))) {
1598 MERGE_WARNING(path, "commits not present");
1599 return 0;
1600 }
tag.c
+1 -1
@@ -146,7 +146,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
146 } else if (!strcmp(type, tree_type)) {
147 item->tagged = &lookup_tree(oid.hash)->object;
148 } else if (!strcmp(type, commit_type)) {
149 - item->tagged = &lookup_commit(oid.hash)->object;
149 + item->tagged = &lookup_commit(&oid)->object;
150 } else if (!strcmp(type, tag_type)) {
151 item->tagged = &lookup_tag(oid.hash)->object;
152 } else {
tree.c
+1 -1
@@ -91,7 +91,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base,
91 else if (S_ISGITLINK(entry.mode)) {
92 struct commit *commit;
93
94 - commit = lookup_commit(entry.oid->hash);
94 + commit = lookup_commit(entry.oid);
95 if (!commit)
96 die("Commit %s in submodule path %s%s not found",
97 oid_to_hex(entry.oid),
walker.c
+1 -1
@@ -206,7 +206,7 @@ static int interpret_target(struct walker *walker, char *target, unsigned char *
206 static int mark_complete(const char *path, const struct object_id *oid,
207 int flag, void *cb_data)
208 {
209 - struct commit *commit = lookup_commit_reference_gently(oid->hash, 1);
209 + struct commit *commit = lookup_commit_reference_gently(oid, 1);
210
211 if (commit) {
212 commit->object.flags |= COMPLETE;
wt-status.c
+1 -1
@@ -1428,7 +1428,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)
1428 /* sha1 is a commit? match without further lookup */
1429 (!oidcmp(&cb.noid, &oid) ||
1430 /* perhaps sha1 is a tag, try to dereference to a commit */
1431 - ((commit = lookup_commit_reference_gently(oid.hash, 1)) != NULL &&
1431 + ((commit = lookup_commit_reference_gently(&oid, 1)) != NULL &&
1432 !oidcmp(&cb.noid, &commit->object.oid)))) {
1433 const char *from = ref;
1434 if (!skip_prefix(from, "refs/tags/", &from))