commit-graph: parse commit from chosen graph
Before verifying a commit-graph file against the object database, we need to parse all commits from the given commit-graph file. Create parse_commit_in_graph_one() to target a given struct commit_graph. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jun 27, 2018 at 09:24 UTC
ee79705311c190e61ac35d67705d387fdeae8c21
1 file changed
+15
-3
commit-graph.c
+15
-3
@@ -314,7 +314,7 @@ static int find_commit_in_graph(struct commit *item, struct commit_graph *g, uin
314
}
315
}
316
317
-int parse_commit_in_graph(struct commit *item)
317
+static int parse_commit_in_graph_one(struct commit_graph *g, struct commit *item)
318
{
319
uint32_t pos;
320
@@ -322,9 +322,21 @@ int parse_commit_in_graph(struct commit *item)
322
return 0;
323
if (item->object.parsed)
324
return 1;
325
+
326
+ if (find_commit_in_graph(item, g, &pos))
327
+ return fill_commit_in_graph(item, g, pos);
328
+
329
+ return 0;
330
+}
331
+
332
+int parse_commit_in_graph(struct commit *item)
333
+{
334
+ if (!core_commit_graph)
335
+ return 0;
336
+
337
prepare_commit_graph();
326
- if (commit_graph && find_commit_in_graph(item, commit_graph, &pos))
327
- return fill_commit_in_graph(item, commit_graph, pos);
338
+ if (commit_graph)
339
+ return parse_commit_in_graph_one(commit_graph, item);
340
return 0;
341
}
342