| 67 | } |
| 68 | |
| 69 | fn tree(repo: &Repository, view: &str) -> Result<Tree, RepositoryError> { |
| 70 | let mut files = Tree::new(); |
| 71 | let filter = GitAttributesFilter::for_repository(repo.root()); |
| 72 | repo.materialize_view_entries::<RepositoryError>(view, |entry| { |
| 73 | if entry.conflict_marker_line.is_some() { |
| 74 | return Err(invalid(format!( |
| 75 | "cannot revise unresolved conflict at '{}'", |
| 76 | entry.path |
| 77 | ))); |
| 78 | } |
| 79 | let file = File { |
| 80 | path: entry.path.clone(), |
| 81 | kind: entry.kind, |
| 82 | mode: entry.mode, |
| 83 | bytes: if entry.kind == ViewEntryKind::File { |
| 84 | filter |
| 85 | .clean(Path::new(&entry.path), &entry.content) |
| 86 | .map_err(|e| invalid(e.to_string()))? |
| 87 | .bytes |
| 88 | } else { |
| 89 | entry.content |
| 90 | }, |
| 91 | }; |
| 92 | if files.insert(entry.inode, file).is_some() { |
| 93 | return Err(invalid( |
| 94 | "cannot revise unresolved concurrent names for one inode", |
| 95 | )); |
| 96 | } |
| 97 | Ok(()) |
| 98 | })??; |
| 99 | Ok(files) |
| 100 | } |
| 101 | |
| 102 | fn paths(tree: &Tree) -> BTreeMap<&str, &File> { |
| 103 | tree.values() |