Skip to content

Commit c8d693e

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fbc21e3 commit c8d693e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

commit-reach.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717

1818
static const unsigned all_flags = (PARENT1 | PARENT2 | STALE | RESULT);
1919

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+
2035
static int queue_has_nonstale(struct prio_queue *queue)
2136
{
2237
int i;
@@ -647,21 +662,6 @@ int commit_contains(struct ref_filter *filter, struct commit *commit,
647662
return repo_is_descendant_of(the_repository, commit, list);
648663
}
649664

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-
665665
int can_all_from_reach_with_flag(struct object_array *from,
666666
unsigned int with_flag,
667667
unsigned int assign_flag,

0 commit comments

Comments
 (0)