Whether `tree` holds exactly `bytes`: at `path`, or — after a rename of the marker-bearing file — as the same blob anywhere in the tree. A tree or gitlink entry at `path` is not a blob and does not count.
(git: &GitRepository, tree: &git2::Tree<'_>, path: &str, bytes: &[u8])
| 2093 | /// the marker-bearing file — as the same blob anywhere in the tree. A tree |
| 2094 | /// or gitlink entry at `path` is not a blob and does not count. |
| 2095 | fn tree_holds_bytes(git: &GitRepository, tree: &git2::Tree<'_>, path: &str, bytes: &[u8]) -> bool { |
| 2096 | let Ok(blob_oid) = git2::Oid::hash_object(git2::ObjectType::Blob, bytes) else { |
| 2097 | return false; |
| 2098 | }; |
| 2099 | let at_path = tree.get_path(Path::new(path)).ok().is_some_and(|entry| { |
| 2100 | entry.kind() == Some(git2::ObjectType::Blob) && entry.id() == blob_oid |
| 2101 | }); |
| 2102 | if at_path { |
| 2103 | return true; |
| 2104 | } |
| 2105 | let mut found = false; |
| 2106 | let _ = tree.walk(git2::TreeWalkMode::PreOrder, |_, entry| { |
| 2107 | if entry.kind() == Some(git2::ObjectType::Blob) && entry.id() == blob_oid { |
| 2108 | found = true; |
| 2109 | return git2::TreeWalkResult::Abort; |
| 2110 | } |
| 2111 | git2::TreeWalkResult::Ok |
| 2112 | }); |
| 2113 | found |
| 2114 | } |
| 2115 | |
| 2116 | fn write_project_tree(git: &GitRepository, project: &ProjectTree) -> CliResult<git2::Oid> { |
| 2117 | if project.git.algorithm != GitHashAlgorithm::Sha1 { |