Commit 7999b2cf authored by brian m. carlson's avatar brian m. carlson Committed by Jeff King

Add several uses of get_object_hash.

Convert most instances where the sha1 member of struct object is
dereferenced to use get_object_hash.  Most instances that are passed to
functions that have versions taking struct object_id, such as
get_sha1_hex/get_oid_hex, or instances that can be trivially converted
to use struct object_id instead, are not converted.
Signed-off-by: brian m. carlson's avatarbrian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: default avatarJeff King <peff@peff.net>
parent 3c427010
......@@ -241,7 +241,7 @@ int write_archive_entries(struct archiver_args *args,
len--;
if (args->verbose)
fprintf(stderr, "%.*s\n", (int)len, args->base);
err = write_entry(args, args->tree->object.sha1, args->base,
err = write_entry(args, get_object_hash(args->tree->object), args->base,
len, 040777);
if (err)
return err;
......@@ -374,7 +374,7 @@ static void parse_treeish_arg(const char **argv,
commit = lookup_commit_reference_gently(oid.hash, 1);
if (commit) {
commit_sha1 = commit->object.sha1;
commit_sha1 = get_object_hash(commit->object);
archive_time = commit->date;
} else {
commit_sha1 = NULL;
......@@ -390,7 +390,7 @@ static void parse_treeish_arg(const char **argv,
unsigned int mode;
int err;
err = get_tree_entry(tree->object.sha1, prefix,
err = get_tree_entry(get_object_hash(tree->object), prefix,
tree_oid.hash, &mode);
if (err || !S_ISDIR(mode))
die("current working directory is untracked");
......
......@@ -500,7 +500,7 @@ struct commit_list *filter_skipped(struct commit_list *list,
struct commit_list *next = list->next;
list->next = NULL;
if (0 <= sha1_array_lookup(&skipped_revs,
list->item->object.sha1)) {
get_object_hash(list->item->object))) {
if (skipped_first && !*skipped_first)
*skipped_first = 1;
/* Move current to tried list */
......@@ -784,7 +784,7 @@ static void check_merge_bases(int no_checkout)
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
for (; result; result = result->next) {
const unsigned char *mb = result->item->object.sha1;
const unsigned char *mb = get_object_hash(result->item->object);
if (!hashcmp(mb, current_bad_oid->hash)) {
handle_bad_merge_base();
} else if (0 <= sha1_array_lookup(&good_revs, mb)) {
......@@ -973,7 +973,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
exit(4);
}
bisect_rev = revs.commits->item->object.sha1;
bisect_rev = get_object_hash(revs.commits->item->object);
if (!hashcmp(bisect_rev, current_bad_oid->hash)) {
exit_if_skipped_commits(tried, current_bad_oid);
......
......@@ -267,7 +267,7 @@ void create_branch(const char *head,
if ((commit = lookup_commit_reference(sha1)) == NULL)
die(_("Not a valid branch point: '%s'."), start_name);
hashcpy(sha1, commit->object.sha1);
hashcpy(sha1, get_object_hash(commit->object));
if (forcing)
snprintf(msg, sizeof msg, "branch: Reset to %s",
......
......@@ -506,7 +506,7 @@ static int fill_blob_sha1_and_mode(struct origin *origin)
{
if (!is_null_sha1(origin->blob_sha1))
return 0;
if (get_tree_entry(origin->commit->object.sha1,
if (get_tree_entry(get_object_hash(origin->commit->object),
origin->path,
origin->blob_sha1, &origin->mode))
goto error_out;
......@@ -558,10 +558,10 @@ static struct origin *find_origin(struct scoreboard *sb,
diff_setup_done(&diff_opts);
if (is_null_sha1(origin->commit->object.sha1))
do_diff_cache(parent->tree->object.sha1, &diff_opts);
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
else
diff_tree_sha1(parent->tree->object.sha1,
origin->commit->tree->object.sha1,
diff_tree_sha1(get_object_hash(parent->tree->object),
get_object_hash(origin->commit->tree->object),
"", &diff_opts);
diffcore_std(&diff_opts);
......@@ -628,10 +628,10 @@ static struct origin *find_rename(struct scoreboard *sb,
diff_setup_done(&diff_opts);
if (is_null_sha1(origin->commit->object.sha1))
do_diff_cache(parent->tree->object.sha1, &diff_opts);
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
else
diff_tree_sha1(parent->tree->object.sha1,
origin->commit->tree->object.sha1,
diff_tree_sha1(get_object_hash(parent->tree->object),
get_object_hash(origin->commit->tree->object),
"", &diff_opts);
diffcore_std(&diff_opts);
......@@ -1276,10 +1276,10 @@ static void find_copy_in_parent(struct scoreboard *sb,
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
if (is_null_sha1(target->commit->object.sha1))
do_diff_cache(parent->tree->object.sha1, &diff_opts);
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
else
diff_tree_sha1(parent->tree->object.sha1,
target->commit->tree->object.sha1,
diff_tree_sha1(get_object_hash(parent->tree->object),
get_object_hash(target->commit->tree->object),
"", &diff_opts);
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
......@@ -2077,7 +2077,7 @@ static int read_ancestry(const char *graft_file)
static int update_auto_abbrev(int auto_abbrev, struct origin *suspect)
{
const char *uniq = find_unique_abbrev(suspect->commit->object.sha1,
const char *uniq = find_unique_abbrev(get_object_hash(suspect->commit->object),
auto_abbrev);
int len = strlen(uniq);
if (auto_abbrev < len)
......@@ -2216,7 +2216,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
struct commit_list *parents;
for (parents = work_tree->parents; parents; parents = parents->next) {
const unsigned char *commit_sha1 = parents->item->object.sha1;
const unsigned char *commit_sha1 = get_object_hash(parents->item->object);
unsigned char blob_sha1[20];
unsigned mode;
......
......@@ -349,7 +349,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_array_item *item,
fill_tracking_info(&stat, refname, filter->verbose > 1);
strbuf_addf(out, " %s %s%s",
find_unique_abbrev(item->commit->object.sha1, filter->abbrev),
find_unique_abbrev(get_object_hash(item->commit->object), filter->abbrev),
stat.buf, sub);
strbuf_release(&stat);
strbuf_release(&subject);
......
......@@ -401,7 +401,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
}
......@@ -510,7 +510,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
setup_standard_excludes(topts.dir);
}
tree = parse_tree_indirect(old->commit ?
old->commit->object.sha1 :
get_object_hash(old->commit->object) :
EMPTY_TREE_SHA1_BIN);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(new->commit->object.sha1);
......@@ -653,7 +653,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
/* Nothing to do. */
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
update_ref(msg.buf, "HEAD", new->commit->object.sha1, NULL,
update_ref(msg.buf, "HEAD", get_object_hash(new->commit->object), NULL,
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
if (!opts->quiet) {
if (old->path && advice_detached_head)
......@@ -704,7 +704,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
strbuf_addstr(sb, " ");
strbuf_addstr(sb,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
......@@ -762,7 +762,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
" git branch <new-branch-name> %s\n\n",
/* Give ngettext() the count */
lost),
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
}
/*
......
......@@ -657,7 +657,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
} else if (our) {
struct commit *c = lookup_commit_reference(our->old_oid.hash);
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
update_ref(msg, "HEAD", c->object.sha1,
update_ref(msg, "HEAD", get_object_hash(c->object),
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
} else if (remote) {
/*
......
......@@ -299,7 +299,7 @@ static void create_base_index(const struct commit *current_head)
opts.dst_index = &the_index;
opts.fn = oneway_merge;
tree = parse_tree_indirect(current_head->object.sha1);
tree = parse_tree_indirect(get_object_hash(current_head->object));
if (!tree)
die(_("failed to unpack HEAD tree object"));
parse_tree(tree);
......@@ -1766,7 +1766,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
if (!transaction ||
ref_transaction_update(transaction, "HEAD", sha1,
current_head
? current_head->object.sha1 : null_sha1,
? get_object_hash(current_head->object) : null_sha1,
0, sb.buf, &err) ||
ref_transaction_commit(transaction, &err)) {
rollback_index_files();
......@@ -1793,10 +1793,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
cfg = init_copy_notes_for_rewrite("amend");
if (cfg) {
/* we are amending, so current_head is not NULL */
copy_note_for_rewrite(cfg, current_head->object.sha1, sha1);
copy_note_for_rewrite(cfg, get_object_hash(current_head->object), sha1);
finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
}
run_rewrite_hook(current_head->object.sha1, sha1);
run_rewrite_hook(get_object_hash(current_head->object), sha1);
}
if (!quiet)
print_summary(prefix, sha1, !current_head);
......
......@@ -252,14 +252,14 @@ static void describe(const char *arg, int last_one)
if (!cmit)
die(_("%s is not a valid '%s' object"), arg, commit_type);
n = find_commit_name(cmit->object.sha1);
n = find_commit_name(get_object_hash(cmit->object));
if (n && (tags || all || n->prio == 2)) {
/*
* Exact match to an existing ref.
*/
display_name(n);
if (longformat)
show_suffix(0, n->tag ? n->tag->tagged->sha1 : sha1);
show_suffix(0, n->tag ? get_object_hash(*n->tag->tagged) : sha1);
if (dirty)
printf("%s", dirty);
printf("\n");
......@@ -380,7 +380,7 @@ static void describe(const char *arg, int last_one)
display_name(all_matches[0].name);
if (abbrev)
show_suffix(all_matches[0].depth, cmit->object.sha1);
show_suffix(all_matches[0].depth, get_object_hash(cmit->object));
if (dirty)
printf("%s", dirty);
printf("\n");
......
......@@ -51,7 +51,7 @@ static int stdin_diff_trees(struct tree *tree1, char *line, int len)
return -1;
printf("%s %s\n", sha1_to_hex(tree1->object.sha1),
sha1_to_hex(tree2->object.sha1));
diff_tree_sha1(tree1->object.sha1, tree2->object.sha1,
diff_tree_sha1(get_object_hash(tree1->object), get_object_hash(tree2->object),
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
......@@ -139,7 +139,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
break;
case 1:
tree1 = opt->pending.objects[0].item;
diff_tree_commit_sha1(tree1->sha1);
diff_tree_commit_sha1(get_object_hash(*tree1));
break;
case 2:
tree1 = opt->pending.objects[0].item;
......@@ -149,8 +149,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
tree2 = tree1;
tree1 = tmp;
}
diff_tree_sha1(tree1->sha1,
tree2->sha1,
diff_tree_sha1(get_object_hash(*tree1),
get_object_hash(*tree2),
"", &opt->diffopt);
log_tree_diff_flush(opt);
break;
......
......@@ -175,8 +175,8 @@ static int builtin_diff_tree(struct rev_info *revs,
*/
if (ent1->item->flags & UNINTERESTING)
swap = 1;
sha1[swap] = ent0->item->sha1;
sha1[1 - swap] = ent1->item->sha1;
sha1[swap] = get_object_hash(*ent0->item);
sha1[1 - swap] = get_object_hash(*ent1->item);
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
log_tree_diff_flush(revs);
return 0;
......@@ -196,8 +196,8 @@ static int builtin_diff_combined(struct rev_info *revs,
if (!revs->dense_combined_merges && !revs->combine_merges)
revs->dense_combined_merges = revs->combine_merges = 1;
for (i = 1; i < ents; i++)
sha1_array_append(&parents, ent[i].item->sha1);
diff_tree_combined(ent[0].item->sha1, &parents,
sha1_array_append(&parents, get_object_hash(*ent[i].item));
diff_tree_combined(get_object_hash(*ent[0].item), &parents,
revs->dense_combined_merges, revs);
sha1_array_clear(&parents);
return 0;
......@@ -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->sha1);
obj = parse_object(get_object_hash(*obj));
obj = deref_tag(obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);
......@@ -408,7 +408,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
} else if (obj->type == OBJ_BLOB) {
if (2 <= blobs)
die(_("more than two blobs given: '%s'"), name);
hashcpy(blob[blobs].sha1, obj->sha1);
hashcpy(blob[blobs].sha1, get_object_hash(*obj));
blob[blobs].name = name;
blob[blobs].mode = entry->mode;
blobs++;
......
......@@ -562,11 +562,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
get_object_mark(&commit->parents->item->object) != 0 &&
!full_tree) {
parse_commit_or_die(commit->parents->item);
diff_tree_sha1(commit->parents->item->tree->object.sha1,
commit->tree->object.sha1, "", &rev->diffopt);
diff_tree_sha1(get_object_hash(commit->parents->item->tree->object),
get_object_hash(commit->tree->object), "", &rev->diffopt);
}
else
diff_root_tree_sha1(commit->tree->object.sha1,
diff_root_tree_sha1(get_object_hash(commit->tree->object),
"", &rev->diffopt);
/* Export the referenced blobs, and remember the marks. */
......@@ -665,7 +665,7 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}
buf = read_sha1_file(tag->object.sha1, &type, &size);
buf = read_sha1_file(get_object_hash(tag->object), &type, &size);
if (!buf)
die ("Could not read tag %s", sha1_to_hex(tag->object.sha1));
message = memmem(buf, size, "\n\n", 2);
......@@ -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.sha1);
parse_object(get_object_hash(tag->object));
string_list_append(&extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}
......@@ -828,7 +828,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
case OBJ_COMMIT:
break;
case OBJ_BLOB:
export_blob(commit->object.sha1);
export_blob(get_object_hash(commit->object));
continue;
default: /* OBJ_TAG (nested tags) is already handled */
warning("Tag points to object of unexpected type %s, skipping.",
......
......@@ -530,7 +530,7 @@ static int update_local_ref(struct ref *ref,
if (in_merge_bases(current, updated)) {
struct strbuf quickref = STRBUF_INIT;
int r;
strbuf_add_unique_abbrev(&quickref, current->object.sha1, DEFAULT_ABBREV);
strbuf_add_unique_abbrev(&quickref, get_object_hash(current->object), DEFAULT_ABBREV);
strbuf_addstr(&quickref, "..");
strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
......@@ -547,7 +547,7 @@ static int update_local_ref(struct ref *ref,
} else if (force || ref->force) {
struct strbuf quickref = STRBUF_INIT;
int r;
strbuf_add_unique_abbrev(&quickref, current->object.sha1, DEFAULT_ABBREV);
strbuf_add_unique_abbrev(&quickref, get_object_hash(current->object), DEFAULT_ABBREV);
strbuf_addstr(&quickref, "...");
strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
......
......@@ -568,7 +568,7 @@ static void find_merge_parents(struct merge_parents *result,
if (!parent)
continue;
commit_list_insert(parent, &parents);
add_merge_parent(result, obj->sha1, parent->object.sha1);
add_merge_parent(result, get_object_hash(*obj), get_object_hash(parent->object));
}
head_commit = lookup_commit(head);
if (head_commit)
......@@ -578,7 +578,7 @@ static void find_merge_parents(struct merge_parents *result,
while (parents) {
struct commit *cmit = pop_commit(&parents);
for (i = 0; i < result->nr; i++)
if (!hashcmp(result->item[i].commit, cmit->object.sha1))
if (!hashcmp(result->item[i].commit, get_object_hash(cmit->object)))
result->item[i].used = 1;
}
......
......@@ -186,7 +186,7 @@ static void check_reachable_object(struct object *obj)
* do a full fsck
*/
if (!(obj->flags & HAS_OBJ)) {
if (has_sha1_pack(obj->sha1))
if (has_sha1_pack(get_object_hash(*obj)))
return; /* it is in pack - forget about it */
if (connectivity_only && has_sha1_file(obj->sha1))
return;
......@@ -249,7 +249,7 @@ static void check_unreachable_object(struct object *obj)
if (!(f = fopen(filename, "w")))
die_errno("Could not open '%s'", filename);
if (obj->type == OBJ_BLOB) {
if (stream_blob_to_fd(fileno(f), obj->sha1, NULL, 1))
if (stream_blob_to_fd(fileno(f), get_object_hash(*obj), NULL, 1))
die_errno("Could not write '%s'", filename);
} else
fprintf(f, "%s\n", sha1_to_hex(obj->sha1));
......
......@@ -459,7 +459,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
struct object *obj, const char *name, const char *path)
{
if (obj->type == OBJ_BLOB)
return grep_sha1(opt, obj->sha1, name, 0, path);
return grep_sha1(opt, get_object_hash(*obj), name, 0, path);
if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {
struct tree_desc tree;
void *data;
......
......@@ -217,7 +217,7 @@ static unsigned check_object(struct object *obj)
if (!(obj->flags & FLAG_CHECKED)) {
unsigned long size;
int type = sha1_object_info(obj->sha1, &size);
int type = sha1_object_info(get_object_hash(*obj), &size);
if (type <= 0)
die(_("did not receive expected object %s"),
sha1_to_hex(obj->sha1));
......
......@@ -552,7 +552,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
const char *name = objects[i].name;
switch (o->type) {
case OBJ_BLOB:
ret = show_blob_object(o->sha1, &rev, name);
ret = show_blob_object(get_object_hash(*o), &rev, name);
break;
case OBJ_TAG: {
struct tag *t = (struct tag *)o;
......@@ -563,11 +563,11 @@ int cmd_show(int argc, const char **argv, const char *prefix)
diff_get_color_opt(&rev.diffopt, DIFF_COMMIT),
t->tag,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
ret = show_tag_object(o->sha1, &rev);
ret = show_tag_object(get_object_hash(*o), &rev);
rev.shown_one = 1;
if (ret)
break;
o = parse_object(t->tagged->sha1);
o = parse_object(get_object_hash(*t->tagged));
if (!o)
ret = error(_("Could not read object %s"),
sha1_to_hex(t->tagged->sha1));
......@@ -830,8 +830,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->sha1);
c2 = lookup_commit_reference(o2->sha1);
c1 = lookup_commit_reference(get_object_hash(*o1));
c2 = lookup_commit_reference(get_object_hash(*o2));
if ((flags1 & UNINTERESTING) == (flags2 & UNINTERESTING))
die(_("Not a range."));
......@@ -993,8 +993,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
diff_setup_done(&opts);
diff_tree_sha1(origin->tree->object.sha1,
head->tree->object.sha1,
diff_tree_sha1(get_object_hash(origin->tree->object),
get_object_hash(head->tree->object),
"", &opts);
diffcore_std(&opts);
diff_flush(&opts);
......@@ -1612,12 +1612,12 @@ static void print_commit(char sign, struct commit *commit, int verbose,
{
if (!verbose) {
printf("%c %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev));
find_unique_abbrev(get_object_hash(commit->object), abbrev));
} else {
struct strbuf buf = STRBUF_INIT;
pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
printf("%c %s %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev),
find_unique_abbrev(get_object_hash(commit->object), abbrev),
buf.buf);
strbuf_release(&buf);
}
......
......@@ -60,7 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size)
const char *path = entry->path;
if (!entry->stage)
return read_sha1_file(entry->blob->object.sha1, &type, size);
return read_sha1_file(get_object_hash(entry->blob->object), &type, size);
base = NULL;
if (entry->stage == 1) {
base = entry->blob;
......@@ -82,7 +82,7 @@ static void *origin(struct merge_list *entry, unsigned long *size)
enum object_type type;
while (entry) {
if (entry->stage == 2)
return read_sha1_file(entry->blob->object.sha1, &type, size);
return read_sha1_file(get_object_hash(entry->blob->object), &type, size);
entry = entry->link;
}
return NULL;
......
......@@ -365,7 +365,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
while ((commit = get_revision(&rev)) != NULL) {
strbuf_addch(&out, '\n');
strbuf_addf(&out, "commit %s\n",
sha1_to_hex(commit->object.sha1));
sha1_to_hex(get_object_hash(commit->object)));
pretty_print_commit(&ctx, commit, &out);
}
if (write_in_full(fd, out.buf, out.len) != out.len)
......@@ -380,7 +380,7 @@ static void finish(struct commit *head_commit,
const unsigned char *new_head, const char *msg)
{
struct strbuf reflog_message = STRBUF_INIT;
const unsigned char *head = head_commit->object.sha1;
const unsigned char *head = get_object_hash(head_commit->object);
if (!msg)
strbuf_addstr(&reflog_message, getenv("GIT_REFLOG_ACTION"));
......@@ -497,7 +497,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
if (ref_exists(truname.buf)) {
strbuf_addf(msg,
"%s\t\tbranch '%s'%s of .\n",
sha1_to_hex(remote_head->object.sha1),
sha1_to_hex(get_object_hash(remote_head->object)),
truname.buf + 11,
(early ? " (early part)" : ""));
strbuf_release(&truname);
......@@ -511,7 +511,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
desc = merge_remote_util(remote_head);
if (desc && desc->obj && desc->obj->type == OBJ_TAG) {
strbuf_addf(msg, "%s\t\t%s '%s'\n",
sha1_to_hex(desc->obj->sha1),
sha1_to_hex(get_object_hash(*desc->obj)),
typename(desc->obj->type),
remote);
goto cleanup;
......@@ -519,7 +519,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
}
strbuf_addf(msg, "%s\t\tcommit '%s'\n",
sha1_to_hex(remote_head->object.sha1), remote);
sha1_to_hex(get_object_hash(remote_head->object)), remote);
cleanup:
strbuf_release(&buf);
strbuf_release(&bname);
......@@ -892,7 +892,7 @@ static struct commit *is_old_style_invocation(int argc, const char **argv,
second_token = lookup_commit_reference_gently(second_sha1, 0);
if (!second_token)
die(_("'%s' is not a commit"), argv[1]);
if (hashcmp(second_token->object.sha1, head))
if (hashcmp(get_object_hash(second_token->object), head))
return NULL;
}
return second_token;
......@@ -963,7 +963,7 @@ static void write_merge_state(struct commit_list *remoteheads)
if (c->util && merge_remote_util(c)->obj) {
sha1 = merge_remote_util(c)->obj->sha1;
} else {
sha1 = c->object.sha1;
sha1 = get_object_hash(c->object);
}
strbuf_addf(&buf, "%s\n", sha1_to_hex(sha1));
}
......@@ -1274,8 +1274,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
die(_("%s - not something we can merge"), argv[0]);
if (remoteheads->next)
die(_("Can merge only exactly one commit into empty head"));
read_empty(remote_head->object.sha1, 0);
update_ref("initial pull", "HEAD", remote_head->object.sha1,
read_empty(get_object_hash(remote_head->object), 0);
update_ref("initial pull", "HEAD", get_object_hash(remote_head->object),
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
goto done;
}
......@@ -1289,7 +1289,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* additional safety measure to check for it.
*/
if (!have_message &&
is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
is_old_style_invocation(argc, argv, get_object_hash(head_commit->object))) {
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
strbuf_addstr(&merge_msg, argv[0]);
head_arg = argv[1];
......@@ -1323,7 +1323,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
check_commit_signature(commit, &signature_check);
find_unique_abbrev_r(hex, commit->object.sha1, DEFAULT_ABBREV);
find_unique_abbrev_r(hex, get_object_hash(commit->object), DEFAULT_ABBREV);
switch (signature_check.result) {
case 'G':
break;
......@@ -1353,7 +1353,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
for (p = remoteheads; p; p = p->next) {
struct commit *commit = p->item;
strbuf_addf(&buf, "GITHEAD_%s",
sha1_to_hex(commit->object.sha1));
sha1_to_hex(get_object_hash(commit->object)));
setenv(buf.buf, merge_remote_util(commit)->name, 1);
strbuf_reset(&buf);
if (fast_forward != FF_ONLY &&
......@@ -1393,7 +1393,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
free(list);
}
update_ref("updating ORIG_HEAD", "ORIG_HEAD", head_commit->object.sha1,
update_ref("updating ORIG_HEAD", "ORIG_HEAD", get_object_hash(head_commit->object),
NULL, 0, UPDATE_REFS_DIE_ON_ERR);
if (remoteheads && !common)
......@@ -1409,16 +1409,16 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
} else if (fast_forward != FF_NO && !remoteheads->next &&
!common->next &&
!hashcmp(common->item->object.sha1, head_commit->object.sha1)) {
!hashcmp(get_object_hash(common->item->object), get_object_hash(head_commit->object))) {
/* Again the most common case of merging one remote. */
struct strbuf msg = STRBUF_INIT;
struct commit *commit;
if (verbosity >= 0) {
char from[GIT_SHA1_HEXSZ + 1], to[GIT_SHA1_HEXSZ + 1];
find_unique_abbrev_r(from, head_commit->object.sha1,
find_unique_abbrev_r(from, get_object_hash(head_commit->object),
DEFAULT_ABBREV);
find_unique_abbrev_r(to, remoteheads->item->object.sha1,
find_unique_abbrev_r(to, get_object_hash(remoteheads->item->object),
DEFAULT_ABBREV);
printf(_("Updating %s..%s\n"), from, to);
}
......@@ -1432,14 +1432,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
goto done;
}
if (checkout_fast_forward(head_commit->object.sha1,
commit->object.sha1,
if (checkout_fast_forward(get_object_hash(head_commit->object),
get_object_hash(commit->object),
overwrite_ignore)) {
ret = 1;
goto done;
}
finish(head_commit, remoteheads, commit->object.sha1, msg.buf);
finish(head_commit, remoteheads, get_object_hash(commit->object), msg.buf);
drop_save();
goto done;
} else if (!remoteheads->next && common->next)
......@@ -1458,9 +1458,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
/* See if it is really trivial. */
git_committer_info(IDENT_STRICT);
printf(_("Trying really trivial in-index merge...\n"));
if (!read_tree_trivial(common->item->object.sha1,
head_commit->object.sha1,
remoteheads->item->object.sha1)) {
if (!read_tree_trivial(get_object_hash(common->item->object),
get_object_hash(head_commit->object),
get_object_hash(remoteheads->item->object))) {
ret = merge_trivial(head_commit, remoteheads);
goto done;
}
......@@ -1483,8 +1483,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* HEAD^^" would be missed.
*/
common_one = get_merge_bases(head_commit, j->item);
if (hashcmp(common_one->item->object.sha1,
j->item->object.sha1)) {
if (hashcmp(get_object_hash(common_one->item->object),