| 842 | } |
| 843 | |
| 844 | fn collect_tree_entries( |
| 845 | repository: &GitRepository, |
| 846 | tree: &git2::Tree<'_>, |
| 847 | prefix: &[u8], |
| 848 | entries: &mut Vec<TreeEntryObservation>, |
| 849 | ) -> Result<(), ObservationError> { |
| 850 | for entry in tree.iter() { |
| 851 | let mut path = prefix.to_vec(); |
| 852 | if !path.is_empty() { |
| 853 | path.push(b'/'); |
| 854 | } |
| 855 | path.extend_from_slice(entry.name_bytes()); |
| 856 | |
| 857 | if entry.kind() == Some(ObjectType::Tree) { |
| 858 | let child = repository.find_tree(entry.id()).map_err(|error| { |
| 859 | ObservationError::new(format!( |
| 860 | "cannot read Git tree {} while observing '{}': {error}", |
| 861 | entry.id(), |
| 862 | display_git_bytes(&path) |
| 863 | )) |
| 864 | })?; |
| 865 | collect_tree_entries(repository, &child, &path, entries)?; |
| 866 | } else { |
| 867 | entries.push(TreeEntryObservation { |
| 868 | path, |
| 869 | oid: entry.id(), |
| 870 | mode: entry.filemode() as u32, |
| 871 | }); |
| 872 | } |
| 873 | } |
| 874 | Ok(()) |
| 875 | } |
| 876 | |
| 877 | fn observe_index( |
| 878 | repository: &GitRepository, |