MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / observe_head_tree

Function observe_head_tree

atomic-cli/src/commands/git/observation.rs:817–835  ·  view source on GitHub ↗
(
    repository: &GitRepository,
    head: &HeadObservation,
)

Source from the content-addressed store, hash-verified

815}
816
817fn observe_head_tree(
818 repository: &GitRepository,
819 head: &HeadObservation,
820) -> Result<(Option<Oid>, Vec<TreeEntryObservation>), ObservationError> {
821 let Some(oid) = head.oid() else {
822 return Ok((None, Vec::new()));
823 };
824 let commit = repository.find_commit(oid).map_err(|error| {
825 ObservationError::new(format!("cannot read Git HEAD commit {oid}: {error}"))
826 })?;
827 let tree = commit.tree().map_err(|error| {
828 ObservationError::new(format!("cannot read Git HEAD tree for {oid}: {error}"))
829 })?;
830 let tree_oid = tree.id();
831 let mut entries = Vec::new();
832 collect_tree_entries(repository, &tree, &[], &mut entries)?;
833 entries.sort_by(|left, right| left.path.cmp(&right.path));
834 Ok((Some(tree_oid), entries))
835}
836
837#[derive(Clone, Debug, Eq, PartialEq)]
838struct TreeEntryObservation {

Callers 1

observe_open_repositoryFunction · 0.85

Calls 5

treeMethod · 0.80
collect_tree_entriesFunction · 0.70
oidMethod · 0.45
idMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected