Skip to content

Commit ff14145

Browse files
christian-schillingLMG
authored andcommitted
Walk simplified history if :linear is used
Without .simplify_first_parent() all commits would be filtered even if they are only reachable via second parents. Change-Id: simplify-first-parent
1 parent 5b44b90 commit ff14145

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/filter/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,3 +840,11 @@ mod tests {
840840
);
841841
}
842842
}
843+
844+
pub fn is_linear(filter: Filter) -> bool {
845+
return match to_op(filter) {
846+
Op::Linear => true,
847+
Op::Chain(a, b) => is_linear(a) || is_linear(b),
848+
_ => false,
849+
};
850+
}

src/history.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ pub fn walk2(
1919

2020
let walk = {
2121
let mut walk = transaction.repo().revwalk()?;
22+
if filter::is_linear(filter) {
23+
walk.simplify_first_parent()?;
24+
}
2225
walk.set_sorting(git2::Sort::REVERSE | git2::Sort::TOPOLOGICAL)?;
2326
walk.push(input)?;
2427
for k in known.iter() {

0 commit comments

Comments
 (0)