|
1 | 1 | use super::*; |
2 | | -use std::path::PathBuf; |
3 | 2 |
|
4 | 3 | use crate::cache::TransactionContext; |
5 | 4 | use crate::cache_stack::CacheStack; |
@@ -890,7 +889,7 @@ pub fn repopulated_tree( |
890 | 889 | populate(transaction, ipaths.id(), partial_tree.id()) |
891 | 890 | } |
892 | 891 |
|
893 | | -fn populate( |
| 892 | +pub fn populate( |
894 | 893 | transaction: &cache::Transaction, |
895 | 894 | paths: git2::Oid, |
896 | 895 | content: git2::Oid, |
@@ -1002,41 +1001,6 @@ pub fn get_blob(repo: &git2::Repository, tree: &git2::Tree, path: &Path) -> Stri |
1002 | 1001 | content.to_owned() |
1003 | 1002 | } |
1004 | 1003 |
|
1005 | | -/// Compose a new tree by taking paths out of `paths`, |
1006 | | -/// and actual blobs out of `blobs`. |
1007 | | -pub fn transpose<'a>( |
1008 | | - transaction: &'a cache::Transaction, |
1009 | | - paths: &'a git2::Tree, |
1010 | | - blobs: &'a git2::Tree, |
1011 | | -) -> JoshResult<git2::Tree<'a>> { |
1012 | | - use git2::build::TreeUpdateBuilder; |
1013 | | - use git2::{TreeWalkMode, TreeWalkResult}; |
1014 | | - |
1015 | | - let mut builder = TreeUpdateBuilder::new(); |
1016 | | - |
1017 | | - paths.walk(TreeWalkMode::PostOrder, |path, entry| { |
1018 | | - let path = PathBuf::from(path).join(entry.name().unwrap_or("")); |
1019 | | - |
1020 | | - let entry = match blobs.get_path(&path) { |
1021 | | - Ok(entry) => entry, |
1022 | | - Err(e) if e.code() == git2::ErrorCode::NotFound => return TreeWalkResult::Ok, |
1023 | | - Err(_) => return TreeWalkResult::Abort, |
1024 | | - }; |
1025 | | - |
1026 | | - if entry.kind() != Some(git2::ObjectType::Blob) { |
1027 | | - return TreeWalkResult::Ok; |
1028 | | - } |
1029 | | - |
1030 | | - builder.upsert(path, entry.id(), git2::FileMode::Blob); |
1031 | | - TreeWalkResult::Ok |
1032 | | - })?; |
1033 | | - |
1034 | | - let repo = transaction.repo(); |
1035 | | - let tree = builder.create_updated(repo, &empty(repo))?; |
1036 | | - |
1037 | | - Ok(repo.find_tree(tree)?) |
1038 | | -} |
1039 | | - |
1040 | 1004 | pub fn empty_id() -> git2::Oid { |
1041 | 1005 | git2::Oid::from_str("4b825dc642cb6eb9a060e54bf8d69288fbee4904").unwrap() |
1042 | 1006 | } |
|
0 commit comments