Skip to content

Commit

Permalink
prepare checkout, but needs to be able to create an index from a tree (
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 14, 2022
1 parent 458e1bc commit e462bd5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
25 changes: 24 additions & 1 deletion git-repository/src/clone/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,30 @@ pub mod main_worktree {
let _workdir = repo.work_dir().ok_or_else(|| Error::BareRepository {
git_dir: repo.git_dir().to_owned(),
})?;

let _index_path = repo.index_path();
// git_worktree::index::checkout(
// &mut index,
// workdir,
// {
// let objects = repo.objects.into_arc()?;
// move |oid, buf| {
// objects.find_blob(oid, buf).ok();
// if empty_files {
// // We always want to query the ODB here…
// objects.find_blob(oid, buf)?;
// buf.clear();
// // …but write nothing
// Ok(git::objs::BlobRef { data: buf })
// } else {
// objects.find_blob(oid, buf)
// }
// }
// },
// &mut files,
// &mut bytes,
// should_interrupt,
// opts,
// );
todo!("which branch to use?")
}
}
Expand Down
11 changes: 10 additions & 1 deletion git-repository/tests/clone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ fn fetch_and_checkout() -> crate::Result {
let mut prepare = git::prepare_clone_bare(remote::repo("base").path(), tmp.path())?;
let (mut checkout, _out) =
prepare.fetch_then_checkout(git::progress::Discard, &std::sync::atomic::AtomicBool::default())?;
checkout.main_worktree(git::progress::Discard, &std::sync::atomic::AtomicBool::default())?;
let repo = checkout.main_worktree(git::progress::Discard, &std::sync::atomic::AtomicBool::default())?;

let index = repo.index()?;
assert_eq!(index.entries().len(), 42, "All entries are known as per HEAD tree");

let work_dir = repo.work_dir().expect("non-bare");
for entry in index.entries() {
let entry_path = work_dir.join(git_path::from_bstr(entry.path(&index)));
assert!(entry_path.is_file(), "{:?} not found on disk", entry_path)
}
Ok(())
}

Expand Down

0 comments on commit e462bd5

Please sign in to comment.