1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-08 20:16:10 +02:00

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>
This commit is contained in:
Brandon Williams 2017-05-30 10:31:03 -07:00 committed by Junio C Hamano
parent 9e5e0c289a
commit 66f414f885
16 changed files with 47 additions and 46 deletions

View File

@ -565,9 +565,9 @@ static struct origin *find_origin(struct scoreboard *sb,
if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
"", &diff_opts);
diff_tree_oid(&parent->tree->object.oid,
&origin->commit->tree->object.oid,
"", &diff_opts);
diffcore_std(&diff_opts);
if (!diff_queued_diff.nr) {
@ -635,9 +635,9 @@ static struct origin *find_rename(struct scoreboard *sb,
if (is_null_oid(&origin->commit->object.oid))
do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
origin->commit->tree->object.oid.hash,
"", &diff_opts);
diff_tree_oid(&parent->tree->object.oid,
&origin->commit->tree->object.oid,
"", &diff_opts);
diffcore_std(&diff_opts);
for (i = 0; i < diff_queued_diff.nr; i++) {
@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
/* Try "find copies harder" on new path if requested;
* we do not want to use diffcore_rename() actually to
* match things up; find_copies_harder is set only to
* force diff_tree_sha1() to feed all filepairs to diff_queue,
* force diff_tree_oid() to feed all filepairs to diff_queue,
* and this code needs to be after diff_setup_done(), which
* usually makes find-copies-harder imply copy detection.
*/
@ -1274,9 +1274,9 @@ static void find_copy_in_parent(struct scoreboard *sb,
if (is_null_oid(&target->commit->object.oid))
do_diff_cache(&parent->tree->object.oid, &diff_opts);
else
diff_tree_sha1(parent->tree->object.oid.hash,
target->commit->tree->object.oid.hash,
"", &diff_opts);
diff_tree_oid(&parent->tree->object.oid,
&target->commit->tree->object.oid,
"", &diff_opts);
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
diffcore_std(&diff_opts);

View File

@ -49,8 +49,8 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
return -1;
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
oid_to_hex(&tree2->object.oid));
diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
"", &log_tree_opt.diffopt);
diff_tree_oid(&tree1->object.oid, &tree2->object.oid,
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
return 0;
}
@ -148,9 +148,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
if (tree2->flags & UNINTERESTING) {
SWAP(tree2, tree1);
}
diff_tree_sha1(tree1->oid.hash,
tree2->oid.hash,
"", &opt->diffopt);
diff_tree_oid(&tree1->oid, &tree2->oid, "", &opt->diffopt);
log_tree_diff_flush(opt);
break;
}

View File

@ -174,7 +174,7 @@ static int builtin_diff_tree(struct rev_info *revs,
swap = 1;
oid[swap] = &ent0->item->oid;
oid[1 - swap] = &ent1->item->oid;
diff_tree_sha1(oid[0]->hash, oid[1]->hash, "", &revs->diffopt);
diff_tree_oid(oid[0], oid[1], "", &revs->diffopt);
log_tree_diff_flush(revs);
return 0;
}

View File

