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:
parent
9e5e0c289a
commit
66f414f885
@ -565,8 +565,8 @@ static struct origin *find_origin(struct scoreboard *sb,
|
|||||||
if (is_null_oid(&origin->commit->object.oid))
|
if (is_null_oid(&origin->commit->object.oid))
|
||||||
do_diff_cache(&parent->tree->object.oid, &diff_opts);
|
do_diff_cache(&parent->tree->object.oid, &diff_opts);
|
||||||
else
|
else
|
||||||
diff_tree_sha1(parent->tree->object.oid.hash,
|
diff_tree_oid(&parent->tree->object.oid,
|
||||||
origin->commit->tree->object.oid.hash,
|
&origin->commit->tree->object.oid,
|
||||||
"", &diff_opts);
|
"", &diff_opts);
|
||||||
diffcore_std(&diff_opts);
|
diffcore_std(&diff_opts);
|
||||||
|
|
||||||
@ -635,8 +635,8 @@ static struct origin *find_rename(struct scoreboard *sb,
|
|||||||
if (is_null_oid(&origin->commit->object.oid))
|
if (is_null_oid(&origin->commit->object.oid))
|
||||||
do_diff_cache(&parent->tree->object.oid, &diff_opts);
|
do_diff_cache(&parent->tree->object.oid, &diff_opts);
|
||||||
else
|
else
|
||||||
diff_tree_sha1(parent->tree->object.oid.hash,
|
diff_tree_oid(&parent->tree->object.oid,
|
||||||
origin->commit->tree->object.oid.hash,
|
&origin->commit->tree->object.oid,
|
||||||
"", &diff_opts);
|
"", &diff_opts);
|
||||||
diffcore_std(&diff_opts);
|
diffcore_std(&diff_opts);
|
||||||
|
|
||||||
@ -1262,7 +1262,7 @@ static void find_copy_in_parent(struct scoreboard *sb,
|
|||||||
/* Try "find copies harder" on new path if requested;
|
/* Try "find copies harder" on new path if requested;
|
||||||
* we do not want to use diffcore_rename() actually to
|
* we do not want to use diffcore_rename() actually to
|
||||||
* match things up; find_copies_harder is set only 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
|
* and this code needs to be after diff_setup_done(), which
|
||||||
* usually makes find-copies-harder imply copy detection.
|
* usually makes find-copies-harder imply copy detection.
|
||||||
*/
|
*/
|
||||||
@ -1274,8 +1274,8 @@ static void find_copy_in_parent(struct scoreboard *sb,
|
|||||||
if (is_null_oid(&target->commit->object.oid))
|
if (is_null_oid(&target->commit->object.oid))
|
||||||
do_diff_cache(&parent->tree->object.oid, &diff_opts);
|
do_diff_cache(&parent->tree->object.oid, &diff_opts);
|
||||||
else
|
else
|
||||||
diff_tree_sha1(parent->tree->object.oid.hash,
|
diff_tree_oid(&parent->tree->object.oid,
|
||||||
target->commit->tree->object.oid.hash,
|
&target->commit->tree->object.oid,
|
||||||
"", &diff_opts);
|
"", &diff_opts);
|
||||||
|
|
||||||
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
|
if (!DIFF_OPT_TST(&diff_opts, FIND_COPIES_HARDER))
|
||||||
|
@ -49,7 +49,7 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
|
|||||||
return -1;
|
return -1;
|
||||||
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
|
printf("%s %s\n", oid_to_hex(&tree1->object.oid),
|
||||||
oid_to_hex(&tree2->object.oid));
|
oid_to_hex(&tree2->object.oid));
|
||||||
diff_tree_sha1(tree1->object.oid.hash, tree2->object.oid.hash,
|
diff_tree_oid(&tree1->object.oid, &tree2->object.oid,
|
||||||
"", &log_tree_opt.diffopt);
|
"", &log_tree_opt.diffopt);
|
||||||
log_tree_diff_flush(&log_tree_opt);
|
log_tree_diff_flush(&log_tree_opt);
|
||||||
return 0;
|
return 0;
|
||||||
@ -148,9 +148,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
|
|||||||
if (tree2->flags & UNINTERESTING) {
|
if (tree2->flags & UNINTERESTING) {
|
||||||
SWAP(tree2, tree1);
|
SWAP(tree2, tree1);
|
||||||
}
|
}
|
||||||
diff_tree_sha1(tree1->oid.hash,
|
diff_tree_oid(&tree1->oid, &tree2->oid, "", &opt->diffopt);
|
||||||
tree2->oid.hash,
|
|
||||||
"", &opt->diffopt);
|
|
||||||
log_tree_diff_flush(opt);
|
log_tree_diff_flush(opt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ static int builtin_diff_tree(struct rev_info *revs,
|
|||||||
swap = 1;
|
swap = 1;
|
||||||
oid[swap] = &ent0->item->oid;
|
oid[swap] = &ent0->item->oid;
|
||||||
oid[1 - swap] = &ent1->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);
|
log_tree_diff_flush(revs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -562,8 +562,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
|
|||||||
get_object_mark(&commit->parents->item->object) != 0 &&
|
get_object_mark(&commit->parents->item->object) != 0 &&
|
||||||
!full_tree) {
|
!full_tree) {
|
||||||
parse_commit_or_die(commit->parents->item);
|
parse_commit_or_die(commit->parents->item);
|
||||||
diff_tree_sha1(commit->parents->item->tree->object.oid.hash,
|
diff_tree_oid(&commit->parents->item->tree->object.oid,
|
||||||
commit->tree->object.oid.hash, "", &rev->diffopt);
|
&commit->tree->object.oid, "", &rev->diffopt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
diff_root_tree_oid(&commit->tree->object.oid,
|
diff_root_tree_oid(&commit->tree->object.oid,
|
||||||
|
@ -1043,8 +1043,8 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
|
|||||||
|
|
||||||
diff_setup_done(&opts);
|
diff_setup_done(&opts);
|
||||||
|
|
||||||
diff_tree_sha1(origin->tree->object.oid.hash,
|
diff_tree_oid(&origin->tree->object.oid,
|
||||||
head->tree->object.oid.hash,
|
&head->tree->object.oid,
|
||||||
"", &opts);
|
"", &opts);
|
||||||
diffcore_std(&opts);
|
diffcore_std(&opts);
|
||||||
diff_flush(&opts);
|
diff_flush(&opts);
|
||||||
|
@ -415,7 +415,7 @@ static void finish(struct commit *head_commit,
|
|||||||
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
|
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
|
||||||
opts.detect_rename = DIFF_DETECT_RENAME;
|
opts.detect_rename = DIFF_DETECT_RENAME;
|
||||||
diff_setup_done(&opts);
|
diff_setup_done(&opts);
|
||||||
diff_tree_sha1(head->hash, new_head->hash, "", &opts);
|
diff_tree_oid(head, new_head, "", &opts);
|
||||||
diffcore_std(&opts);
|
diffcore_std(&opts);
|
||||||
diff_flush(&opts);
|
diff_flush(&opts);
|
||||||
}
|
}
|
||||||
|
@ -1336,7 +1336,7 @@ static struct combine_diff_path *find_paths_generic(const struct object_id *oid,
|
|||||||
opt->output_format = stat_opt;
|
opt->output_format = stat_opt;
|
||||||
else
|
else
|
||||||
opt->output_format = DIFF_FORMAT_NO_OUTPUT;
|
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);
|
diffcore_std(opt);
|
||||||
paths = intersect_paths(paths, i, num_parent);
|
paths = intersect_paths(paths, i, num_parent);
|
||||||
|
|
||||||
@ -1463,7 +1463,7 @@ void diff_tree_combined(const struct object_id *oid,
|
|||||||
if (stat_opt) {
|
if (stat_opt) {
|
||||||
diffopts.output_format = 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);
|
diffcore_std(&diffopts);
|
||||||
if (opt->orderfile)
|
if (opt->orderfile)
|
||||||
diffcore_order(opt->orderfile);
|
diffcore_order(opt->orderfile);
|
||||||
|
3
diff.h
3
diff.h
@ -213,7 +213,8 @@ extern struct combine_diff_path *diff_tree_paths(
|
|||||||
struct combine_diff_path *p, const unsigned char *sha1,
|
struct combine_diff_path *p, const unsigned char *sha1,
|
||||||
const unsigned char **parent_sha1, int nparent,
|
const unsigned char **parent_sha1, int nparent,
|
||||||
struct strbuf *base, struct diff_options *opt);
|
struct strbuf *base, struct diff_options *opt);
|
||||||
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
|
extern int diff_tree_oid(const struct object_id *old_oid,
|
||||||
|
const struct object_id *new_oid,
|
||||||
const char *base, struct diff_options *opt);
|
const char *base, struct diff_options *opt);
|
||||||
extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,
|
extern int diff_root_tree_oid(const struct object_id *new_oid, const char *base,
|
||||||
struct diff_options *opt);
|
struct diff_options *opt);
|
||||||
|
@ -819,8 +819,8 @@ static void queue_diffs(struct line_log_data *range,
|
|||||||
assert(commit);
|
assert(commit);
|
||||||
|
|
||||||
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
DIFF_QUEUE_CLEAR(&diff_queued_diff);
|
||||||
diff_tree_sha1(parent ? parent->tree->object.oid.hash : NULL,
|
diff_tree_oid(parent ? &parent->tree->object.oid : NULL,
|
||||||
commit->tree->object.oid.hash, "", opt);
|
&commit->tree->object.oid, "", opt);
|
||||||
if (opt->detect_rename) {
|
if (opt->detect_rename) {
|
||||||
filter_diffs_for_paths(range, 1);
|
filter_diffs_for_paths(range, 1);
|
||||||
if (diff_might_be_rename())
|
if (diff_might_be_rename())
|
||||||
|
@ -822,8 +822,8 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
|
|||||||
* we merged _in_.
|
* we merged _in_.
|
||||||
*/
|
*/
|
||||||
parse_commit_or_die(parents->item);
|
parse_commit_or_die(parents->item);
|
||||||
diff_tree_sha1(parents->item->tree->object.oid.hash,
|
diff_tree_oid(&parents->item->tree->object.oid,
|
||||||
oid->hash, "", &opt->diffopt);
|
oid, "", &opt->diffopt);
|
||||||
log_tree_diff_flush(opt);
|
log_tree_diff_flush(opt);
|
||||||
return !opt->loginfo;
|
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;
|
struct commit *parent = parents->item;
|
||||||
|
|
||||||
parse_commit_or_die(parent);
|
parse_commit_or_die(parent);
|
||||||
diff_tree_sha1(parent->tree->object.oid.hash,
|
diff_tree_oid(&parent->tree->object.oid,
|
||||||
oid->hash, "", &opt->diffopt);
|
oid, "", &opt->diffopt);
|
||||||
log_tree_diff_flush(opt);
|
log_tree_diff_flush(opt);
|
||||||
|
|
||||||
showed_log |= !opt->loginfo;
|
showed_log |= !opt->loginfo;
|
||||||
|
@ -528,7 +528,7 @@ static struct string_list *get_renames(struct merge_options *o,
|
|||||||
opts.show_rename_progress = o->show_rename_progress;
|
opts.show_rename_progress = o->show_rename_progress;
|
||||||
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
diff_setup_done(&opts);
|
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);
|
diffcore_std(&opts);
|
||||||
if (opts.needed_rename_limit > o->needed_rename_limit)
|
if (opts.needed_rename_limit > o->needed_rename_limit)
|
||||||
o->needed_rename_limit = opts.needed_rename_limit;
|
o->needed_rename_limit = opts.needed_rename_limit;
|
||||||
|
@ -129,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
|
|||||||
DIFF_OPT_SET(&opt, RECURSIVE);
|
DIFF_OPT_SET(&opt, RECURSIVE);
|
||||||
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
|
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
diff_setup_done(&opt);
|
diff_setup_done(&opt);
|
||||||
diff_tree_sha1(base->hash, remote->hash, "", &opt);
|
diff_tree_oid(base, remote, "", &opt);
|
||||||
diffcore_std(&opt);
|
diffcore_std(&opt);
|
||||||
|
|
||||||
changes = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));
|
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);
|
DIFF_OPT_SET(&opt, RECURSIVE);
|
||||||
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
|
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
diff_setup_done(&opt);
|
diff_setup_done(&opt);
|
||||||
diff_tree_sha1(base->hash, local->hash, "", &opt);
|
diff_tree_oid(base, local, "", &opt);
|
||||||
diffcore_std(&opt);
|
diffcore_std(&opt);
|
||||||
|
|
||||||
for (i = 0; i < diff_queued_diff.nr; i++) {
|
for (i = 0; i < diff_queued_diff.nr; i++) {
|
||||||
|
@ -17,8 +17,8 @@ int commit_patch_id(struct commit *commit, struct diff_options *options,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (commit->parents)
|
if (commit->parents)
|
||||||
diff_tree_sha1(commit->parents->item->object.oid.hash,
|
diff_tree_oid(&commit->parents->item->object.oid,
|
||||||
commit->object.oid.hash, "", options);
|
&commit->object.oid, "", options);
|
||||||
else
|
else
|
||||||
diff_root_tree_oid(&commit->object.oid, "", options);
|
diff_root_tree_oid(&commit->object.oid, "", options);
|
||||||
diffcore_std(options);
|
diffcore_std(options);
|
||||||
|
@ -455,7 +455,7 @@ static int rev_compare_tree(struct rev_info *revs,
|
|||||||
|
|
||||||
tree_difference = REV_TREE_SAME;
|
tree_difference = REV_TREE_SAME;
|
||||||
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
|
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)
|
&revs->pruning) < 0)
|
||||||
return REV_TREE_DIFFERENT;
|
return REV_TREE_DIFFERENT;
|
||||||
return tree_difference;
|
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;
|
tree_difference = REV_TREE_SAME;
|
||||||
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
|
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);
|
return retval >= 0 && (tree_difference == REV_TREE_SAME);
|
||||||
}
|
}
|
||||||
|
@ -2129,8 +2129,8 @@ cleanup_head_ref:
|
|||||||
if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
|
if (read_oneliner(&buf, rebase_path_orig_head(), 0) &&
|
||||||
!get_sha1(buf.buf, orig.hash) &&
|
!get_sha1(buf.buf, orig.hash) &&
|
||||||
!get_sha1("HEAD", head.hash)) {
|
!get_sha1("HEAD", head.hash)) {
|
||||||
diff_tree_sha1(orig.hash, head.hash,
|
diff_tree_oid(&orig, &head, "",
|
||||||
"", &log_tree_opt.diffopt);
|
&log_tree_opt.diffopt);
|
||||||
log_tree_diff_flush(&log_tree_opt);
|
log_tree_diff_flush(&log_tree_opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
tree-diff.c
12
tree-diff.c
@ -419,7 +419,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
|
|||||||
* load parents first, as they are probably already cached.
|
* load parents first, as they are probably already cached.
|
||||||
*
|
*
|
||||||
* ( log_tree_diff() parses commit->parent before calling here via
|
* ( 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)
|
for (i = 0; i < nparent; ++i)
|
||||||
tptree[i] = fill_tree_descriptor(&tp[i], parents_sha1[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;
|
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;
|
struct strbuf base;
|
||||||
int retval;
|
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_init(&base, PATH_MAX);
|
||||||
strbuf_addstr(&base, base_str);
|
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())
|
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);
|
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)
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user