diff-tree: convert diff_tree_sha1 to struct object_id

Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Williams committed May 30, 2017 at 10:31 UTC 66f414f885aa6f44ae9e764bdd3e3cd7bd80c5a3
16 files changed +47 -46
builtin/blame.c
+10 -10
@@ -565,9 +565,9 @@ static struct origin *find_origin(struct scoreboard *sb,
565 if (is_null_oid(&origin->commit->object.oid))
566 do_diff_cache(&parent->tree->object.oid, &diff_opts);
567 else
568 - diff_tree_sha1(parent->tree->object.oid.hash,
569 - origin->commit->tree->object.oid.hash,
570 - "", &diff_opts);
568 + diff_tree_oid(&parent->tree->object.oid,
569 + &origin->commit->tree->object.oid,
570 + "", &diff_opts);
571 diffcore_std(&diff_opts);
572
573 if (!diff_queued_diff.nr) {
@@ -635,9 +635,9 @@ static struct origin *find_rename(struct scoreboard *sb,
635 if (is_null_oid(&origin->commit->object.oid))
636 do_diff_cache(&parent->tree->object.oid, &diff_opts);
637 else
638 - diff_tree_sha1(parent->tree->object.oid.hash,
639 - origin->commit->tree->object.oid.hash,
640 - "", &diff_opts);
638 + diff_tree_oid(&parent->tree->object.oid,
639 + &origin->commit->tree->object.oid,
640 + "", &diff_opts);
641 diffcore_std(&diff_opts);
642
643 for (i = 0; i < diff_queued_diff.nr; i++) {
@@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
1262 /* Try "find copies harder" on new path if requested;
1263 * we do not want to use diffcore_rename() actually to
1264 * match things up; find_copies_harder is set only to
1265 - * force diff_tree_sha1() to feed all filepairs to diff_queue,
1265 + * force diff_tree_oid() to feed all filepairs to diff_queue,
1266 * and this code needs to be after diff_setup_done(), which
1267 * usually makes find-copies-harder imply copy detection.
1268 */
@@ -1274,9 +1274,9 @@ static void find_copy_in_parent(struct scoreboard *sb,
1274 if (is_null_oid(&target->commit->object.oid))
1275 do_diff_cache(&parent->tree->object.oid, &diff_opts);
1276 else
1277 - diff_tree_sha1(parent->tree->object.oid.hash,
1278 - target->commit->tree->object.oid.hash,
1279 - "", &diff_opts);
1277 + diff_tree_oid(&parent->tree->object.oid,
1278 + &target->commit->tree->object.oid,
1279 + "", &diff_opts);
1280
1281 if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
1282 diffcore_std(&diff_opts);
builtin/diff-tree.c
+3 -5
@@ -49,8 +49,8 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
49 return -1;
50 printf("%s %s\n", oid_to_hex(&tree1->object.oid),
51 oid_to_hex(&tree2->object.oid));
52 - diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
53 - "", &log_tree_opt.diffopt);
52 + diff_tree_oid(&tree1->object.oid, &tree2->object.oid,
53 + "", &log_tree_opt.diffopt);
54 log_tree_diff_flush(&log_tree_opt);
55 return 0;
56 }
@@ -148,9 +148,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
148 if (tree2->flags & UNINTERESTING) {
149 SWAP(tree2, tree1);
150 }
151 - diff_tree_sha1(tree1->oid.hash,
152 - tree2->oid.hash,
153 - "", &opt->diffopt);
151 + diff_tree_oid(&tree1->oid, &tree2->oid, "", &opt->diffopt);
152 log_tree_diff_flush(opt);
153 break;
154 }
builtin/diff.c
+1 -1
@@ -174,7 +174,7 @@ static int builtin_diff_tree(struct rev_info *revs,
174 swap = 1;
175 oid[swap] = &ent0->item->oid;
176 oid[1 - swap] = &ent1->item->oid;
177 - diff_tree_sha1(oid[0]->hash, oid[1]->hash, "", &revs->diffopt);
177 + diff_tree_oid(oid[0], oid[1], "", &revs->diffopt);
178 log_tree_diff_flush(revs);
179 return 0;
180 }
builtin/fast-export.c
+2 -2
@@ -562,8 +562,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
562 get_object_mark(&commit->parents->item->object) != 0 &&
563 !full_tree) {
564 parse_commit_or_die(commit->parents->item);
565 - diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
566 - commit->tree->object.oid.hash, "", &rev->diffopt);
565 + diff_tree_oid(&commit->parents->item->tree->object.oid,
566 + &commit->tree->object.oid, "", &rev->diffopt);
567 }
568 else
569 diff_root_tree_oid(&commit->tree->object.oid,
builtin/log.c
+3 -3
@@ -1043,9 +1043,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
1043
1044 diff_setup_done(&opts);
1045
1046 - diff_tree_sha1(origin->tree->object.oid.hash,
1047 - head->tree->object.oid.hash,
1048 - "", &opts);
1046 + diff_tree_oid(&origin->tree->object.oid,
1047 + &head->tree->object.oid,
1048 + "", &opts);
1049 diffcore_std(&opts);
1050 diff_flush(&opts);
1051
builtin/merge.c
+1 -1
@@ -415,7 +415,7 @@ static void finish(struct commit *head_commit,
415 DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
416 opts.detect_rename = DIFF_DETECT_RENAME;
417 diff_setup_done(&opts);
418 - diff_tree_sha1(head->hash, new_head->hash, "", &opts);
418 + diff_tree_oid(head, new_head, "", &opts);
419 diffcore_std(&opts);
420 diff_flush(&opts);
421 }
combine-diff.c
+2 -2
@@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
1336 opt->output_format = stat_opt;
1337 else
1338 opt->output_format = DIFF_FORMAT_NO_OUTPUT;
1339 - diff_tree_sha1(parents->oid[i].hash, oid->hash, "", opt);
1339 + diff_tree_oid(&parents->oid[i], oid, "", opt);
1340 diffcore_std(opt);
1341 paths = intersect_paths(paths, i, num_parent);
1342
@@ -1463,7 +1463,7 @@ void diff_tree_combined(const struct object_id *oid,
1463 if (stat_opt) {
1464 diffopts.output_format = stat_opt;
1465
1466 - diff_tree_sha1(parents->oid[0].hash, oid->hash, "", &diffopts);
1466 + diff_tree_oid(&parents->oid[0], oid, "", &diffopts);
1467 diffcore_std(&diffopts);
1468 if (opt->orderfile)
1469 diffcore_order(opt->orderfile);
diff.h
+3 -2
@@ -213,8 +213,9 @@ extern struct combine_diff_path *diff_tree_paths(
213 struct combine_diff_path *p, const unsigned char *sha1,
214 const unsigned char **parent_sha1, int nparent,
215 struct strbuf *base, struct diff_options *opt);
216 -extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
217 - const char *base, struct diff_options *opt);
216 +extern int diff_tree_oid(const struct object_id *old_oid,
217 + const struct object_id *new_oid,
218 + const char *base, struct diff_options *opt);
219 extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,
220 struct diff_options *opt);
221
line-log.c
+2 -2
@@ -819,8 +819,8 @@ static void queue_diffs(struct line_log_data *range,
819 assert(commit);
820
821 DIFF_QUEUE_CLEAR(&diff_queued_diff);
822 - diff_tree_sha1(parent ? parent->tree->object.oid.hash : NULL,
823 - commit->tree->object.oid.hash, "", opt);
822 + diff_tree_oid(parent ? &parent->tree->object.oid : NULL,
823 + &commit->tree->object.oid, "", opt);
824 if (opt->detect_rename) {
825 filter_diffs_for_paths(range, 1);
826 if (diff_might_be_rename())
log-tree.c
+4 -4
@@ -822,8 +822,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
822 * we merged _in_.
823 */
824 parse_commit_or_die(parents->item);
825 - diff_tree_sha1(parents->item->tree->object.oid.hash,
826 - oid->hash, "", &opt->diffopt);
825 + diff_tree_oid(&parents->item->tree->object.oid,
826 + oid, "", &opt->diffopt);
827 log_tree_diff_flush(opt);
828 return !opt->loginfo;
829 }
@@ -837,8 +837,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
837 struct commit *parent = parents->item;
838
839 parse_commit_or_die(parent);
840 - diff_tree_sha1(parent->tree->object.oid.hash,
841 - oid->hash, "", &opt->diffopt);
840 + diff_tree_oid(&parent->tree->object.oid,
841 + oid, "", &opt->diffopt);
842 log_tree_diff_flush(opt);
843
844 showed_log |= !opt->loginfo;
merge-recursive.c
+1 -1
@@ -528,7 +528,7 @@ static struct string_list *get_renames(struct merge_options *o,
528 opts.show_rename_progress = o->show_rename_progress;
529 opts.output_format = DIFF_FORMAT_NO_OUTPUT;
530 diff_setup_done(&opts);
531 - diff_tree_sha1(o_tree->object.oid.hash, tree->object.oid.hash, "", &opts);
531 + diff_tree_oid(&o_tree->object.oid, &tree->object.oid, "", &opts);
532 diffcore_std(&opts);
533 if (opts.needed_rename_limit > o->needed_rename_limit)
534 o->needed_rename_limit = opts.needed_rename_limit;
notes-merge.c
+2 -2
@@ -129,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
129 DIFF_OPT_SET(&opt, RECURSIVE);
130 opt.output_format = DIFF_FORMAT_NO_OUTPUT;
131 diff_setup_done(&opt);
132 - diff_tree_sha1(base->hash, remote->hash, "", &opt);
132 + diff_tree_oid(base, remote, "", &opt);
133 diffcore_std(&opt);
134
135 changes = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));
@@ -192,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,
192 DIFF_OPT_SET(&opt, RECURSIVE);
193 opt.output_format = DIFF_FORMAT_NO_OUTPUT;
194 diff_setup_done(&opt);
195 - diff_tree_sha1(base->hash, local->hash, "", &opt);
195 + diff_tree_oid(base, local, "", &opt);
196 diffcore_std(&opt);
197
198 for (i = 0; i < diff_queued_diff.nr; i++) {
patch-ids.c
+2 -2
@@ -17,8 +17,8 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
17 return -1;
18
19 if (commit->parents)
20 - diff_tree_sha1(commit->parents->item->object.oid.hash,
21 - commit->object.oid.hash, "", options);
20 + diff_tree_oid(&commit->parents->item->object.oid,
21 + &commit->object.oid, "", options);
22 else
23 diff_root_tree_oid(&commit->object.oid, "", options);
24 diffcore_std(options);
revision.c
+2 -2
@@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,
455
456 tree_difference = REV_TREE_SAME;
457 DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
458 - if (diff_tree_sha1(t1->object.oid.hash, t2->object.oid.hash, "",
458 + if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "",
459 &revs->pruning) < 0)
460 return REV_TREE_DIFFERENT;
461 return tree_difference;
@@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
471
472 tree_difference = REV_TREE_SAME;
473 DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
474 - retval = diff_tree_sha1(NULL, t1->object.oid.hash, "", &revs->pruning);
474 + retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
475
476 return retval >= 0 && (tree_difference == REV_TREE_SAME);
477 }
sequencer.c
+2 -2
@@ -2129,8 +2129,8 @@ cleanup_head_ref:
2129 if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
2130 !get_sha1(buf.buf, orig.hash) &&
2131 !get_sha1("HEAD", head.hash)) {
2132 - diff_tree_sha1(orig.hash, head.hash,
2133 - "", &log_tree_opt.diffopt);
2132 + diff_tree_oid(&orig, &head, "",
2133 + &log_tree_opt.diffopt);
2134 log_tree_diff_flush(&log_tree_opt);
2135 }
2136 }
tree-diff.c
+7 -5
@@ -419,7 +419,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
419 * load parents first, as they are probably already cached.
420 *
421 * ( log_tree_diff() parses commit->parent before calling here via
422 - * diff_tree_sha1(parent, commit) )
422 + * diff_tree_oid(parent, commit) )
423 */
424 for (i = 0; i < nparent; ++i)
425 tptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[i]);
@@ -694,7 +694,9 @@ static int ll_diff_tree_sha1(const unsigned char *old, const unsigned char *new,
694 return 0;
695 }
696
697 -int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base_str, struct diff_options *opt)
697 +int diff_tree_oid(const struct object_id *old_oid,
698 + const struct object_id *new_oid,
699 + const char *base_str, struct diff_options *opt)
700 {
701 struct strbuf base;
702 int retval;
@@ -702,9 +704,9 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
704 strbuf_init(&base, PATH_MAX);
705 strbuf_addstr(&base, base_str);
706
705 - retval = ll_diff_tree_sha1(old, new, &base, opt);
707 + retval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt);
708 if (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())
707 - try_to_follow_renames(old, new, &base, opt);
709 + try_to_follow_renames(old_oid->hash, new_oid->hash, &base, opt);
710
711 strbuf_release(&base);
712
@@ -713,5 +715,5 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
715
716 int diff_root_tree_oid(const struct object_id *new_oid, const char *base, struct diff_options *opt)
717 {
716 - return diff_tree_sha1(NULL, new_oid->hash, base, opt);
718 + return diff_tree_oid(NULL, new_oid, base, opt);
719 }