Skip to content

Commit

Permalink
Fix dir-diff paths merging to not add duplicated entries from remainder
Browse files Browse the repository at this point in the history
If lhs_paths and rhs_paths are ["a", "c"] and ["a", "b", "c"] respectively, the
loop ends with paths = ["a", "c", "b"], i = j = 2. We still need to deduplicate
"c" from the rhs_paths.

.into_iter() can't be used anymore since the seen set still borrows the paths.
  • Loading branch information
yuja committed Jan 2, 2024
1 parent db0c150 commit 19e21cd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,18 @@ pub(crate) fn relative_paths_in_either(lhs_dir: &Path, rhs_dir: &Path) -> Vec<Pa
}
}

paths.extend(lhs_paths.into_iter().skip(i));
paths.extend(rhs_paths.into_iter().skip(j));
paths.extend(
lhs_paths[i..]
.iter()
.filter(|&path| !seen.contains(path))
.cloned(),
);
paths.extend(
rhs_paths[j..]
.iter()
.filter(|&path| !seen.contains(path))
.cloned(),
);

paths
}
Expand Down

0 comments on commit 19e21cd

Please sign in to comment.