Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove get_object_hash.
Convert all instances of get_object_hash to use an appropriate reference
to the hash member of the oid member of struct object.  This provides no
functional change, as it is essentially a macro substitution.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
brian m. carlson authored and Jeff King committed Nov 20, 2015
1 parent f2fd076 commit ed1c997
Show file tree
Hide file tree
Showing 63 changed files with 251 additions and 253 deletions.
6 changes: 3 additions & 3 deletions archive.c
Expand Up @@ -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, get_object_hash(args->tree->object), args->base,
err = write_entry(args, args->tree->object.oid.hash, args->base,
len, 040777);
if (err)
return err;
Expand Down Expand Up @@ -374,7 +374,7 @@ static void parse_treeish_arg(const char **argv,

commit = lookup_commit_reference_gently(oid.hash, 1);
if (commit) {
commit_sha1 = get_object_hash(commit->object);
commit_sha1 = commit->object.oid.hash;
archive_time = commit->date;
} else {
commit_sha1 = NULL;
Expand All @@ -390,7 +390,7 @@ static void parse_treeish_arg(const char **argv,
unsigned int mode;
int err;

err = get_tree_entry(get_object_hash(tree->object), prefix,
err = get_tree_entry(tree->object.oid.hash, prefix,
tree_oid.hash, &mode);
if (err || !S_ISDIR(mode))
die("current working directory is untracked");
Expand Down
6 changes: 3 additions & 3 deletions bisect.c
Expand Up @@ -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,
get_object_hash(list->item->object))) {
list->item->object.oid.hash)) {
if (skipped_first && !*skipped_first)
*skipped_first = 1;
/* Move current to tried list */
Expand Down Expand Up @@ -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 = get_object_hash(result->item->object);
const unsigned char *mb = result->item->object.oid.hash;
if (!hashcmp(mb, current_bad_oid->hash)) {
handle_bad_merge_base();
} else if (0 <= sha1_array_lookup(&good_revs, mb)) {
Expand Down Expand Up @@ -973,7 +973,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
exit(4);
}

bisect_rev = get_object_hash(revs.commits->item->object);
bisect_rev = revs.commits->item->object.oid.hash;

if (!hashcmp(bisect_rev, current_bad_oid->hash)) {
exit_if_skipped_commits(tried, current_bad_oid);
Expand Down
2 changes: 1 addition & 1 deletion branch.c
Expand Up @@ -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, get_object_hash(commit->object));
hashcpy(sha1, commit->object.oid.hash);

if (forcing)
snprintf(msg, sizeof msg, "branch: Reset to %s",
Expand Down
24 changes: 12 additions & 12 deletions builtin/blame.c
Expand Up @@ -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(get_object_hash(origin->commit->object),
if (get_tree_entry(origin->commit->object.oid.hash,
origin->path,
origin->blob_sha1, &origin->mode))
goto error_out;
Expand Down Expand Up @@ -558,10 +558,10 @@ static struct origin *find_origin(struct scoreboard *sb,
diff_setup_done(&diff_opts);

if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
else
diff_tree_sha1(get_object_hash(parent->tree->object),
get_object_hash(origin->commit->tree->object),
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
"", &diff_opts);
diffcore_std(&diff_opts);

Expand Down Expand Up @@ -628,10 +628,10 @@ static struct origin *find_rename(struct scoreboard *sb,
diff_setup_done(&diff_opts);

if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
else
diff_tree_sha1(get_object_hash(parent->tree->object),
get_object_hash(origin->commit->tree->object),
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
"", &diff_opts);
diffcore_std(&diff_opts);

Expand Down Expand Up @@ -1276,10 +1276,10 @@ 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(get_object_hash(parent->tree->object), &diff_opts);
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
else
diff_tree_sha1(get_object_hash(parent->tree->object),
get_object_hash(target->commit->tree->object),
diff_tree_sha1(parent->tree->object.oid.hash,
target->commit->tree->object.oid.hash,
"", &diff_opts);

if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
Expand Down Expand Up @@ -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(get_object_hash(suspect->commit->object),
const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,
auto_abbrev);
int len = strlen(uniq);
if (auto_abbrev < len)
Expand Down Expand Up @@ -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 = get_object_hash(parents->item->object);
const unsigned char *commit_sha1 = parents->item->object.oid.hash;
unsigned char blob_sha1[20];
unsigned mode;

Expand Down
2 changes: 1 addition & 1 deletion builtin/branch.c
Expand Up @@ -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(get_object_hash(item->commit->object), filter->abbrev),
find_unique_abbrev(item->commit->object.oid.hash, filter->abbrev),
stat.buf, sub);
strbuf_release(&stat);
strbuf_release(&subject);
Expand Down
10 changes: 5 additions & 5 deletions builtin/checkout.c
Expand Up @@ -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(get_object_hash(commit->object), DEFAULT_ABBREV), sb.buf);
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
}

Expand Down Expand Up @@ -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 ?
get_object_hash(old->commit->object) :
old->commit->object.oid.hash :
EMPTY_TREE_SHA1_BIN);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(new->commit->object.oid.hash);
Expand Down Expand Up @@ -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", get_object_hash(new->commit->object), NULL,
update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL,
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
if (!opts->quiet) {
if (old->path && advice_detached_head)
Expand Down Expand Up @@ -704,7 +704,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
{
strbuf_addstr(sb, " ");
strbuf_addstr(sb,
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
strbuf_addch(sb, ' ');
if (!parse_commit(commit))
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
Expand Down Expand Up @@ -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(get_object_hash(commit->object), DEFAULT_ABBREV));
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
}

/*
Expand Down
2 changes: 1 addition & 1 deletion builtin/clone.c
Expand Up @@ -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", get_object_hash(c->object),
update_ref(msg, "HEAD", c->object.oid.hash,
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
} else if (remote) {
/*
Expand Down
8 changes: 4 additions & 4 deletions builtin/commit.c
Expand Up @@ -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(get_object_hash(current_head->object));
tree = parse_tree_indirect(current_head->object.oid.hash);
if (!tree)
die(_("failed to unpack HEAD tree object"));
parse_tree(tree);
Expand Down Expand Up @@ -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
? get_object_hash(current_head->object) : null_sha1,
? current_head->object.oid.hash : null_sha1,
0, sb.buf, &err) ||
ref_transaction_commit(transaction, &err)) {
rollback_index_files();
Expand All @@ -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, get_object_hash(current_head->object), sha1);
copy_note_for_rewrite(cfg, current_head->object.oid.hash, sha1);
finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
}
run_rewrite_hook(get_object_hash(current_head->object), sha1);
run_rewrite_hook(current_head->object.oid.hash, sha1);
}
if (!quiet)
print_summary(prefix, sha1, !current_head);
Expand Down
6 changes: 3 additions & 3 deletions builtin/describe.c
Expand Up @@ -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(get_object_hash(cmit->object));
n = find_commit_name(cmit->object.oid.hash);
if (n && (tags || all || n->prio == 2)) {
/*
* Exact match to an existing ref.
*/
display_name(n);
if (longformat)
show_suffix(0, n->tag ? get_object_hash(*n->tag->tagged) : sha1);
show_suffix(0, n->tag ? n->tag->tagged->oid.hash : sha1);
if (dirty)
printf("%s", dirty);
printf("\n");
Expand Down Expand Up @@ -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, get_object_hash(cmit->object));
show_suffix(all_matches[0].depth, cmit->object.oid.hash);
if (dirty)
printf("%s", dirty);
printf("\n");
Expand Down
8 changes: 4 additions & 4 deletions builtin/diff-tree.c
Expand Up @@ -51,7 +51,7 @@ static int stdin_diff_trees(struct tree *tree1, char *line, int len)
return -1;
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
oid_to_hex(&tree2->object.oid));
diff_tree_sha1(get_object_hash(tree1->object), get_object_hash(tree2->object),
diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
Expand Down Expand Up @@ -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(get_object_hash(*tree1));
diff_tree_commit_sha1(tree1->oid.hash);
break;
case 2:
tree1 = opt->pending.objects[0].item;
Expand All @@ -149,8 +149,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
tree2 = tree1;
tree1 = tmp;
}
diff_tree_sha1(get_object_hash(*tree1),
get_object_hash(*tree2),
diff_tree_sha1(tree1->oid.hash,
tree2->oid.hash,
"", &opt->diffopt);
log_tree_diff_flush(opt);
break;
Expand Down
12 changes: 6 additions & 6 deletions builtin/diff.c
Expand Up @@ -175,8 +175,8 @@ static int builtin_diff_tree(struct rev_info *revs,
*/
if (ent1->item->flags & UNINTERESTING)
swap = 1;
sha1[swap] = get_object_hash(*ent0->item);
sha1[1 - swap] = get_object_hash(*ent1->item);
sha1[swap] = ent0->item->oid.hash;
sha1[1 - swap] = ent1->item->oid.hash;
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
log_tree_diff_flush(revs);
return 0;
Expand All @@ -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, get_object_hash(*ent[i].item));
diff_tree_combined(get_object_hash(*ent[0].item), &parents,
sha1_array_append(&parents, ent[i].item->oid.hash);
diff_tree_combined(ent[0].item->oid.hash, &parents,
revs->dense_combined_merges, revs);
sha1_array_clear(&parents);
return 0;
Expand Down Expand Up @@ -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(get_object_hash(*obj));
obj = parse_object(obj->oid.hash);
obj = deref_tag(obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);
Expand All @@ -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, get_object_hash(*obj));
hashcpy(blob[blobs].sha1, obj->oid.hash);
blob[blobs].name = name;
blob[blobs].mode = entry->mode;
blobs++;
Expand Down
12 changes: 6 additions & 6 deletions builtin/fast-export.c
Expand Up @@ -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(get_object_hash(commit->parents->item->tree->object),
get_object_hash(commit->tree->object), "", &rev->diffopt);
diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
commit->tree->object.oid.hash, "", &rev->diffopt);
}
else
diff_root_tree_sha1(get_object_hash(commit->tree->object),
diff_root_tree_sha1(commit->tree->object.oid.hash,
"", &rev->diffopt);

/* Export the referenced blobs, and remember the marks. */
Expand Down Expand Up @@ -665,7 +665,7 @@ static void handle_tag(const char *name, struct tag *tag)
return;
}

buf = read_sha1_file(get_object_hash(tag->object), &type, &size);
buf = read_sha1_file(tag->object.oid.hash, &type, &size);
if (!buf)
die ("Could not read tag %s", oid_to_hex(&tag->object.oid));
message = memmem(buf, size, "\n\n", 2);
Expand Down Expand Up @@ -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(get_object_hash(tag->object));
parse_object(tag->object.oid.hash);
string_list_append(&extra_refs, full_name)->util = tag;
tag = (struct tag *)tag->tagged;
}
Expand Down Expand Up @@ -828,7 +828,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
case OBJ_COMMIT:
break;
case OBJ_BLOB:
export_blob(get_object_hash(commit->object));
export_blob(commit->object.oid.hash);
continue;
default: /* OBJ_TAG (nested tags) is already handled */
warning("Tag points to object of unexpected type %s, skipping.",
Expand Down
4 changes: 2 additions & 2 deletions builtin/fetch.c
Expand Up @@ -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, get_object_hash(current->object), DEFAULT_ABBREV);
strbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);
strbuf_addstr(&quickref, "..");
strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
Expand All @@ -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, get_object_hash(current->object), DEFAULT_ABBREV);
strbuf_add_unique_abbrev(&quickref, current->object.oid.hash, DEFAULT_ABBREV);
strbuf_addstr(&quickref, "...");
strbuf_add_unique_abbrev(&quickref, ref->new_oid.hash, DEFAULT_ABBREV);
if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
Expand Down
4 changes: 2 additions & 2 deletions builtin/fmt-merge-msg.c
Expand Up @@ -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, get_object_hash(*obj), get_object_hash(parent->object));
add_merge_parent(result, obj->oid.hash, parent->object.oid.hash);
}
head_commit = lookup_commit(head);
if (head_commit)
Expand All @@ -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, get_object_hash(cmit->object)))
if (!hashcmp(result->item[i].commit, cmit->object.oid.hash))
result->item[i].used = 1;
}

Expand Down

0 comments on commit ed1c997

Please sign in to comment.