@ -562,8 +562,8 @@ 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.oid.hash,
commit->tree->object.oid.hash, "", &rev->diffopt);
diff_tree_oid(&commit->parents->item->tree->object.oid,
&commit->tree->object.oid, "", &rev->diffopt);
}
else
diff_root_tree_oid(&commit->tree->object.oid,

View File

@ -1043,9 +1043,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
diff_setup_done(&opts);
diff_tree_sha1(origin->tree->object.oid.hash,
head->tree->object.oid.hash,
"", &opts);
diff_tree_oid(&origin->tree->object.oid,
&head->tree->object.oid,
"", &opts);
diffcore_std(&opts);
diff_flush(&opts);

View File

@ -415,7 +415,7 @@ static void finish(struct commit *head_commit,
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
opts.detect_rename = DIFF_DETECT_RENAME;
diff_setup_done(&opts);
diff_tree_sha1(head->hash, new_head->hash, "", &opts);
diff_tree_oid(head, new_head, "", &opts);
diffcore_std(&opts);
diff_flush(&opts);
}

View File

@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
opt->output_format = stat_opt;
else
opt->output_format = DIFF_FORMAT_NO_OUTPUT;
diff_tree_sha1(parents->oid[i].hash, oid->hash, "", opt);
diff_tree_oid(&parents->oid[i], oid, "", opt);
diffcore_std(opt);
paths = intersect_paths(paths, i, num_parent);
@ -1463,7 +1463,7 @@ void diff_tree_combined(const struct object_id *oid,
if (stat_opt) {
diffopts.output_format = stat_opt;
diff_tree_sha1(parents->oid[0].hash, oid->hash, "", &diffopts);
diff_tree_oid(&parents->oid[0], oid, "", &diffopts);
diffcore_std(&diffopts);
if (opt->orderfile)
diffcore_order(opt->orderfile);

5
diff.h
View File

@ -213,8 +213,9 @@ extern struct combine_diff_path *diff_tree_paths(
struct combine_diff_path *p, const unsigned char *sha1,
const unsigned char **parent_sha1, int nparent,
struct strbuf *base, struct diff_options *opt);
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
const char *base, struct diff_options *opt);
extern int diff_tree_oid(const struct object_id *old_oid,
const struct object_id *new_oid,
const char *base, struct diff_options *opt);
extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,
struct diff_options *opt);

View File

@ -819,8 +819,8 @@ static void queue_diffs(struct line_log_data *range,
assert(commit);
DIFF_QUEUE_CLEAR(&diff_queued_diff);
diff_tree_sha1(parent ? parent->tree->object.oid.hash : NULL,
commit->tree->object.oid.hash, "", opt);
diff_tree_oid(parent ? &parent->tree->object.oid : NULL,
&commit->tree->object.oid, "", opt);
if (opt->detect_rename) {
filter_diffs_for_paths(range, 1);
if (diff_might_be_rename())

View File

@ -822,8 +822,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
* we merged _in_.
*/
parse_commit_or_die(parents->item);
diff_tree_sha1(parents->item->tree->object.oid.hash,
oid->hash, "", &opt->diffopt);
diff_tree_oid(&parents->item->tree->object.oid,
oid, "", &opt->diffopt);
log_tree_diff_flush(opt);
return !opt->loginfo;
}
@ -837,8 +837,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
struct commit *parent = parents->item;
parse_commit_or_die(parent);
diff_tree_sha1(parent->tree->object.oid.hash,
oid->hash, "", &opt->diffopt);
diff_tree_oid(&parent->tree->object.oid,
oid, "", &opt->diffopt);
log_tree_diff_flush(opt);
showed_log |= !opt->loginfo;

View File

@ -528,7 +528,7 @@ static struct string_list *get_renames(struct merge_options *o,
opts.show_rename_progress = o->show_rename_progress;
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
diff_setup_done(&opts);
diff_tree_sha1(o_tree->object.oid.hash, tree->object.oid.hash, "", &opts);
diff_tree_oid(&o_tree->object.oid, &tree->object.oid, "", &opts);
diffcore_std(&opts);
if (opts.needed_rename_limit > o->needed_rename_limit)
o->needed_rename_limit = opts.needed_rename_limit;

View File

@ -129,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
DIFF_OPT_SET(&opt, RECURSIVE);
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
diff_setup_done(&opt);
diff_tree_sha1(base->hash, remote->hash, "", &opt);
diff_tree_oid(base, remote, "", &opt);
diffcore_std(&opt);
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,
DIFF_OPT_SET(&opt, RECURSIVE);
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
diff_setup_done(&opt);
diff_tree_sha1(base->hash, local->hash, "", &opt);
diff_tree_oid(base, local, "", &opt);
diffcore_std(&opt);
for (i = 0; i < diff_queued_diff.nr; i++) {

View File

@ -17,8 +17,8 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
return -1;
if (commit->parents)
diff_tree_sha1(commit->parents->item->object.oid.hash,
commit->object.oid.hash, "", options);
diff_tree_oid(&commit->parents->item->object.oid,
&commit->object.oid, "", options);
else
diff_root_tree_oid(&commit->object.oid, "", options);
diffcore_std(options);

View File

@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,
tree_difference = REV_TREE_SAME;
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
if (diff_tree_sha1(t1->object.oid.hash, t2->object.oid.hash, "",
if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "",
&revs->pruning) < 0)
return REV_TREE_DIFFERENT;
return tree_difference;
@ -471,7 +471,7 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
tree_difference = REV_TREE_SAME;
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
retval = diff_tree_sha1(NULL, t1->object.oid.hash, "", &revs->pruning);
retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
return retval >= 0 && (tree_difference == REV_TREE_SAME);
}

View File

@ -2129,8 +2129,8 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
!get_sha1(buf.buf, orig.hash) &&
!get_sha1("HEAD", head.hash)) {
diff_tree_sha1(orig.hash, head.hash,
"", &log_tree_opt.diffopt);
diff_tree_oid(&orig, &head, "",
&log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
}
}

View File

@ -419,7 +419,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
* load parents first, as they are probably already cached.
*
* ( log_tree_diff() parses commit->parent before calling here via
* diff_tree_sha1(parent, commit) )
* diff_tree_oid(parent, commit) )
*/
for (i = 0; i < nparent; ++i)
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,
return 0;
}
int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const char *base_str, struct diff_options *opt)
int diff_tree_oid(const struct object_id *old_oid,
const struct object_id *new_oid,
const char *base_str, struct diff_options *opt)
{
struct strbuf base;
int retval;
@ -702,9 +704,9 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
strbuf_init(&base, PATH_MAX);
strbuf_addstr(&base, base_str);
retval = ll_diff_tree_sha1(old, new, &base, opt);
retval = ll_diff_tree_sha1(old_oid->hash, new_oid->hash, &base, opt);
if (!*base_str && DIFF_OPT_TST(opt, FOLLOW_RENAMES) && diff_might_be_rename())
try_to_follow_renames(old, new, &base, opt);
try_to_follow_renames(old_oid->hash, new_oid->hash, &base, opt);
strbuf_release(&base);
@ -713,5 +715,5 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
int diff_root_tree_oid(const struct object_id *new_oid, const char *base, struct diff_options *opt)
{
return diff_tree_sha1(NULL, new_oid->hash, base, opt);
return diff_tree_oid(NULL, new_oid, base, opt);
}