Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-05-23 08:38:13 +0300
committerJunio C Hamano <gitster@pobox.com>2018-05-23 08:38:13 +0300
commitc89b6e136e421f1e9108b3c5bc050b19b0243844 (patch)
tree8d81e022f855aad5d29853b56b886d3c6b382c45 /commit-graph.c
parent05682ee270199fdfbc11883458b3639b2b1577df (diff)
parent279ffad17dcc3b72aa7cb5c73fb7aa8eddeed9da (diff)
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
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 3fc1e0da27..3a183abd1f 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -250,7 +250,6 @@ static struct commit_list **insert_parent_or_die(struct commit_graph *g,
static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uint32_t pos)
{
- struct object_id oid;
uint32_t edge_value;
uint32_t *parent_data_ptr;
uint64_t date_low, date_high;
@@ -260,8 +259,7 @@ static int fill_commit_in_graph(struct commit *item, struct commit_graph *g, uin
item->object.parsed = 1;
item->graph_pos = pos;
- hashcpy(oid.hash, commit_data);
- item->tree = lookup_tree(&oid);
+ item->maybe_tree = NULL;
date_high = get_be32(commit_data + g->hash_len + 8) & 0x3;
date_low = get_be32(commit_data + g->hash_len + 12);
@@ -320,6 +318,28 @@ int parse_commit_in_graph(struct commit *item)
return 0;
}
+static struct tree *load_tree_for_commit(struct commit_graph *g, struct commit *c)
+{
+ struct object_id oid;
+ const unsigned char *commit_data = g->chunk_commit_data +
+ GRAPH_DATA_WIDTH * (c->graph_pos);
+
+ hashcpy(oid.hash, commit_data);
+ c->maybe_tree = lookup_tree(&oid);
+
+ return c->maybe_tree;
+}
+
+struct tree *get_commit_tree_in_graph(const struct commit *c)
+{
+ if (c->maybe_tree)
+ return c->maybe_tree;
+ if (c->graph_pos == COMMIT_NOT_FROM_GRAPH)
+ BUG("get_commit_tree_in_graph called from non-commit-graph commit");
+
+ return load_tree_for_commit(commit_graph, (struct commit *)c);
+}
+
static void write_graph_chunk_fanout(struct hashfile *f,
struct commit **commits,
int nr_commits)
@@ -372,7 +392,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
uint32_t packedDate[2];
parse_commit(*list);
- hashwrite(f, (*list)->tree->object.oid.hash, hash_len);
+ hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
parent = (*list)->parents;