Adapt log example to use OldestFirst sorting for -r/--reverse option #1669
Answered
by
Byron
jakewilliami
asked this question in
Q&A
-
How can I adapt the log example to reverse the order of the I tried this: // ...
use gix::{
// ...
traverse::commit::simple::CommitTimeOrder,
};
// ...
let sorting = if args.breadth_first {
Sorting::BreadthFirst
} else {
Sorting::ByCommitTime(if !args.reverse {
CommitTimeOrder::NewestFirst
} else {
CommitTimeOrder::OldestFirst
})
};
// ... Rather than doing it in a vector: if args.reverse {
let mut results: Vec<_> = log_iter.collect();
results.reverse();
log_iter = Box::new(results.into_iter());
} But this produces incorrect results. |
Beta Was this translation helpful? Give feedback.
Answered by
Byron
Nov 12, 2024
Replies: 1 comment
-
There is no way to reverse the order of commits shown other than collecting them first.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Byron
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is no way to reverse the order of commits shown other than collecting them first.
CommitTimeOrder::OldestFirst
has a different effect as it sorts only the commits at each 'junction' of the graph, which can be used to reach the beginning of the graph much faster. But that's already it.