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])
| 2281 | /// the marker-bearing file — as the same blob anywhere in the tree. A tree |
| 2282 | /// or gitlink entry at `path` is not a blob and does not count. |
| 2283 | fn tree_holds_bytes(git: &GitRepository, tree: &git2::Tree<'_>, path: &str, bytes: &[u8]) -> bool { |
| 2284 | let Ok(blob_oid) = git2::Oid::hash_object(git2::ObjectType::Blob, bytes) else { |
| 2285 | return false; |
| 2286 | }; |
| 2287 | let at_path = tree.get_path(Path::new(path)).ok().is_some_and(|entry| { |
| 2288 | entry.kind() == Some(git2::ObjectType::Blob) && entry.id() == blob_oid |
| 2289 | }); |
| 2290 | if at_path { |
| 2291 | return true; |
| 2292 | } |
| 2293 | let mut found = false; |
| 2294 | let _ = tree.walk(git2::TreeWalkMode::PreOrder, |_, entry| { |
| 2295 | if entry.kind() == Some(git2::ObjectType::Blob) && entry.id() == blob_oid { |
| 2296 | found = true; |
| 2297 | return git2::TreeWalkResult::Abort; |
| 2298 | } |
| 2299 | git2::TreeWalkResult::Ok |
| 2300 | }); |
| 2301 | found |
| 2302 | } |
| 2303 | |
| 2304 | fn write_project_tree(git: &GitRepository, project: &ProjectTree) -> CliResult<git2::Oid> { |
| 2305 | if project.git.algorithm != GitHashAlgorithm::Sha1 { |