Enum gix_traverse::commit::Sorting
source · pub enum Sorting {
BreadthFirst,
ByCommitTimeNewestFirst,
ByCommitTimeNewestFirstCutoffOlderThan {
seconds: SecondsSinceUnixEpoch,
},
}
Expand description
Specify how to sort commits during traversal.
Sample History
The following history will be referred to for explaining how the sort order works, with the number denoting the commit timestamp (their X-alignment doesn’t matter).
---1----2----4----7 <- second parent of 8
\ \
3----5----6----8---
Variants§
BreadthFirst
Commits are sorted as they are mentioned in the commit graph.
In the sample history the order would be 8, 6, 7, 5, 4, 3, 2, 1
Note
This is not to be confused with git log/rev-list --topo-order
, which is notably different from
as it avoids overlapping branches.
ByCommitTimeNewestFirst
Commits are sorted by their commit time in descending order, that is newest first.
The sorting applies to all currently queued commit ids and thus is full.
In the sample history the order would be 8, 7, 6, 5, 4, 3, 2, 1
Performance
This mode benefits greatly from having an object_cache in find()
to avoid having to lookup each commit twice.
ByCommitTimeNewestFirstCutoffOlderThan
Fields
seconds: SecondsSinceUnixEpoch
The amount of seconds since unix epoch, the same value obtained by any gix_date::Time
structure and the way git counts time.
This sorting is similar to ByCommitTimeNewestFirst
, but adds a cutoff to not return commits older than
a given time, stopping the iteration once no younger commits is queued to be traversed.
As the query is usually repeated with different cutoff dates, this search mode benefits greatly from an object cache.
In the sample history and a cut-off date of 4, the returned list of commits would be 8, 7, 6, 4