From: Junio C Hamano Date: Wed, 23 May 2018 05:38:13 +0000 (+0900) Subject: Merge branch 'ds/lazy-load-trees' X-Git-Tag: v2.18.0-rc0~62 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c89b6e136e421f1e9108b3c5bc050b19b0243844;p=thirdparty%2Fgit.git 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 --- c89b6e136e421f1e9108b3c5bc050b19b0243844 diff --cc pretty.c index 34fe891fc0,15997f5e01..703fa6ff7b --- a/pretty.c +++ b/pretty.c @@@ -1161,10 -1161,11 +1161,11 @@@ static size_t format_commit_one(struct strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_RESET)); return 1; case 'T': /* tree hash */ - strbuf_addstr(sb, oid_to_hex(&commit->tree->object.oid)); + strbuf_addstr(sb, oid_to_hex(get_commit_tree_oid(commit))); return 1; case 't': /* abbreviated tree hash */ - strbuf_add_unique_abbrev(sb, &commit->tree->object.oid, + strbuf_add_unique_abbrev(sb, - get_commit_tree_oid(commit)->hash, ++ get_commit_tree_oid(commit), c->pretty_ctx->abbrev); return 1; case 'P': /* parent hashes */ diff --cc walker.c index 8eb7db7a52,f51b855872..0b162a09b9 --- a/walker.c +++ b/walker.c @@@ -88,14 -86,19 +88,14 @@@ static int process_commit(struct walke walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid)); - if (process(walker, &commit->tree->object)) - if (walker->get_tree) { - if (process(walker, &get_commit_tree(commit)->object)) ++ if (process(walker, &get_commit_tree(commit)->object)) + return -1; + + for (parents = commit->parents; parents; parents = parents->next) { + if (process(walker, &parents->item->object)) return -1; - if (!walker->get_all) - walker->get_tree = 0; - } - if (walker->get_history) { - struct commit_list *parents = commit->parents; - for (; parents; parents = parents->next) { - if (process(walker, &parents->item->object)) - return -1; - } } + return 0; }