diff options
106 files changed, 1173 insertions, 1134 deletions
@@ -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; @@ -369,7 +369,7 @@ static void parse_treeish_arg(const char **argv, archive_time = time(NULL); } - tree = parse_tree_indirect(oid.hash); + tree = parse_tree_indirect(&oid); if (tree == NULL) die("not a tree object"); @@ -383,7 +383,7 @@ static void parse_treeish_arg(const char **argv, if (err || !S_ISDIR(mode)) die("current working directory is untracked"); - tree = parse_tree_indirect(tree_oid.hash); + tree = parse_tree_indirect(&tree_oid); } ar_args->tree = tree; ar_args->commit_sha1 = commit_sha1; @@ -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; @@ -3,11 +3,11 @@ const char *blob_type = "blob"; -struct blob *lookup_blob(const unsigned char *sha1) +struct blob *lookup_blob(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_blob_node()); + return create_object(oid->hash, alloc_blob_node()); return object_as_type(obj, OBJ_BLOB, 0); } @@ -9,7 +9,7 @@ struct blob { struct object object; }; -struct blob *lookup_blob(const unsigned char *sha1); +struct blob *lookup_blob(const struct object_id *oid); int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size); @@ -191,9 +191,9 @@ int validate_new_branchname(const char *name, struct strbuf *ref, if (!attr_only) { const char *head; - unsigned char sha1[20]; + struct object_id oid; - head = resolve_ref_unsafe("HEAD", 0, sha1, NULL); + head = resolve_ref_unsafe("HEAD", 0, oid.hash, NULL); if (!is_bare_repository() && head && !strcmp(head, ref->buf)) die(_("Cannot force update the current branch.")); } @@ -233,7 +233,7 @@ void create_branch(const char *name, const char *start_name, int quiet, enum branch_track track) { struct commit *commit; - unsigned char sha1[20]; + struct object_id oid; char *real_ref; struct strbuf ref = STRBUF_INIT; int forcing = 0; @@ -253,7 +253,7 @@ void create_branch(const char *name, const char *start_name, } real_ref = NULL; - if (get_sha1(start_name, sha1)) { + if (get_oid(start_name, &oid)) { if (explicit_tracking) { if (advice_set_upstream_failure) { error(_(upstream_missing), start_name); @@ -265,7 +265,7 @@ void create_branch(const char *name, const char *start_name, die(_("Not a valid object name: '%s'."), start_name); } - switch (dwim_ref(start_name, strlen(start_name), sha1, &real_ref)) { + switch (dwim_ref(start_name, strlen(start_name), oid.hash, &real_ref)) { case 0: /* Not branching from any existing branch */ if (explicit_tracking) @@ -286,9 +286,9 @@ void create_branch(const char *name, const char *start_name, break; } - if ((commit = lookup_commit_reference(sha1)) == NULL) + if ((commit = lookup_commit_reference(&oid)) == NULL) die(_("Not a valid branch point: '%s'."), start_name); - hashcpy(sha1, commit->object.oid.hash); + oidcpy(&oid, &commit->object.oid); if (reflog) log_all_ref_updates = LOG_REFS_NORMAL; @@ -306,7 +306,7 @@ void create_branch(const char *name, const char *start_name, transaction = ref_transaction_begin(&err); if (!transaction || ref_transaction_update(transaction, ref.buf, - sha1, forcing ? NULL : null_sha1, + oid.hash, forcing ? NULL : null_sha1, 0, msg, &err) || ref_transaction_commit(transaction, &err)) die("%s", err.buf); diff --git a/builtin/am.c b/builtin/am.c index 8e9ac1144d..2ec1d7b71e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1145,7 +1145,7 @@ static int index_has_changes(struct strbuf *sb) DIFF_OPT_SET(&opt, EXIT_WITH_STATUS); if (!sb) DIFF_OPT_SET(&opt, QUICK); - do_diff_cache(head.hash, &opt); + do_diff_cache(&head, &opt); diffcore_std(&opt); for (i = 0; sb && i < diff_queued_diff.nr; i++) { if (i) @@ -1447,9 +1447,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); @@ -1482,7 +1482,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); @@ -1612,7 +1612,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa init_revisions(&rev_info, NULL); rev_info.diffopt.output_format = DIFF_FORMAT_NAME_STATUS; diff_opt_parse(&rev_info.diffopt, &diff_filter_str, 1, rev_info.prefix); - add_pending_sha1(&rev_info, "HEAD", our_tree.hash, 0); + add_pending_oid(&rev_info, "HEAD", &our_tree, 0); diff_setup_done(&rev_info.diffopt); run_diff_index(&rev_info, 1); } @@ -1677,7 +1677,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")); @@ -2039,11 +2039,11 @@ static int clean_index(const struct object_id *head, const struct object_id *rem struct tree *head_tree, *remote_tree, *index_tree; struct object_id index; - head_tree = parse_tree_indirect(head->hash); + head_tree = parse_tree_indirect(head); if (!head_tree) return error(_("Could not parse object '%s'."), oid_to_hex(head)); - remote_tree = parse_tree_indirect(remote->hash); + remote_tree = parse_tree_indirect(remote); if (!remote_tree) return error(_("Could not parse object '%s'."), oid_to_hex(remote)); @@ -2055,7 +2055,7 @@ static int clean_index(const struct object_id *head, const struct object_id *rem if (write_cache_as_tree(index.hash, 0, NULL)) return -1; - index_tree = parse_tree_indirect(index.hash); + index_tree = parse_tree_indirect(&index); if (!index_tree) return error(_("Could not parse object '%s'."), oid_to_hex(&index)); diff --git a/builtin/blame.c b/builtin/blame.c index f00eda1637..1043e5376f 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -563,7 +563,7 @@ static struct origin *find_origin(struct scoreboard *sb, diff_setup_done(&diff_opts); if (is_null_oid(&origin->commit->object.oid)) - do_diff_cache(parent->tree->object.oid.hash, &diff_opts); + do_diff_cache(&parent->tree->object.oid, &diff_opts); else diff_tree_sha1(parent->tree->object.oid.hash, origin->commit->tree->object.oid.hash, @@ -633,7 +633,7 @@ static struct origin *find_rename(struct scoreboard *sb, diff_setup_done(&diff_opts); if (is_null_oid(&origin->commit->object.oid)) - do_diff_cache(parent->tree->object.oid.hash, &diff_opts); + do_diff_cache(&parent->tree->object.oid, &diff_opts); else diff_tree_sha1(parent->tree->object.oid.hash, origin->commit->tree->object.oid.hash, @@ -1272,7 +1272,7 @@ static void find_copy_in_parent(struct scoreboard *sb, DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER); if (is_null_oid(&target->commit->object.oid)) - do_diff_cache(parent->tree->object.oid.hash, &diff_opts); + do_diff_cache(&parent->tree->object.oid, &diff_opts); else diff_tree_sha1(parent->tree->object.oid.hash, target->commit->tree->object.oid.hash, @@ -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; @@ -2461,7 +2461,7 @@ static const char *dwim_reverse_initial(struct scoreboard *sb) */ struct object *obj; struct commit *head_commit; - unsigned char head_sha1[20]; + struct object_id head_oid; if (sb->revs->pending.nr != 1) return NULL; @@ -2473,9 +2473,9 @@ static const char *dwim_reverse_initial(struct scoreboard *sb) return NULL; /* Do we have HEAD? */ - if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_sha1, NULL)) + if (!resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, head_oid.hash, NULL)) return NULL; - head_commit = lookup_commit_reference_gently(head_sha1, 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_commi |