From e92b848cb6a77172d2fbd2bda39a32e371d40eea Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 6 May 2017 22:10:06 +0000 Subject: shallow: convert shallow registration functions to object_id Convert register_shallow and unregister_shallow to take struct object_id. register_shallow is a caller of lookup_commit, which we will convert later. It doesn't make sense for the registration and unregistration functions to have incompatible interfaces, so convert them both. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- commit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index 73c78c2b80..ec41ba5e09 100644 --- a/commit.c +++ b/commit.c @@ -216,9 +216,9 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data) return ret; } -int unregister_shallow(const unsigned char *sha1) +int unregister_shallow(const struct object_id *oid) { - int pos = commit_graft_pos(sha1); + int pos = commit_graft_pos(oid->hash); if (pos < 0) return -1; if (pos + 1 < commit_graft_nr) -- cgit v1.2.3 From bc83266abe36905cade4719cbaeb8a62d0a382da Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 6 May 2017 22:10:10 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- archive.c | 2 +- bisect.c | 2 +- branch.c | 2 +- builtin/am.c | 4 ++-- builtin/blame.c | 4 ++-- builtin/branch.c | 6 +++--- builtin/checkout.c | 6 +++--- builtin/clone.c | 2 +- builtin/commit-tree.c | 2 +- builtin/commit.c | 4 ++-- builtin/describe.c | 4 ++-- builtin/diff-tree.c | 4 ++-- builtin/fast-export.c | 2 +- builtin/fetch.c | 7 ++++--- builtin/fmt-merge-msg.c | 4 ++-- builtin/log.c | 8 ++++---- builtin/merge-base.c | 6 +++--- builtin/merge.c | 2 +- builtin/notes.c | 2 +- builtin/pull.c | 10 +++++----- builtin/reflog.c | 8 ++++---- builtin/replace.c | 4 ++-- builtin/reset.c | 4 ++-- builtin/rev-parse.c | 6 +++--- builtin/show-branch.c | 4 ++-- builtin/tag.c | 2 +- builtin/verify-commit.c | 2 +- bundle.c | 2 +- commit.c | 30 +++++++++++++++--------------- commit.h | 12 ++++++------ fast-import.c | 4 ++-- fetch-pack.c | 2 +- http-push.c | 5 +++-- log-tree.c | 2 +- notes-cache.c | 2 +- notes-merge.c | 4 ++-- notes-utils.c | 2 +- object.c | 5 ++++- parse-options-cb.c | 2 +- ref-filter.c | 4 ++-- remote.c | 13 +++++++------ revision.c | 8 ++++---- sequencer.c | 8 ++++---- sha1_name.c | 10 +++++----- shallow.c | 20 ++++++++++---------- submodule.c | 14 +++++++------- tag.c | 2 +- tree.c | 2 +- walker.c | 2 +- wt-status.c | 2 +- 50 files changed, 138 insertions(+), 132 deletions(-) (limited to 'commit.c') diff --git a/archive.c b/archive.c index 60b8891986..54701e8bb2 100644 --- 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; diff --git a/bisect.c b/bisect.c index 08c9fb7266..bb5af3ea3d 100644 --- 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; diff --git a/branch.c b/branch.c index 1758c97086..4899144f5d 100644 --- 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); diff --git a/builtin/am.c b/builtin/am.c index a95dd8b4e6..650269ac5e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -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")); diff --git a/builtin/blame.c b/builtin/blame.c index 7d644d0925..58bb274d02 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -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; diff --git a/builtin/branch.c b/builtin/branch.c index 48a513a84d..83fcda43dc 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -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")); } diff --git a/builtin/checkout.c b/builtin/checkout.c index bfa5419f33..afa99fb8a0 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -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); diff --git a/builtin/clone.c b/builtin/clone.c index de85b85254..646f287925 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -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); diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 605017261c..f39c2b2737 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -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; } diff --git a/builtin/commit.c b/builtin/commit.c index 8685c888f0..e69f466d5b 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -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")); } diff --git a/builtin/describe.c b/builtin/describe.c index a5cd8c513f..f6032f593c 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -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; } diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 326f88b657..e85a449df1 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -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); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index e0220630d0..b4521cb627 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -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)); diff --git a/builtin/fetch.c b/builtin/fetch.c index 5f2c2ab23e..d4d573b985 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -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; diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index 6faa3c0d24..91dd753dd9 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -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; diff --git a/builtin/log.c b/builtin/log.c index b3b10cc1ed..d8b56ea410 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -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); diff --git a/builtin/merge-base.c b/builtin/merge-base.c index cfe2a796f8..5c74ce249b 100644 --- a/builtin/merge-base.c +++ b/builtin/merge-base.c @@ -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); diff --git a/builtin/merge.c b/builtin/merge.c index 703827f006..f11b5f3de4 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -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); diff --git a/builtin/notes.c b/builtin/notes.c index 7b891471c4..f2847c41e0 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -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.")); diff --git a/builtin/pull.c b/builtin/pull.c index dd1a4a94e4..2ffb6569a9 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -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"; diff --git a/builtin/reflog.c b/builtin/reflog.c index d6718d326c..4831116ea3 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -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 diff --git a/builtin/replace.c b/builtin/replace.c index ab17668f43..3c44ef750e 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -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); diff --git a/builtin/reset.c b/builtin/reset.c index fc3b906c47..0be52fa36a 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -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(); diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 4af1222644..f650188ef3 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -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 = '^'; diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 19756595d5..71b6f3c179 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -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)); diff --git a/builtin/tag.c b/builtin/tag.c index 597c925e38..d0070b37c2 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -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: diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c index a5db1c427f..05b734e6d1 100644 --- a/builtin/verify-commit.c +++ b/builtin/verify-commit.c @@ -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); diff --git a/bundle.c b/bundle.c index 6e181bb3d8..3386dba3be 100644 --- 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)) { diff --git a/commit.c b/commit.c index ec41ba5e09..0f6c9b6bf3 100644 --- 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); } diff --git a/commit.h b/commit.h index 884177b8fa..3488a285b1 100644 --- 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); diff --git a/fast-import.c b/fast-import.c index ba886c9e7e..585d5d6e85 100644 --- a/fast-import.c +++ b/fast-import.c @@ -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); diff --git a/fetch-pack.c b/fetch-pack.c index d455ef97af..7ec75f2782 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -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 diff --git a/http-push.c b/http-push.c index f3dd0a5606..04568e4fbd 100644 --- a/http-push.c +++ b/http-push.c @@ -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); } diff --git a/log-tree.c b/log-tree.c index 4618dd04ca..7fb1a85d2d 100644 --- a/log-tree.c +++ b/log-tree.c @@ -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); diff --git a/notes-cache.c b/notes-cache.c index 1cdd4984a4..2843e98576 100644 --- a/notes-cache.c +++ b/notes-cache.c @@ -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; diff --git a/notes-merge.c b/notes-merge.c index 06d8be9cbf..6244f6af9c 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -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); } diff --git a/notes-utils.c b/notes-utils.c index 36c1490aa7..325ff3daa3 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -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); diff --git a/object.c b/object.c index e680d881a4..fe22223566 100644 --- 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; diff --git a/parse-options-cb.c b/parse-options-cb.c index 35a941fddc..8dd57cf6ea 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -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); diff --git a/ref-filter.c b/ref-filter.c index 47cce0a184..e1d18ac0d1 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -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); diff --git a/remote.c b/remote.c index 801137c72e..bf9a47d95b 100644 --- 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; diff --git a/revision.c b/revision.c index 9453670341..f8e0dee6d5 100644 --- a/revision.c +++ b/revision.c @@ -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); diff --git a/sequencer.c b/sequencer.c index e44c015b2c..0867633602 100644 --- a/sequencer.c +++ b/sequencer.c @@ -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)); diff --git a/sha1_name.c b/sha1_name.c index 8889190a90..390a09c41a 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -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); diff --git a/shallow.c b/shallow.c index 1327ee16fc..6950cc24f0 100644 --- 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; diff --git a/submodule.c b/submodule.c index d5c28b9f1b..ba5429be15 100644 --- a/submodule.c +++ b/submodule.c @@ -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 625f5cd71e..79b78d3583 100644 --- 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 ce345c5511..33fa7ee717 100644 --- 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), diff --git a/walker.c b/walker.c index 2c86e406f9..b499fcb729 100644 --- 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; diff --git a/wt-status.c b/wt-status.c index 0375484962..e5854ba6f8 100644 --- a/wt-status.c +++ b/wt-status.c @@ -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)) -- cgit v1.2.3 From 740ee055c6178fc2dd43c5ccfbd367c4c64d6e0d Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 6 May 2017 22:10:17 +0000 Subject: Convert lookup_tree to struct object_id Convert the lookup_tree function to take a pointer to struct object_id. The commit was created with manual changes to tree.c, tree.h, and object.c, plus the following semantic patch: @@ @@ - lookup_tree(EMPTY_TREE_SHA1_BIN) + lookup_tree(&empty_tree_oid) @@ expression E1; @@ - lookup_tree(E1.hash) + lookup_tree(&E1) @@ expression E1; @@ - lookup_tree(E1->hash) + lookup_tree(E1) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- builtin/am.c | 4 ++-- builtin/diff-tree.c | 2 +- builtin/diff.c | 2 +- builtin/reflog.c | 2 +- cache-tree.c | 2 +- commit.c | 2 +- fsck.c | 2 +- http-push.c | 2 +- list-objects.c | 2 +- merge-recursive.c | 6 +++--- object.c | 2 +- reachable.c | 2 +- revision.c | 4 ++-- sequencer.c | 2 +- tag.c | 2 +- tree.c | 8 ++++---- tree.h | 2 +- walker.c | 2 +- 18 files changed, 25 insertions(+), 25 deletions(-) (limited to 'commit.c') diff --git a/builtin/am.c b/builtin/am.c index 650269ac5e..7663f12e64 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1453,9 +1453,9 @@ static void write_index_patch(const struct am_state *state) FILE *fp; if (!get_sha1_tree("HEAD", head.hash)) - tree = lookup_tree(head.hash); + tree = lookup_tree(&head); else - tree = lookup_tree(EMPTY_TREE_SHA1_BIN); + tree = lookup_tree(&empty_tree_oid); fp = xfopen(am_path(state, "patch"), "w"); init_revisions(&rev_info, NULL); diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index e85a449df1..95b8d1ba7c 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -44,7 +44,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p) struct tree *tree2; if (!isspace(*p++) || parse_oid_hex(p, &oid, &p) || *p) return error("Need exactly two trees, separated by a space"); - tree2 = lookup_tree(oid.hash); + tree2 = lookup_tree(&oid); if (!tree2 || parse_tree(tree2)) return -1; printf("%s %s\n", oid_to_hex(&tree1->object.oid), diff --git a/builtin/diff.c b/builtin/diff.c index a25b4e4ae6..895f928978 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -381,7 +381,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) add_head_to_pending(&rev); if (!rev.pending.nr) { struct tree *tree; - tree = lookup_tree(EMPTY_TREE_SHA1_BIN); + tree = lookup_tree(&empty_tree_oid); add_pending_object(&rev, &tree->object, "HEAD"); } break; diff --git a/builtin/reflog.c b/builtin/reflog.c index 7866a03412..7e89e84dce 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -62,7 +62,7 @@ static int tree_is_complete(const struct object_id *oid) int complete; struct tree *tree; - tree = lookup_tree(oid->hash); + tree = lookup_tree(oid); if (!tree) return 0; if (tree->object.flags & SEEN) diff --git a/cache-tree.c b/cache-tree.c index 35d507ed79..4892410212 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -672,7 +672,7 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree) cnt++; else { struct cache_tree_sub *sub; - struct tree *subtree = lookup_tree(entry.oid->hash); + struct tree *subtree = lookup_tree(entry.oid); if (!subtree->object.parsed) parse_tree(subtree); sub = cache_tree_sub(it, entry.path); diff --git a/commit.c b/commit.c index 0f6c9b6bf3..8004008bc3 100644 --- a/commit.c +++ b/commit.c @@ -331,7 +331,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s if (get_sha1_hex(bufptr + 5, parent.hash) < 0) return error("bad tree pointer in commit %s", oid_to_hex(&item->object.oid)); - item->tree = lookup_tree(parent.hash); + item->tree = lookup_tree(&parent); bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */ pptr = &item->parents; diff --git a/fsck.c b/fsck.c index ab3016c0e1..ee5224aea9 100644 --- a/fsck.c +++ b/fsck.c @@ -358,7 +358,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op continue; if (S_ISDIR(entry.mode)) { - obj = &lookup_tree(entry.oid->hash)->object; + obj = &lookup_tree(entry.oid)->object; if (name) put_object_name(options, obj, "%s%s/", name, entry.path); diff --git a/http-push.c b/http-push.c index 9bb5e06482..7781f40788 100644 --- a/http-push.c +++ b/http-push.c @@ -1312,7 +1312,7 @@ static struct object_list **process_tree(struct tree *tree, while (tree_entry(&desc, &entry)) switch (object_type(entry.mode)) { case OBJ_TREE: - p = process_tree(lookup_tree(entry.oid->hash), p); + p = process_tree(lookup_tree(entry.oid), p); break; case OBJ_BLOB: p = process_blob(lookup_blob(entry.oid), p); diff --git a/list-objects.c b/list-objects.c index 721e5fb08b..b3931fa434 100644 --- a/list-objects.c +++ b/list-objects.c @@ -110,7 +110,7 @@ static void process_tree(struct rev_info *revs, if (S_ISDIR(entry.mode)) process_tree(revs, - lookup_tree(entry.oid->hash), + lookup_tree(entry.oid), show, base, entry.path, cb_data); else if (S_ISGITLINK(entry.mode)) diff --git a/merge-recursive.c b/merge-recursive.c index 1315a45b93..92e0a63dcc 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -67,7 +67,7 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two, } if (!oidcmp(&two->object.oid, &shifted)) return two; - return lookup_tree(shifted.hash); + return lookup_tree(&shifted); } static struct commit *make_virtual_commit(struct tree *tree, const char *comment) @@ -304,7 +304,7 @@ struct tree *write_tree_from_memory(struct merge_options *o) return NULL; } - result = lookup_tree(active_cache_tree->oid.hash); + result = lookup_tree(&active_cache_tree->oid); return result; } @@ -2042,7 +2042,7 @@ int merge_recursive(struct merge_options *o, /* if there is no common ancestor, use an empty tree */ struct tree *tree; - tree = lookup_tree(EMPTY_TREE_SHA1_BIN); + tree = lookup_tree(&empty_tree_oid); merged_common_ancestors = make_virtual_commit(tree, "ancestor"); } diff --git a/object.c b/object.c index 2c8d1e5d31..d23c5fad38 100644 --- a/object.c +++ b/object.c @@ -197,7 +197,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t obj = &blob->object; } } else if (type == OBJ_TREE) { - struct tree *tree = lookup_tree(sha1); + struct tree *tree = lookup_tree(&oid); if (tree) { obj = &tree->object; if (!tree->buffer) diff --git a/reachable.c b/reachable.c index 8ea0bdd7c0..3bbc84417f 100644 --- a/reachable.c +++ b/reachable.c @@ -85,7 +85,7 @@ static void add_recent_object(const struct object_id *oid, obj = parse_object_or_die(oid->hash, NULL); break; case OBJ_TREE: - obj = (struct object *)lookup_tree(oid->hash); + obj = (struct object *)lookup_tree(oid); break; case OBJ_BLOB: obj = (struct object *)lookup_blob(oid); diff --git a/revision.c b/revision.c index db2de7a7a8..c2091b6de7 100644 --- a/revision.c +++ b/revision.c @@ -59,7 +59,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree) while (tree_entry(&desc, &entry)) { switch (object_type(entry.mode)) { case OBJ_TREE: - mark_tree_uninteresting(lookup_tree(entry.oid->hash)); + mark_tree_uninteresting(lookup_tree(entry.oid)); break; case OBJ_BLOB: mark_blob_uninteresting(lookup_blob(entry.oid)); @@ -1249,7 +1249,7 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs, int i; if (it->entry_count >= 0) { - struct tree *tree = lookup_tree(it->oid.hash); + struct tree *tree = lookup_tree(&it->oid); add_pending_object_with_path(revs, &tree->object, "", 040000, path->buf); } diff --git a/sequencer.c b/sequencer.c index 0867633602..218895fde1 100644 --- a/sequencer.c +++ b/sequencer.c @@ -344,7 +344,7 @@ static int read_oneliner(struct strbuf *buf, static struct tree *empty_tree(void) { - return lookup_tree(EMPTY_TREE_SHA1_BIN); + return lookup_tree(&empty_tree_oid); } static int error_dirty_index(struct replay_opts *opts) diff --git a/tag.c b/tag.c index dff251673e..062516b405 100644 --- a/tag.c +++ b/tag.c @@ -144,7 +144,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size) if (!strcmp(type, blob_type)) { item->tagged = &lookup_blob(&oid)->object; } else if (!strcmp(type, tree_type)) { - item->tagged = &lookup_tree(oid.hash)->object; + item->tagged = &lookup_tree(&oid)->object; } else if (!strcmp(type, commit_type)) { item->tagged = &lookup_commit(&oid)->object; } else if (!strcmp(type, tag_type)) { diff --git a/tree.c b/tree.c index 21fd80b801..28ce930b95 100644 --- a/tree.c +++ b/tree.c @@ -110,7 +110,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, len = tree_entry_len(&entry); strbuf_add(base, entry.path, len); strbuf_addch(base, '/'); - retval = read_tree_1(lookup_tree(oid.hash), + retval = read_tree_1(lookup_tree(&oid), base, stage, pathspec, fn, context); strbuf_setlen(base, oldlen); @@ -184,11 +184,11 @@ int read_tree(struct tree *tree, int stage, struct pathspec *match) return 0; } -struct tree *lookup_tree(const unsigned char *sha1) +struct tree *lookup_tree(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_tree_node()); + return create_object(oid->hash, alloc_tree_node()); return object_as_type(obj, OBJ_TREE, 0); } diff --git a/tree.h b/tree.h index d24786cba2..2b2c8dbbe9 100644 --- a/tree.h +++ b/tree.h @@ -12,7 +12,7 @@ struct tree { unsigned long size; }; -struct tree *lookup_tree(const unsigned char *sha1); +struct tree *lookup_tree(const struct object_id *oid); int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); diff --git a/walker.c b/walker.c index 3d6029c8e2..eae9fb974f 100644 --- a/walker.c +++ b/walker.c @@ -47,7 +47,7 @@ static int process_tree(struct walker *walker, struct tree *tree) if (S_ISGITLINK(entry.mode)) continue; if (S_ISDIR(entry.mode)) { - struct tree *tree = lookup_tree(entry.oid->hash); + struct tree *tree = lookup_tree(entry.oid); if (tree) obj = &tree->object; } -- cgit v1.2.3 From c251c83df276dc0bff4d008433268ad59b7a8df2 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 6 May 2017 22:10:38 +0000 Subject: object: convert parse_object* to take struct object_id Make parse_object, parse_object_or_die, and parse_object_buffer take a pointer to struct object_id. Remove the temporary variables inserted earlier, since they are no longer necessary. Transform all of the callers using the following semantic patch: @@ expression E1; @@ - parse_object(E1.hash) + parse_object(&E1) @@ expression E1; @@ - parse_object(E1->hash) + parse_object(E1) @@ expression E1, E2; @@ - parse_object_or_die(E1.hash, E2) + parse_object_or_die(&E1, E2) @@ expression E1, E2; @@ - parse_object_or_die(E1->hash, E2) + parse_object_or_die(E1, E2) @@ expression E1, E2, E3, E4, E5; @@ - parse_object_buffer(E1.hash, E2, E3, E4, E5) + parse_object_buffer(&E1, E2, E3, E4, E5) @@ expression E1, E2, E3, E4, E5; @@ - parse_object_buffer(E1->hash, E2, E3, E4, E5) + parse_object_buffer(E1, E2, E3, E4, E5) Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- builtin/diff-tree.c | 2 +- builtin/diff.c | 2 +- builtin/fast-export.c | 4 ++-- builtin/fmt-merge-msg.c | 4 ++-- builtin/fsck.c | 8 ++++---- builtin/grep.c | 2 +- builtin/index-pack.c | 3 ++- builtin/log.c | 2 +- builtin/name-rev.c | 6 +++--- builtin/prune.c | 3 ++- builtin/receive-pack.c | 6 +++--- builtin/reflog.c | 2 +- builtin/rev-list.c | 2 +- builtin/unpack-objects.c | 3 ++- bundle.c | 10 ++++++---- commit.c | 4 ++-- fetch-pack.c | 14 +++++++------- fsck.c | 2 +- http-backend.c | 2 +- http-push.c | 4 ++-- log-tree.c | 6 +++--- merge-recursive.c | 2 +- object.c | 44 +++++++++++++++++++------------------------- object.h | 8 ++++---- pack-bitmap.c | 4 ++-- pretty.c | 2 +- reachable.c | 4 ++-- ref-filter.c | 4 ++-- reflog-walk.c | 4 ++-- refs/files-backend.c | 2 +- remote.c | 4 ++-- revision.c | 12 ++++++------ server-info.c | 2 +- sha1_name.c | 14 +++++++------- tag.c | 4 ++-- tree.c | 4 ++-- upload-pack.c | 8 ++++---- walker.c | 2 +- 38 files changed, 107 insertions(+), 108 deletions(-) (limited to 'commit.c') diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 95b8d1ba7c..5ea1c14317 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -67,7 +67,7 @@ static int diff_tree_stdin(char *line) line[len-1] = 0; if (parse_oid_hex(line, &oid, &p)) return -1; - obj = parse_object(oid.hash); + obj = parse_object(&oid); if (!obj) return -1; if (obj->type == OBJ_COMMIT) diff --git a/builtin/diff.c b/builtin/diff.c index 895f928978..8c03ddaf58 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -395,7 +395,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) const char *name = entry->name; int flags = (obj->flags & UNINTERESTING); if (!obj->parsed) - obj = parse_object(obj->oid.hash); + obj = parse_object(&obj->oid); obj = deref_tag(obj, NULL, 0); if (!obj) die(_("invalid object '%s' given."), name); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index ae36b14db7..969550531b 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -240,7 +240,7 @@ static void export_blob(const struct object_id *oid) die ("Could not read blob %s", oid_to_hex(oid)); if (check_sha1_signature(oid->hash, buf, size, typename(type)) < 0) die("sha1 mismatch in blob %s", oid_to_hex(oid)); - object = parse_object_buffer(oid->hash, type, size, buf, &eaten); + object = parse_object_buffer(oid, type, size, buf, &eaten); } if (!object) @@ -777,7 +777,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name) /* handle nested tags */ while (tag && tag->object.type == OBJ_TAG) { - parse_object(tag->object.oid.hash); + parse_object(&tag->object.oid); string_list_append(&extra_refs, full_name)->util = tag; tag = (struct tag *)tag->tagged; } diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index 91dd753dd9..70137b0b7e 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -341,7 +341,7 @@ static void shortlog(const char *name, const struct object_id *oid = &origin_data->oid; int limit = opts->shortlog_len; - branch = deref_tag(parse_object(oid->hash), oid_to_hex(oid), GIT_SHA1_HEXSZ); + branch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ); if (!branch || branch->type != OBJ_COMMIT) return; @@ -559,7 +559,7 @@ static void find_merge_parents(struct merge_parents *result, * "name" here and we do not want to contaminate its * util field yet. */ - obj = parse_object(oid.hash); + obj = parse_object(&oid); parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT); if (!parent) continue; diff --git a/builtin/fsck.c b/builtin/fsck.c index a187054dac..8b8146174a 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -385,7 +385,7 @@ static int fsck_obj_buffer(const struct object_id *oid, enum object_type type, * verify_packfile(), data_valid variable for details. */ struct object *obj; - obj = parse_object_buffer(oid->hash, type, size, buffer, eaten); + obj = parse_object_buffer(oid, type, size, buffer, eaten); if (!obj) { errors_found |= ERROR_OBJECT; return error("%s: object corrupt or missing", oid_to_hex(oid)); @@ -444,7 +444,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid, { struct object *obj; - obj = parse_object(oid->hash); + obj = parse_object(oid); if (!obj) { error("%s: invalid sha1 pointer %s", refname, oid_to_hex(oid)); errors_found |= ERROR_REACHABLE; @@ -506,7 +506,7 @@ static struct object *parse_loose_object(const struct object_id *oid, if (!contents && type != OBJ_BLOB) die("BUG: read_loose_object streamed a non-blob"); - obj = parse_object_buffer(oid->hash, type, size, contents, &eaten); + obj = parse_object_buffer(oid, type, size, contents, &eaten); if (!eaten) free(contents); @@ -599,7 +599,7 @@ static int fsck_cache_tree(struct cache_tree *it) fprintf(stderr, "Checking cache tree\n"); if (0 <= it->entry_count) { - struct object *obj = parse_object(it->oid.hash); + struct object *obj = parse_object(&it->oid); if (!obj) { error("%s: invalid sha1 pointer in cache-tree", oid_to_hex(&it->oid)); diff --git a/builtin/grep.c b/builtin/grep.c index 3ffb5b4e81..e64e14e945 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -1196,7 +1196,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) break; } - object = parse_object_or_die(oid.hash, arg); + object = parse_object_or_die(&oid, arg); if (!seen_dashdash) verify_non_filename(prefix, arg); add_object_array_with_path(object, arg, &list, oc.mode, oc.path); diff --git a/builtin/index-pack.c b/builtin/index-pack.c index b75133f625..04b9dcaf0f 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -845,7 +845,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, * we do not need to free the memory here, as the * buf is deleted by the caller. */ - obj = parse_object_buffer(oid->hash, type, size, buf, &eaten); + obj = parse_object_buffer(oid, type, size, buf, + &eaten); if (!obj) die(_("invalid %s"), typename(type)); if (do_fsck_object && diff --git a/builtin/log.c b/builtin/log.c index d8b56ea410..8dd4e3daec 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -596,7 +596,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) rev.shown_one = 1; if (ret) break; - o = parse_object(t->tagged->oid.hash); + o = parse_object(&t->tagged->oid); if (!o) ret = error(_("Could not read object %s"), oid_to_hex(&t->tagged->oid)); diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 00760ecc65..f06261cada 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -142,7 +142,7 @@ static int tipcmp(const void *a_, const void *b_) static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data) { - struct object *o = parse_object(oid->hash); + struct object *o = parse_object(oid); struct name_ref_data *data = cb_data; int can_abbreviate_output = data->tags_only && data->name_only; int deref = 0; @@ -200,7 +200,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo struct tag *t = (struct tag *) o; if (!t->tagged) break; /* broken repository */ - o = parse_object(t->tagged->oid.hash); + o = parse_object(&t->tagged->oid); deref = 1; taggerdate = t->date; } @@ -385,7 +385,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) } commit = NULL; - object = parse_object(oid.hash); + object = parse_object(&oid); if (object) { struct object *peeled = deref_tag(object, *argv, 0); if (peeled && peeled->type == OBJ_COMMIT) diff --git a/builtin/prune.c b/builtin/prune.c index 96dca7d58a..536366056a 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -127,7 +127,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix) const char *name = *argv++; if (!get_oid(name, &oid)) { - struct object *object = parse_object_or_die(oid.hash, name); + struct object *object = parse_object_or_die(&oid, + name); add_pending_object(&revs, object, ""); } else diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 6f0f788b0c..36e0e29ea2 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1058,8 +1058,8 @@ static const char *update(struct command *cmd, struct shallow_info *si) struct object *old_object, *new_object; struct commit *old_commit, *new_commit; - old_object = parse_object(old_oid->hash); - new_object = parse_object(new_oid->hash); + old_object = parse_object(old_oid); + new_object = parse_object(new_oid); if (!old_object || !new_object || old_object->type != OBJ_COMMIT || @@ -1082,7 +1082,7 @@ static const char *update(struct command *cmd, struct shallow_info *si) if (is_null_oid(new_oid)) { struct strbuf err = STRBUF_INIT; - if (!parse_object(old_oid->hash)) { + if (!parse_object(old_oid)) { old_oid = NULL; if (ref_exists(name)) { rp_warning("Allowing deletion of corrupt ref."); diff --git a/builtin/reflog.c b/builtin/reflog.c index 7e89e84dce..8f3f1bd997 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -126,7 +126,7 @@ static int commit_is_complete(struct commit *commit) struct commit_list *parent; c = (struct commit *)study.objects[--study.nr].item; - if (!c->object.parsed && !parse_object(c->object.oid.hash)) + if (!c->object.parsed && !parse_object(&c->object.oid)) c->object.flags |= INCOMPLETE; if (c->object.flags & INCOMPLETE) { diff --git a/builtin/rev-list.c b/builtin/rev-list.c index bcf77f0b8a..1ddfca32be 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -181,7 +181,7 @@ static void finish_object(struct object *obj, const char *name, void *cb_data) if (obj->type == OBJ_BLOB && !has_object_file(&obj->oid)) die("missing blob object '%s'", oid_to_hex(&obj->oid)); if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT) - parse_object(obj->oid.hash); + parse_object(&obj->oid); } static void show_object(struct object *obj, const char *name, void *cb_data) diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 7d5efa2b3b..8bc9997767 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -260,7 +260,8 @@ static void write_object(unsigned nr, enum object_type type, int eaten; hash_sha1_file(buf, size, typename(type), obj_list[nr].oid.hash); added_object(nr, type, buf, size); - obj = parse_object_buffer(obj_list[nr].oid.hash, type, size, buf, &eaten); + obj = parse_object_buffer(&obj_list[nr].oid, type, size, buf, + &eaten); if (!obj) die("invalid %s", typename(type)); add_object_buffer(obj, buf, size); diff --git a/bundle.c b/bundle.c index 3386dba3be..f4abac4672 100644 --- a/bundle.c +++ b/bundle.c @@ -142,7 +142,7 @@ int verify_bundle(struct bundle_header *header, int verbose) init_revisions(&revs, NULL); for (i = 0; i < p->nr; i++) { struct ref_list_entry *e = p->list + i; - struct object *o = parse_object(e->oid.hash); + struct object *o = parse_object(&e->oid); if (o) { o->flags |= PREREQ_MARK; add_pending_object(&revs, o, e->name); @@ -290,12 +290,14 @@ static int compute_and_write_prerequisites(int bundle_fd, if (buf.len > 0 && buf.buf[0] == '-') { write_or_die(bundle_fd, buf.buf, buf.len); if (!get_oid_hex(buf.buf + 1, &oid)) { - struct object *object = parse_object_or_die(oid.hash, buf.buf); + struct object *object = parse_object_or_die(&oid, + buf.buf); object->flags |= UNINTERESTING; add_pending_object(revs, object, buf.buf); } } else if (!get_oid_hex(buf.buf, &oid)) { - struct object *object = parse_object_or_die(oid.hash, buf.buf); + struct object *object = parse_object_or_die(&oid, + buf.buf); object->flags |= SHOWN; } } @@ -379,7 +381,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs) * end up triggering "empty bundle" * error. */ - obj = parse_object_or_die(oid.hash, e->name); + obj = parse_object_or_die(&oid, e->name); obj->flags |= SHOWN; add_pending_object(revs, obj, e->name); } diff --git a/commit.c b/commit.c index 8004008bc3..424237a8e9 100644 --- a/commit.c +++ b/commit.c @@ -21,7 +21,7 @@ const char *commit_type = "commit"; struct commit *lookup_commit_reference_gently(const struct object_id *oid, int quiet) { - struct object *obj = deref_tag(parse_object(oid->hash), NULL, 0); + struct object *obj = deref_tag(parse_object(oid), NULL, 0); if (!obj) return NULL; @@ -1589,7 +1589,7 @@ struct commit *get_merge_parent(const char *name) struct object_id oid; if (get_sha1(name, oid.hash)) return NULL; - obj = parse_object(oid.hash); + obj = parse_object(&oid); commit = (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT); if (commit && !commit->util) set_merge_remote_desc(commit, name, obj); diff --git a/fetch-pack.c b/fetch-pack.c index 7ec75f2782..2880f5d6a6 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -78,7 +78,7 @@ static void cache_one_alternate(const char *refname, void *vcache) { struct alternate_object_cache *cache = vcache; - struct object *obj = parse_object(oid->hash); + struct object *obj = parse_object(oid); if (!obj || (obj->flags & ALTERNATE)) return; @@ -120,7 +120,7 @@ static void rev_list_push(struct commit *commit, int mark) static int rev_list_insert_ref(const char *refname, const struct object_id *oid) { - struct object *o = deref_tag(parse_object(oid->hash), refname, 0); + struct object *o = deref_tag(parse_object(oid), refname, 0); if (o && o->type == OBJ_COMMIT) rev_list_push((struct commit *)o, SEEN); @@ -137,7 +137,7 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id * static int clear_marks(const char *refname, const struct object_id *oid, int flag, void *cb_data) { - struct object *o = deref_tag(parse_object(oid->hash), refname, 0); + struct object *o = deref_tag(parse_object(oid), refname, 0); if (o && o->type == OBJ_COMMIT) clear_commit_marks((struct commit *)o, @@ -426,7 +426,7 @@ static int find_common(struct fetch_pack_args *args, if (!lookup_object(oid.hash)) die(_("object not found: %s"), line); /* make sure that it is parsed as shallow */ - if (!parse_object(oid.hash)) + if (!parse_object(&oid)) die(_("error in object: %s"), line); if (unregister_shallow(&oid)) die(_("no shallow found: %s"), line); @@ -557,14 +557,14 @@ static struct commit_list *complete; static int mark_complete(const struct object_id *oid) { - struct object *o = parse_object(oid->hash); + struct object *o = parse_object(oid); while (o && o->type == OBJ_TAG) { struct tag *t = (struct tag *) o; if (!t->tagged) break; /* broken repository */ o->flags |= COMPLETE; - o = parse_object(t->tagged->oid.hash); + o = parse_object(&t->tagged->oid); } if (o && o->type == OBJ_COMMIT) { struct commit *commit = (struct commit *)o; @@ -681,7 +681,7 @@ static int everything_local(struct fetch_pack_args *args, if (!has_object_file(&ref->old_oid)) continue; - o = parse_object(ref->old_oid.hash); + o = parse_object(&ref->old_oid); if (!o) continue; diff --git a/fsck.c b/fsck.c index ee5224aea9..90857e122d 100644 --- a/fsck.c +++ b/fsck.c @@ -461,7 +461,7 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options) return -1; if (obj->type == OBJ_NONE) - parse_object(obj->oid.hash); + parse_object(&obj->oid); switch (obj->type) { case OBJ_BLOB: diff --git a/http-backend.c b/http-backend.c index eef0a361f4..7663813323 100644 --- a/http-backend.c +++ b/http-backend.c @@ -431,7 +431,7 @@ static int show_text_ref(const char *name, const struct object_id *oid, { const char *name_nons = strip_namespace(name); struct strbuf *buf = cb_data; - struct object *o = parse_object(oid->hash); + struct object *o = parse_object(oid); if (!o) return 0; diff --git a/http-push.c b/http-push.c index 4e7bd9e42b..67c4d4b472 100644 --- a/http-push.c +++ b/http-push.c @@ -724,7 +724,7 @@ static void one_remote_object(const struct object_id *oid) obj = lookup_object(oid->hash); if (!obj) - obj = parse_object(oid->hash); + obj = parse_object(oid); /* Ignore remote objects that don't exist locally */ if (!obj) @@ -1462,7 +1462,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls) return; } - o = parse_object(ref->old_oid.hash); + o = parse_object(&ref->old_oid); if (!o) { fprintf(stderr, "Unable to parse object %s for remote ref %s\n", diff --git a/log-tree.c b/log-tree.c index 6532c892c2..a4ec11c2bf 100644 --- a/log-tree.c +++ b/log-tree.c @@ -105,13 +105,13 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid, warning("invalid replace ref %s", refname); return 0; } - obj = parse_object(original_oid.hash); + obj = parse_object(&original_oid); if (obj) add_name_decoration(DECORATION_GRAFTED, "replaced", obj); return 0; } - obj = parse_object(oid->hash); + obj = parse_object(oid); if (!obj) return 0; @@ -132,7 +132,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid, if (!obj) break; if (!obj->parsed) - parse_object(obj->oid.hash); + parse_object(&obj->oid); add_name_decoration(DECORATION_REF_TAG, refname, obj); } return 0; diff --git a/merge-recursive.c b/merge-recursive.c index 92e0a63dcc..ae5238d82c 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -2103,7 +2103,7 @@ static struct commit *get_ref(const struct object_id *oid, const char *name) { struct object *object; - object = deref_tag(parse_object(oid->hash), name, strlen(name)); + object = deref_tag(parse_object(oid), name, strlen(name)); if (!object) return NULL; if (object->type == OBJ_TREE) diff --git a/object.c b/object.c index dd4d3a1ea7..06ba3a11d8 100644 --- a/object.c +++ b/object.c @@ -180,24 +180,21 @@ struct object *lookup_unknown_object(const unsigned char *sha1) return obj; } -struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p) +struct object *parse_object_buffer(const struct object_id *oid, 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(&oid); + struct blob *blob = lookup_blob(oid); if (blob) { if (parse_blob_buffer(blob, buffer, size)) return NULL; obj = &blob->object; } } else if (type == OBJ_TREE) { - struct tree *tree = lookup_tree(&oid); + struct tree *tree = lookup_tree(oid); if (tree) { obj = &tree->object; if (!tree->buffer) @@ -209,7 +206,7 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t } } } else if (type == OBJ_COMMIT) { - struct commit *commit = lookup_commit(&oid); + struct commit *commit = lookup_commit(oid); if (commit) { if (parse_commit_buffer(commit, buffer, size)) return NULL; @@ -220,57 +217,54 @@ struct object *parse_object_buffer(const unsigned char *sha1, enum object_type t obj = &commit->object; } } else if (type == OBJ_TAG) { - struct tag *tag = lookup_tag(&oid); + struct tag *tag = lookup_tag(oid); if (tag) { if (parse_tag_buffer(tag, buffer, size)) return NULL; obj = &tag->object; } } else { - warning("object %s has unknown type id %d", sha1_to_hex(sha1), type); + warning("object %s has unknown type id %d", oid_to_hex(oid), type); obj = NULL; } return obj; } -struct object *parse_object_or_die(const unsigned char *sha1, +struct object *parse_object_or_die(const struct object_id *oid, const char *name) { - struct object *o = parse_object(sha1); + struct object *o = parse_object(oid); if (o) return o; - die(_("unable to parse object: %s"), name ? name : sha1_to_hex(sha1)); + die(_("unable to parse object: %s"), name ? name : oid_to_hex(oid)); } -struct object *parse_object(const unsigned char *sha1) +struct object *parse_object(const struct object_id *oid) { unsigned long size; enum object_type type; int eaten; - const unsigned char *repl = lookup_replace_object(sha1); + const unsigned char *repl = lookup_replace_object(oid->hash); void *buffer; struct object *obj; - struct object_id oid; - - hashcpy(oid.hash, sha1); - obj = lookup_object(oid.hash); + obj = lookup_object(oid->hash); if (obj && obj->parsed) return obj; if ((obj && obj->type == OBJ_BLOB) || - (!obj && has_sha1_file(sha1) && - sha1_object_info(sha1, NULL) == OBJ_BLOB)) { + (!obj && has_object_file(oid) && + sha1_object_info(oid->hash, NULL) == OBJ_BLOB)) { if (check_sha1_signature(repl, NULL, 0, NULL) < 0) { - error("sha1 mismatch %s", sha1_to_hex(repl)); + error("sha1 mismatch %s", oid_to_hex(oid)); return NULL; } - parse_blob_buffer(lookup_blob(&oid), NULL, 0); - return lookup_object(sha1); + parse_blob_buffer(lookup_blob(oid), NULL, 0); + return lookup_object(oid->hash); } - buffer = read_sha1_file(sha1, &type, &size); + buffer = read_sha1_file(oid->hash, &type, &size); if (buffer) { if (check_sha1_signature(repl, buffer, size, typename(type)) < 0) { free(buffer); @@ -278,7 +272,7 @@ struct object *parse_object(const unsigned char *sha1) return NULL; } - obj = parse_object_buffer(sha1, type, size, buffer, &eaten); + obj = parse_object_buffer(oid, type, size, buffer, &eaten); if (!eaten) free(buffer); return obj; diff --git a/object.h b/object.h index f52957dcb3..33e5cc9943 100644 --- a/object.h +++ b/object.h @@ -89,20 +89,20 @@ void *object_as_type(struct object *obj, enum object_type type, int quiet); * * Returns NULL if the object is missing or corrupt. */ -struct object *parse_object(const unsigned char *sha1); +struct object *parse_object(const struct object_id *oid); /* * Like parse_object, but will die() instead of returning NULL. If the * "name" parameter is not NULL, it is included in the error message - * (otherwise, the sha1 hex is given). + * (otherwise, the hex object ID is given). */ -struct object *parse_object_or_die(const unsigned char *sha1, const char *name); +struct object *parse_object_or_die(const struct object_id *oid, const char *name); /* Given the result of read_sha1_file(), returns the object after * parsing it. eaten_p indicates if the object has a borrowed copy * of buffer and the caller should not free() it. */ -struct object *parse_object_buffer(const unsigned char *sha1, enum object_type type, unsigned long size, void *buffer, int *eaten_p); +struct object *parse_object_buffer(const struct object_id *oid, enum object_type type, unsigned long size, void *buffer, int *eaten_p); /** Returns the object, with potentially excess memory allocated. **/ struct object *lookup_unknown_object(const unsigned char *sha1); diff --git a/pack-bitmap.c b/pack-bitmap.c index 39bcc16846..a3ac3dccd4 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -673,7 +673,7 @@ int prepare_bitmap_walk(struct rev_info *revs) struct object *object = pending_e[i].item; if (object->type == OBJ_NONE) - parse_object_or_die(object->oid.hash, NULL); + parse_object_or_die(&object->oid, NULL); while (object->type == OBJ_TAG) { struct tag *tag = (struct tag *) object; @@ -685,7 +685,7 @@ int prepare_bitmap_walk(struct rev_info *revs) if (!tag->tagged) die("bad tag"); - object = parse_object_or_die(tag->tagged->oid.hash, NULL); + object = parse_object_or_die(&tag->tagged->oid, NULL); } if (object->flags & UNINTERESTING) diff --git a/pretty.c b/pretty.c index d0f86f5d85..c4a0ace34c 100644 --- a/pretty.c +++ b/pretty.c @@ -1137,7 +1137,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ /* these depend on the commit */ if (!commit->object.parsed) - parse_object(commit->object.oid.hash); + parse_object(&commit->object.oid); switch (placeholder[0]) { case 'H': /* commit hash */ diff --git a/reachable.c b/reachable.c index 3bbc84417f..69ca176f6c 100644 --- a/reachable.c +++ b/reachable.c @@ -33,7 +33,7 @@ static int add_one_ref(const char *path, const struct object_id *oid, return 0; } - object = parse_object_or_die(oid->hash, path); + object = parse_object_or_die(oid, path); add_pending_object(revs, object, ""); return 0; @@ -82,7 +82,7 @@ static void add_recent_object(const struct object_id *oid, switch (type) { case OBJ_TAG: case OBJ_COMMIT: - obj = parse_object_or_die(oid->hash, NULL); + obj = parse_object_or_die(oid, NULL); break; case OBJ_TREE: obj = (struct object *)lookup_tree(oid); diff --git a/ref-filter.c b/ref-filter.c index 56fc990a52..3f7cf71b5f 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -683,7 +683,7 @@ static void *get_obj(const struct object_id *oid, struct object **obj, unsigned void *buf = read_sha1_file(oid->hash, &type, sz); if (buf) - *obj = parse_object_buffer(oid->hash, type, *sz, buf, eaten); + *obj = parse_object_buffer(oid, type, *sz, buf, eaten); else *obj = NULL; return buf; @@ -1687,7 +1687,7 @@ static const struct object_id *match_points_at(struct oid_array *points_at, if (oid_array_lookup(points_at, oid) >= 0) return oid; - obj = parse_object(oid->hash); + obj = parse_object(oid); if (!obj) die(_("malformed object at '%s'"), refname); if (obj->type == OBJ_TAG) diff --git a/reflog-walk.c b/reflog-walk.c index c8fdf051d2..110e18f1f3 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -238,13 +238,13 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit) do { reflog = &commit_reflog->reflogs->items[commit_reflog->recno]; commit_reflog->recno--; - logobj = parse_object(reflog->ooid.hash); + logobj = parse_object(&reflog->ooid); } while (commit_reflog->recno && (logobj && logobj->type != OBJ_COMMIT)); if (!logobj && commit_reflog->recno >= 0 && is_null_oid(&reflog->ooid)) { /* a root commit, but there are still more entries to show */ reflog = &commit_reflog->reflogs->items[commit_reflog->recno]; - logobj = parse_object(reflog->noid.hash); + logobj = parse_object(&reflog->noid); } if (!logobj || logobj->type != OBJ_COMMIT) { diff --git a/refs/files-backend.c b/refs/files-backend.c index 2c360a4107..2cccdf71ae 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -2057,7 +2057,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock, struct object *o; int fd; - o = parse_object(oid->hash); + o = parse_object(oid); if (!o) { strbuf_addf(err, "trying to write ref '%s' with nonexistent object %s", diff --git a/remote.c b/remote.c index bf9a47d95b..38ca1353b9 100644 --- a/remote.c +++ b/remote.c @@ -1954,12 +1954,12 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid) * Both new and old must be commit-ish and new is descendant of * old. Otherwise we require --force. */ - o = deref_tag(parse_object(old_oid->hash), NULL, 0); + o = deref_tag(parse_object(old_oid), NULL, 0); if (!o || o->type != OBJ_COMMIT) return 0; old = (struct commit *) o; - o = deref_tag(parse_object(new_oid->hash), NULL, 0); + o = deref_tag(parse_object(new_oid), NULL, 0); if (!o || o->type != OBJ_COMMIT) return 0; new = (struct commit *) o; diff --git a/revision.c b/revision.c index 80f74bb7b4..64e67e017f 100644 --- a/revision.c +++ b/revision.c @@ -181,7 +181,7 @@ void add_head_to_pending(struct rev_info *revs) struct object *obj; if (get_oid("HEAD", &oid)) return; - obj = parse_object(oid.hash); + obj = parse_object(&oid); if (!obj) return; add_pending_object(revs, obj, "HEAD"); @@ -193,7 +193,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name, { struct object *object; - object = parse_object(oid->hash); + object = parse_object(oid); if (!object) { if (revs->ignore_missing) return object; @@ -228,7 +228,7 @@ static struct commit *handle_commit(struct rev_info *revs, add_pending_object(revs, object, tag->tag); if (!tag->tagged) die("bad tag"); - object = parse_object(tag->tagged->oid.hash); + object = parse_object(&tag->tagged->oid); if (!object) { if (flags & UNINTERESTING) return NULL; @@ -1200,7 +1200,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data) { struct all_refs_cb *cb = cb_data; if (!is_null_oid(oid)) { - struct object *o = parse_object(oid->hash); + struct object *o = parse_object(oid); if (o) { o->flags |= cb->all_flags; /* ??? CMDLINEFLAGS ??? */ @@ -1479,8 +1479,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi verify_non_filename(revs->prefix, arg); } - a_obj = parse_object(from_oid.hash); - b_obj = parse_object(oid.hash); + a_obj = parse_object(&from_oid); + b_obj = parse_object(&oid); if (!a_obj || !b_obj) { missing: if (revs->ignore_missing) diff --git a/server-info.c b/server-info.c index f6c1a3dfb0..6f865b73a3 100644 --- a/server-info.c +++ b/server-info.c @@ -53,7 +53,7 @@ static int add_info_ref(const char *path, const struct object_id *oid, int flag, void *cb_data) { FILE *fp = cb_data; - struct object *o = parse_object(oid->hash); + struct object *o = parse_object(oid); if (!o) return -1; diff --git a/sha1_name.c b/sha1_name.c index 72e72ab9ae..de8278530a 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -241,7 +241,7 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da return 0; /* We need to do this the hard way... */ - obj = deref_tag(parse_object(oid->hash), NULL, 0); + obj = deref_tag(parse_object(oid), NULL, 0); if (obj && obj->type == OBJ_COMMIT) return 1; return 0; @@ -265,7 +265,7 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_ return 0; /* We need to do this the hard way... */ - obj = deref_tag(parse_object(oid->hash), NULL, 0); + obj = deref_tag(parse_object(oid), NULL, 0); if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT)) return 1; return 0; @@ -776,7 +776,7 @@ struct object *peel_to_type(const char *name, int namelen, if (name && !namelen) namelen = strlen(name); while (1) { - if (!o || (!o->parsed && !parse_object(o->oid.hash))) + if (!o || (!o->parsed && !parse_object(&o->oid))) return NULL; if (expected_type == OBJ_ANY || o->type == expected_type) return o; @@ -849,12 +849,12 @@ static int peel_onion(const char *name, int len, unsigned char *sha1, if (get_sha1_1(name, sp - name - 2, outer.hash, lookup_flags)) return -1; - o = parse_object(outer.hash); + o = parse_object(&outer); if (!o) return -1; if (!expected_type) { o = deref_tag(o, name, sp - name - 2); - if (!o || (!o->parsed && !parse_object(o->oid.hash))) + if (!o || (!o->parsed && !parse_object(&o->oid))) return -1; hashcpy(sha1, o->oid.hash); return 0; @@ -981,7 +981,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid, int flag, void *cb_data) { struct commit_list **list = cb_data; - struct object *object = parse_object(oid->hash); + struct object *object = parse_object(oid); if (!object) return 0; if (object->type == OBJ_TAG) { @@ -1027,7 +1027,7 @@ static int get_sha1_oneline(const char *prefix, unsigned char *sha1, int matches; commit = pop_most_recent_commit(&list, ONELINE_SEEN); - if (!parse_object(commit->object.oid.hash)) + if (!parse_object(&commit->object.oid)) continue; buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); diff --git a/tag.c b/tag.c index 571798519f..eb7b146f4a 100644 --- a/tag.c +++ b/tag.c @@ -66,7 +66,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen) { while (o && o->type == OBJ_TAG) if (((struct tag *)o)->tagged) - o = parse_object(((struct tag *)o)->tagged->oid.hash); + o = parse_object(&((struct tag *)o)->tagged->oid); else o = NULL; if (!o && warn) { @@ -80,7 +80,7 @@ struct object *deref_tag(struct object *o, const char *warn, int warnlen) struct object *deref_tag_noverify(struct object *o) { while (o && o->type == OBJ_TAG) { - o = parse_object(o->oid.hash); + o = parse_object(&o->oid); if (o && o->type == OBJ_TAG && ((struct tag *)o)->tagged) o = ((struct tag *)o)->tagged; else diff --git a/tree.c b/tree.c index 9adcd8bd42..603b29ee80 100644 --- a/tree.c +++ b/tree.c @@ -234,7 +234,7 @@ void free_tree_buffer(struct tree *tree) struct tree *parse_tree_indirect(const struct object_id *oid) { - struct object *obj = parse_object(oid->hash); + struct object *obj = parse_object(oid); do { if (!obj) return NULL; @@ -247,6 +247,6 @@ struct tree *parse_tree_indirect(const struct object_id *oid) else return NULL; if (!obj->parsed) - parse_object(obj->oid.hash); + parse_object(&obj->oid); } while (1); } diff --git a/upload-pack.c b/upload-pack.c index 5b9d21089a..8619ec4354 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -296,7 +296,7 @@ static int got_oid(const char *hex, struct object_id *oid) if (!has_object_file(oid)) return -1; - o = parse_object(oid->hash); + o = parse_object(oid); if (!o) die("oops (%s)", oid_to_hex(oid)); if (o->type == OBJ_COMMIT) { @@ -334,7 +334,7 @@ static int reachable(struct commit *want) break; } if (!commit->object.parsed) - parse_object(commit->object.oid.hash); + parse_object(&commit->object.oid); if (commit->object.flags & REACHABLE) continue; commit->object.flags |= REACHABLE; @@ -755,7 +755,7 @@ static void receive_needs(void) struct object *object; if (get_oid_hex(arg, &oid)) die("invalid shallow line: %s", line); - object = parse_object(oid.hash); + object = parse_object(&oid); if (!object) continue; if (object->type != OBJ_COMMIT) @@ -821,7 +821,7 @@ static void receive_needs(void) if (parse_feature_request(features, "include-tag")) use_include_tag = 1; - o = parse_object(oid_buf.hash); + o = parse_object(&oid_buf); if (!o) { packet_write_fmt(1, "ERR upload-pack: not our ref %s", diff --git a/walker.c b/walker.c index eae9fb974f..274f1a4935 100644 --- a/walker.c +++ b/walker.c @@ -180,7 +180,7 @@ static int loop(struct walker *walker) } } if (!obj->type) - parse_object(obj->oid.hash); + parse_object(&obj->oid); if (process_object(walker, obj)) return -1; } -- cgit v1.2.3