commit 58e5f354035040c9e6fd3d29cfda7bbe9a700a2e from: Stefan Sperling date: Mon Jun 11 20:19:29 2018 UTC tweak add_node_to_iter_list for clarity; no functional change commit - 191379307b0c8d7c44e8b958cce3288b86b54d7e commit + 58e5f354035040c9e6fd3d29cfda7bbe9a700a2e blob - 9f0c3c9a7ab7018ee59cef631cc0d19eeb453e01 blob + 2fca28a4074d95d8a0dc869fc4217dca43892bb4 --- lib/commit_graph.c +++ lib/commit_graph.c @@ -152,17 +152,10 @@ add_node_to_iter_list(struct got_commit_graph *graph, return; } - /* - * If a child node is known, begin looping over the list there - * instead of beginning from the list head. Parent commits are - * traversed before their children. - */ - n = child_node ? child_node : TAILQ_FIRST(&graph->iter_list); - /* Ensure that an iteration in progress will see this new commit. */ if (graph->iter_node) { n = graph->iter_node; - do { + while (n) { next = TAILQ_NEXT(n, entry); if (next && node->commit_timestamp >= next->commit_timestamp) { @@ -170,13 +163,19 @@ add_node_to_iter_list(struct got_commit_graph *graph, return; } n = next; - } while (next); - + } TAILQ_INSERT_AFTER(&graph->iter_list, graph->iter_node, node, entry); return; } + /* + * If a child node is known, begin looping over the list there + * instead of beginning from the list head. Parent commits are + * traversed before their children. + */ + n = child_node ? child_node : TAILQ_FIRST(&graph->iter_list); + /* Insert into list based on committer timestamp. */ do { if (node->commit_timestamp == n->commit_timestamp) {