Skip to content

Commit e97f90b

Browse files
committed
add permutation tests and make them pass
1 parent 8e643e9 commit e97f90b

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

gix-revision/src/merge_base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ pub(crate) mod function {
7575

7676
let mut walk_start = Vec::with_capacity(commits.len());
7777
for (id, _) in commits {
78-
graph.insert(*id, Flags::RESULT);
7978
graph.insert_parents_with_lookup(id, &mut |parent_id, parent_data, maybe_flags| -> Result<_, Error> {
80-
if maybe_flags.is_none() {
79+
if maybe_flags.map_or(true, |flags| !flags.contains(Flags::STALE)) {
8180
walk_start.push((parent_id, GenThenTime::try_from(parent_data)?));
8281
}
8382
Ok(Flags::empty())
8483
})?;
84+
graph.insert(*id, Flags::RESULT);
8585
}
8686
walk_start.sort_by(|a, b| a.0.cmp(&b.0));
8787
let mut count_still_independent = commits.len();
Binary file not shown.

gix-revision/tests/fixtures/make_merge_base_repos.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,15 @@ H=$(mkcommit 8 H $A $F)
6565
baseline G H
6666
} > 2_a.baseline
6767

68+
commits=$(git log --all --format=%s)
69+
commit_array=($commits)
70+
num_commits=${#commit_array[@]}
71+
72+
for ((i=0; i<num_commits; i++)); do
73+
for ((j=0; j<num_commits; j++)); do
74+
baseline ${commit_array[$i]} ${commit_array[$j]}
75+
done
76+
done > 3_permutations.baseline
77+
6878
git commit-graph write --no-progress --reachable
6979
git repack -adq

0 commit comments

Comments
 (0)