Merge branch 'ds/lazy-load-trees'

The code has been taught to use the duplicated information stored
in the commit-graph file to learn the tree object name for a commit
to avoid opening and parsing the commit object when it makes sense
to do so.

* ds/lazy-load-trees:
  coccinelle: avoid wrong transformation suggestions from commit.cocci
  commit-graph: lazy-load trees for commits
  treewide: replace maybe_tree with accessor methods
  commit: create get_commit_tree() method
  treewide: rename tree to maybe_tree
This commit is contained in:
Junio C Hamano
2018-05-23 14:38:13 +09:00
26 changed files with 152 additions and 66 deletions

View File

@ -484,7 +484,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
resolve_undo_clear();
if (opts->force) {
ret = reset_tree(new_branch_info->commit->tree, opts, 1, writeout_error);
ret = reset_tree(get_commit_tree(new_branch_info->commit),
opts, 1, writeout_error);
if (ret)
return ret;
} else {
@ -570,18 +571,23 @@ static int merge_working_tree(const struct checkout_opts *opts,
o.verbosity = 0;
work = write_tree_from_memory(&o);
ret = reset_tree(new_branch_info->commit->tree, opts, 1,
ret = reset_tree(get_commit_tree(new_branch_info->commit),
opts, 1,
writeout_error);
if (ret)
return ret;
o.ancestor = old_branch_info->name;
o.branch1 = new_branch_info->name;
o.branch2 = "local";
ret = merge_trees(&o, new_branch_info->commit->tree, work,
old_branch_info->commit->tree, &result);
ret = merge_trees(&o,
get_commit_tree(new_branch_info->commit),
work,
get_commit_tree(old_branch_info->commit),
&result);
if (ret < 0)
exit(128);
ret = reset_tree(new_branch_info->commit->tree, opts, 0,
ret = reset_tree(get_commit_tree(new_branch_info->commit),
opts, 0,
writeout_error);
strbuf_release(&o.obuf);
if (ret)
@ -1002,7 +1008,7 @@ static int parse_branchname_arg(int argc, const char **argv,
*source_tree = parse_tree_indirect(rev);
} else {
parse_commit_or_die(new_branch_info->commit);
*source_tree = new_branch_info->commit->tree;
*source_tree = get_commit_tree(new_branch_info->commit);
}
if (!*source_tree) /* case (1): want a tree */