commit-reach: move compare_commits_by_gen
Move this earlier in the file so it can be used by more methods. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Feb 19, 2021 at 12:34 UTC
c8d693e1e6d3bd883224559cf4c1b07d9d58e0cf
1 file changed
+15
-15
commit-reach.c
+15
-15
@@ -17,6 +17,21 @@
17
18
static const unsigned all_flags = (PARENT1 | PARENT2 | STALE | RESULT);
19
20
+static int compare_commits_by_gen(const void *_a, const void *_b)
21
+{
22
+ const struct commit *a = *(const struct commit * const *)_a;
23
+ const struct commit *b = *(const struct commit * const *)_b;
24
+
25
+ timestamp_t generation_a = commit_graph_generation(a);
26
+ timestamp_t generation_b = commit_graph_generation(b);
27
+
28
+ if (generation_a < generation_b)
29
+ return -1;
30
+ if (generation_a > generation_b)
31
+ return 1;
32
+ return 0;
33
+}
34
+
35
static int queue_has_nonstale(struct prio_queue *queue)
36
{
37
int i;
@@ -647,21 +662,6 @@ int commit_contains(struct ref_filter *filter, struct commit *commit,
662
return repo_is_descendant_of(the_repository, commit, list);
663
}
664
650
-static int compare_commits_by_gen(const void *_a, const void *_b)
651
-{
652
- const struct commit *a = *(const struct commit * const *)_a;
653
- const struct commit *b = *(const struct commit * const *)_b;
654
-
655
- timestamp_t generation_a = commit_graph_generation(a);
656
- timestamp_t generation_b = commit_graph_generation(b);
657
-
658
- if (generation_a < generation_b)
659
- return -1;
660
- if (generation_a > generation_b)
661
- return 1;
662
- return 0;
663
-}
664
-
665
int can_all_from_reach_with_flag(struct object_array *from,
666
unsigned int with_flag,
667
unsigned int assign_flag,