commit - 63da309a4f2c5978e3fe9ec99266313333116218
commit + 1bf85b22df5bb9019f291c010d72dcf37ad2e774
blob - f6669fd0b9bea0a21d77886b9e2933fc07952a79
blob + df87bed092f0a22f4787ade94b10bdac94c80123
--- lib/commit_graph.c
+++ lib/commit_graph.c
static const struct got_error *
add_node(struct got_commit_graph_node **new_node, int *changed,
- struct got_commit_graph *graph, struct got_object_id *commit_id,
- struct got_commit_object *commit, struct got_commit_graph_node *child_node,
- struct got_repository *repo)
+ int *branch_done, struct got_commit_graph *graph,
+ struct got_object_id *commit_id, struct got_commit_object *commit,
+ struct got_commit_graph_node *child_node, struct got_repository *repo)
{
const struct got_error *err = NULL;
struct got_commit_graph_node *node;
struct got_object_qid *pid;
- int branch_done = 0;
*new_node = NULL;
*changed = 0;
+ *branch_done = 0;
node = calloc(1, sizeof(*node));
if (node == NULL)
* branch. Keep going on other branches.
*/
err = NULL;
- branch_done = 1;
+ *branch_done = 1;
} else {
free_node(node);
return err;
if (*changed)
add_node_to_iter_list(graph, node, child_node);
- if (branch_done)
- err = close_branch(graph, commit_id);
- else
- err = advance_branch(graph, node, commit_id, commit, repo);
if (err)
free_node(node);
else
{
const struct got_error *err = NULL;
struct got_commit_object *commit;
- int changed;
+ int changed, branch_done;
*graph = NULL;
if (first_parent_traversal)
(*graph)->flags |= GOT_COMMIT_GRAPH_FIRST_PARENT_TRAVERSAL;
- err = add_node(&(*graph)->head_node, &changed, *graph, commit_id,
- commit, NULL, repo);
+ err = add_node(&(*graph)->head_node, &changed, &branch_done, *graph,
+ commit_id, commit, NULL, repo);
+ if (err == NULL) {
+ err = advance_branch(*graph, (*graph)->head_node, commit_id,
+ commit, repo);
+ }
got_object_commit_close(commit);
if (err) {
got_commit_graph_close(*graph);
struct got_object_id *commit_id;
struct got_commit_graph_node *child_node, *new_node;
struct got_commit_object *commit;
- int changed;
+ int changed, branch_done;
commit_id = &graph->tips[i].id;
child_node = graph->tips[i].node;
if (err)
break;
- err = add_node(&new_node, &changed, graph, commit_id, commit,
- child_node, repo);
+ err = add_node(&new_node, &changed, &branch_done, graph,
+ commit_id, commit, child_node, repo);
+ if (branch_done)
+ err = close_branch(graph, commit_id);
+ else
+ err = advance_branch(graph, new_node, commit_id,
+ commit, repo);
if (changed && *changed_id == NULL)
*changed_id = commit_id;
got_object_commit_close(commit);