Skip to content

Commit 952c577

Browse files
committed
Sort parents by index
1 parent 90c2bb8 commit 952c577

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/it/src/commands/blame_copy_royal.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,24 @@ git commit -m {commit_id}
274274
// In almost all cases, `children` will only have one element. The exception are merge
275275
// commits where there’s changes against each parent. Each of these changes would
276276
// produce a diff that’s represented in `self.blame_path`.
277-
let children = self
277+
let mut children: Vec<_> = self
278278
.blame_path
279279
.iter()
280280
.enumerate()
281-
.filter(|(_, x)| x.commit_id == child.commit_id);
281+
.filter(|(_, x)| x.commit_id == child.commit_id)
282+
.collect();
283+
284+
children.sort_by_key(|(_, x)| x.index);
282285

283286
let parents = children
287+
.iter()
284288
.filter_map(|(index, child)| {
285289
let parent_blob_id = child.previous_blob_id;
286290
let parent_source_file_path = &child.previous_source_file_path;
287291

288292
// When we search for a parent we only have to consider entries up to and
289293
// excluding `index` as anything after `index` can only be a child.
290-
self.blame_path[..index]
294+
self.blame_path[..(*index)]
291295
.iter()
292296
.rfind(|&x| {
293297
x.blob_id == parent_blob_id && Some(&x.source_file_path) == parent_source_file_path.as_ref()

0 commit comments

Comments
 (0)