@@ -112,6 +112,21 @@ uint32_t commit_graph_generation(const struct commit *c)
return data->generation;
}
+int compare_commits_by_gen(const void *_a, const void *_b)
+{
+ const struct commit *a = _a, *b = _b;
+ const uint32_t generation_a = commit_graph_generation(a);
+ const uint32_t generation_b = commit_graph_generation(b);
+
+ /* older commits first */
+ if (generation_a < generation_b)
+ return -1;
+ else if (generation_a > generation_b)
+ return 1;
+
+ return 0;
+}
+
static struct commit_graph_data *commit_graph_data_at(const struct commit *c)
{
unsigned int i, nth_slab;
@@ -146,4 +146,6 @@ struct commit_graph_data {
*/
uint32_t commit_graph_generation(const struct commit *);
uint32_t commit_graph_position(const struct commit *);
+
+int compare_commits_by_gen(const void *_a, const void *_b);
#endif
@@ -561,21 +561,6 @@ int commit_contains(struct ref_filter *filter, struct commit *commit,
return repo_is_descendant_of(the_repository, commit, list);
}
-static int compare_commits_by_gen(const void *_a, const void *_b)
-{
- const struct commit *a = *(const struct commit * const *)_a;
- const struct commit *b = *(const struct commit * const *)_b;
-
- uint32_t generation_a = commit_graph_generation(a);
- uint32_t generation_b = commit_graph_generation(b);
-
- if (generation_a < generation_b)
- return -1;
- if (generation_a > generation_b)
- return 1;
- return 0;
-}
-
int can_all_from_reach_with_flag(struct object_array *from,
unsigned int with_flag,
unsigned int assign_flag,
@@ -731,14 +731,11 @@ int compare_commits_by_author_date(const void *a_, const void *b_,
int compare_commits_by_gen_then_commit_date(const void *a_, const void *b_, void *unused)
{
const struct commit *a = a_, *b = b_;
- const uint32_t generation_a = commit_graph_generation(a),
- generation_b = commit_graph_generation(b);
+ int ret_val = compare_commits_by_gen(a_, b_);
/* newer commits first */
- if (generation_a < generation_b)
- return 1;
- else if (generation_a > generation_b)
- return -1;
+ if (ret_val)
+ return -ret_val;
/* use date as a heuristic when generations are equal */
if (a->date < b->date)