Skip to content

Commit ed1c997

Browse files
bk2204peff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent f2fd076 commit ed1c997

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+251
-253
lines changed

archive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ int write_archive_entries(struct archiver_args *args,
241241
len--;
242242
if (args->verbose)
243243
fprintf(stderr, "%.*s\n", (int)len, args->base);
244-
err = write_entry(args, get_object_hash(args->tree->object), args->base,
244+
err = write_entry(args, args->tree->object.oid.hash, args->base,
245245
len, 040777);
246246
if (err)
247247
return err;
@@ -374,7 +374,7 @@ static void parse_treeish_arg(const char **argv,
374374

375375
commit = lookup_commit_reference_gently(oid.hash, 1);
376376
if (commit) {
377-
commit_sha1 = get_object_hash(commit->object);
377+
commit_sha1 = commit->object.oid.hash;
378378
archive_time = commit->date;
379379
} else {
380380
commit_sha1 = NULL;
@@ -390,7 +390,7 @@ static void parse_treeish_arg(const char **argv,
390390
unsigned int mode;
391391
int err;
392392

393-
err = get_tree_entry(get_object_hash(tree->object), prefix,
393+
err = get_tree_entry(tree->object.oid.hash, prefix,
394394
tree_oid.hash, &mode);
395395
if (err || !S_ISDIR(mode))
396396
die("current working directory is untracked");

bisect.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ struct commit_list *filter_skipped(struct commit_list *list,
500500
struct commit_list *next = list->next;
501501
list->next = NULL;
502502
if (0 <= sha1_array_lookup(&skipped_revs,
503-
get_object_hash(list->item->object))) {
503+
list->item->object.oid.hash)) {
504504
if (skipped_first && !*skipped_first)
505505
*skipped_first = 1;
506506
/* Move current to tried list */
@@ -784,7 +784,7 @@ static void check_merge_bases(int no_checkout)
784784
result = get_merge_bases_many(rev[0], rev_nr - 1, rev + 1);
785785

786786
for (; result; result = result->next) {
787-
const unsigned char *mb = get_object_hash(result->item->object);
787+
const unsigned char *mb = result->item->object.oid.hash;
788788
if (!hashcmp(mb, current_bad_oid->hash)) {
789789
handle_bad_merge_base();
790790
} else if (0 <= sha1_array_lookup(&good_revs, mb)) {
@@ -973,7 +973,7 @@ int bisect_next_all(const char *prefix, int no_checkout)
973973
exit(4);
974974
}
975975

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

978978
if (!hashcmp(bisect_rev, current_bad_oid->hash)) {
979979
exit_if_skipped_commits(tried, current_bad_oid);

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void create_branch(const char *head,
267267

268268
if ((commit = lookup_commit_reference(sha1)) == NULL)
269269
die(_("Not a valid branch point: '%s'."), start_name);
270-
hashcpy(sha1, get_object_hash(commit->object));
270+
hashcpy(sha1, commit->object.oid.hash);
271271

272272
if (forcing)
273273
snprintf(msg, sizeof msg, "branch: Reset to %s",

builtin/blame.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static int fill_blob_sha1_and_mode(struct origin *origin)
506506
{
507507
if (!is_null_sha1(origin->blob_sha1))
508508
return 0;
509-
if (get_tree_entry(get_object_hash(origin->commit->object),
509+
if (get_tree_entry(origin->commit->object.oid.hash,
510510
origin->path,
511511
origin->blob_sha1, &origin->mode))
512512
goto error_out;
@@ -558,10 +558,10 @@ static struct origin *find_origin(struct scoreboard *sb,
558558
diff_setup_done(&diff_opts);
559559

560560
if (is_null_oid(&origin->commit->object.oid))
561-
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
561+
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
562562
else
563-
diff_tree_sha1(get_object_hash(parent->tree->object),
564-
get_object_hash(origin->commit->tree->object),
563+
diff_tree_sha1(parent->tree->object.oid.hash,
564+
origin->commit->tree->object.oid.hash,
565565
"", &diff_opts);
566566
diffcore_std(&diff_opts);
567567

@@ -628,10 +628,10 @@ static struct origin *find_rename(struct scoreboard *sb,
628628
diff_setup_done(&diff_opts);
629629

630630
if (is_null_oid(&origin->commit->object.oid))
631-
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
631+
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
632632
else
633-
diff_tree_sha1(get_object_hash(parent->tree->object),
634-
get_object_hash(origin->commit->tree->object),
633+
diff_tree_sha1(parent->tree->object.oid.hash,
634+
origin->commit->tree->object.oid.hash,
635635
"", &diff_opts);
636636
diffcore_std(&diff_opts);
637637

@@ -1276,10 +1276,10 @@ static void find_copy_in_parent(struct scoreboard *sb,
12761276
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
12771277

12781278
if (is_null_oid(&target->commit->object.oid))
1279-
do_diff_cache(get_object_hash(parent->tree->object), &diff_opts);
1279+
do_diff_cache(parent->tree->object.oid.hash, &diff_opts);
12801280
else
1281-
diff_tree_sha1(get_object_hash(parent->tree->object),
1282-
get_object_hash(target->commit->tree->object),
1281+
diff_tree_sha1(parent->tree->object.oid.hash,
1282+
target->commit->tree->object.oid.hash,
12831283
"", &diff_opts);
12841284

12851285
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
@@ -2077,7 +2077,7 @@ static int read_ancestry(const char *graft_file)
20772077

20782078
static int update_auto_abbrev(int auto_abbrev, struct origin *suspect)
20792079
{
2080-
const char *uniq = find_unique_abbrev(get_object_hash(suspect->commit->object),
2080+
const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash,
20812081
auto_abbrev);
20822082
int len = strlen(uniq);
20832083
if (auto_abbrev < len)
@@ -2216,7 +2216,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
22162216
struct commit_list *parents;
22172217

22182218
for (parents = work_tree->parents; parents; parents = parents->next) {
2219-
const unsigned char *commit_sha1 = get_object_hash(parents->item->object);
2219+
const unsigned char *commit_sha1 = parents->item->object.oid.hash;
22202220
unsigned char blob_sha1[20];
22212221
unsigned mode;
22222222

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_array_item *item,
349349
fill_tracking_info(&stat, refname, filter->verbose > 1);
350350

351351
strbuf_addf(out, " %s %s%s",
352-
find_unique_abbrev(get_object_hash(item->commit->object), filter->abbrev),
352+
find_unique_abbrev(item->commit->object.oid.hash, filter->abbrev),
353353
stat.buf, sub);
354354
strbuf_release(&stat);
355355
strbuf_release(&subject);

builtin/checkout.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static void describe_detached_head(const char *msg, struct commit *commit)
401401
if (!parse_commit(commit))
402402
pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
403403
fprintf(stderr, "%s %s... %s\n", msg,
404-
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV), sb.buf);
404+
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV), sb.buf);
405405
strbuf_release(&sb);
406406
}
407407

@@ -510,7 +510,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
510510
setup_standard_excludes(topts.dir);
511511
}
512512
tree = parse_tree_indirect(old->commit ?
513-
get_object_hash(old->commit->object) :
513+
old->commit->object.oid.hash :
514514
EMPTY_TREE_SHA1_BIN);
515515
init_tree_desc(&trees[0], tree->buffer, tree->size);
516516
tree = parse_tree_indirect(new->commit->object.oid.hash);
@@ -653,7 +653,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
653653
if (!strcmp(new->name, "HEAD") && !new->path && !opts->force_detach) {
654654
/* Nothing to do. */
655655
} else if (opts->force_detach || !new->path) { /* No longer on any branch. */
656-
update_ref(msg.buf, "HEAD", get_object_hash(new->commit->object), NULL,
656+
update_ref(msg.buf, "HEAD", new->commit->object.oid.hash, NULL,
657657
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
658658
if (!opts->quiet) {
659659
if (old->path && advice_detached_head)
@@ -704,7 +704,7 @@ static void describe_one_orphan(struct strbuf *sb, struct commit *commit)
704704
{
705705
strbuf_addstr(sb, " ");
706706
strbuf_addstr(sb,
707-
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
707+
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
708708
strbuf_addch(sb, ' ');
709709
if (!parse_commit(commit))
710710
pp_commit_easy(CMIT_FMT_ONELINE, commit, sb);
@@ -762,7 +762,7 @@ static void suggest_reattach(struct commit *commit, struct rev_info *revs)
762762
" git branch <new-branch-name> %s\n\n",
763763
/* Give ngettext() the count */
764764
lost),
765-
find_unique_abbrev(get_object_hash(commit->object), DEFAULT_ABBREV));
765+
find_unique_abbrev(commit->object.oid.hash, DEFAULT_ABBREV));
766766
}
767767

768768
/*

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
657657
} else if (our) {
658658
struct commit *c = lookup_commit_reference(our->old_oid.hash);
659659
/* --branch specifies a non-branch (i.e. tags), detach HEAD */
660-
update_ref(msg, "HEAD", get_object_hash(c->object),
660+
update_ref(msg, "HEAD", c->object.oid.hash,
661661
NULL, REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
662662
} else if (remote) {
663663
/*

builtin/commit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ static void create_base_index(const struct commit *current_head)
299299
opts.dst_index = &the_index;
300300

301301
opts.fn = oneway_merge;
302-
tree = parse_tree_indirect(get_object_hash(current_head->object));
302+
tree = parse_tree_indirect(current_head->object.oid.hash);
303303
if (!tree)
304304
die(_("failed to unpack HEAD tree object"));
305305
parse_tree(tree);
@@ -1766,7 +1766,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17661766
if (!transaction ||
17671767
ref_transaction_update(transaction, "HEAD", sha1,
17681768
current_head
1769-
? get_object_hash(current_head->object) : null_sha1,
1769+
? current_head->object.oid.hash : null_sha1,
17701770
0, sb.buf, &err) ||
17711771
ref_transaction_commit(transaction, &err)) {
17721772
rollback_index_files();
@@ -1793,10 +1793,10 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
17931793
cfg = init_copy_notes_for_rewrite("amend");
17941794
if (cfg) {
17951795
/* we are amending, so current_head is not NULL */
1796-
copy_note_for_rewrite(cfg, get_object_hash(current_head->object), sha1);
1796+
copy_note_for_rewrite(cfg, current_head->object.oid.hash, sha1);
17971797
finish_copy_notes_for_rewrite(cfg, "Notes added by 'git commit --amend'");
17981798
}
1799-
run_rewrite_hook(get_object_hash(current_head->object), sha1);
1799+
run_rewrite_hook(current_head->object.oid.hash, sha1);
18001800
}
18011801
if (!quiet)
18021802
print_summary(prefix, sha1, !current_head);

builtin/describe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ static void describe(const char *arg, int last_one)
252252
if (!cmit)
253253
die(_("%s is not a valid '%s' object"), arg, commit_type);
254254

255-
n = find_commit_name(get_object_hash(cmit->object));
255+
n = find_commit_name(cmit->object.oid.hash);
256256
if (n && (tags || all || n->prio == 2)) {
257257
/*
258258
* Exact match to an existing ref.
259259
*/
260260
display_name(n);
261261
if (longformat)
262-
show_suffix(0, n->tag ? get_object_hash(*n->tag->tagged) : sha1);
262+
show_suffix(0, n->tag ? n->tag->tagged->oid.hash : sha1);
263263
if (dirty)
264264
printf("%s", dirty);
265265
printf("\n");
@@ -380,7 +380,7 @@ static void describe(const char *arg, int last_one)
380380

381381
display_name(all_matches[0].name);
382382
if (abbrev)
383-
show_suffix(all_matches[0].depth, get_object_hash(cmit->object));
383+
show_suffix(all_matches[0].depth, cmit->object.oid.hash);
384384
if (dirty)
385385
printf("%s", dirty);
386386
printf("\n");

builtin/diff-tree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int stdin_diff_trees(struct tree *tree1, char *line, int len)
5151
return -1;
5252
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
5353
oid_to_hex(&tree2->object.oid));
54-
diff_tree_sha1(get_object_hash(tree1->object), get_object_hash(tree2->object),
54+
diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
5555
"", &log_tree_opt.diffopt);
5656
log_tree_diff_flush(&log_tree_opt);
5757
return 0;
@@ -139,7 +139,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
139139
break;
140140
case 1:
141141
tree1 = opt->pending.objects[0].item;
142-
diff_tree_commit_sha1(get_object_hash(*tree1));
142+
diff_tree_commit_sha1(tree1->oid.hash);
143143
break;
144144
case 2:
145145
tree1 = opt->pending.objects[0].item;
@@ -149,8 +149,8 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
149149
tree2 = tree1;
150150
tree1 = tmp;
151151
}
152-
diff_tree_sha1(get_object_hash(*tree1),
153-
get_object_hash(*tree2),
152+
diff_tree_sha1(tree1->oid.hash,
153+
tree2->oid.hash,
154154
"", &opt->diffopt);
155155
log_tree_diff_flush(opt);
156156
break;

0 commit comments

Comments
 (0)