The path where a commit puts a directory in place of a file, or a file in place of a directory, if it does. Git records that as removed paths plus added paths, one of which is a parent directory of the other. Atomic does not record the swap as one change: the turn would record the removals and lose the additions.
(changed: &[CommitPath])
| 998 | /// parent directory of the other. Atomic does not record the swap as one |
| 999 | /// change: the turn would record the removals and lose the additions. |
| 1000 | fn file_directory_swap(changed: &[CommitPath]) -> Option<&str> { |
| 1001 | use std::collections::BTreeSet; |
| 1002 | |
| 1003 | let paths_absent_on = |side: fn(&CommitPath) -> &str| -> BTreeSet<&str> { |
| 1004 | changed |
| 1005 | .iter() |
| 1006 | .filter(|entry| side(entry) == GIT_ABSENT_MODE) |
| 1007 | .map(|entry| entry.path.as_str()) |
| 1008 | .collect() |
| 1009 | }; |
| 1010 | let removed = paths_absent_on(|entry| &entry.new_mode); |
| 1011 | let added = paths_absent_on(|entry| &entry.old_mode); |
| 1012 | parent_directory_among(&added, &removed).or_else(|| parent_directory_among(&removed, &added)) |
| 1013 | } |
| 1014 | |
| 1015 | /// The first parent directory of a path in `paths` that is itself a path in |
| 1016 | /// `others`. |
no test coverage detected