8000 make clear that we are currently only dealing with checkout during cl… · GitoxideLabs/gitoxide@3556af4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3556af4

Browse files
committed
make clear that we are currently only dealing with checkout during clone (#301)
1 parent b14ac1e commit 3556af4

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

git-worktree/src/index.rs

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ pub mod checkout {
88
pub struct Options {
99
/// capabilities of the file system
1010
pub fs: crate::fs::Context,
11+
/// If true, we assume no file to exist in the target directory, and want exclusive access to it.
12+
/// This should be enabled when cloning.
13+
pub destination_is_initially_empty: bool,
1114
}
1215

1316
quick_error! {
@@ -42,6 +45,9 @@ pub fn checkout<Find>(
4245
where
4346
Find: for<'a> FnMut(&oid, &'a mut Vec<u8>) -> Option<git_object::BlobRef<'a>>,
4447
{
48+
if !options.destination_is_initially_empty {
49+
todo!("non-clone logic isn't implemented or vetted yet");
50+
}
4551
let root = path.as_ref();
4652
let mut buf = Vec::new();
4753
for (entry, entry_path) in index.entries_mut_with_paths() {
@@ -76,6 +82,7 @@ pub(crate) mod entry {
7682
root: &std::path::Path,
7783
index::checkout::Options {
7884
fs: crate::fs::Context { symlink, .. },
85+
..
7986
}: index::checkout::Options,
8087
buf: &mut Vec<u8>,
8188
) -> Result<(), index::checkout::Error>

git-worktree/tests/index/mod.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,33 @@ mod checkout {
99
use git_object::bstr::ByteSlice;
1010
use git_odb::FindExt;
1111
use git_worktree::index;
12+
use git_worktree::index::checkout::Options;
1213
use tempfile::TempDir;
1314

1415
use crate::fixture_path;
1516

1617
#[test]
1718
fn allow_symlinks() -> crate::Result {
18-
let opts = index::checkout::Options {
19-
fs: git_worktree::fs::Context {
20-
symlink: true,
21-
..Default::default()
22-
},
23-
};
19+
let opts = opts_with_symlink(true);
2420
let (source_tree, destination) = setup_fixture_with_options(opts, "make_mixed_without_submodules")?;
2521

2622
assert_equality(&source_tree, &destination, opts.fs.symlink)?;
2723
Ok(())
2824
}
2925

30-
#[test]
31-
fn symlinks_become_files_if_disabled() -> crate::Result {
32-
let opts = index::checkout::Options {
26+
fn opts_with_symlink(symlink: bool) -> Options {
27+
index::checkout::Options {
3328
fs: git_worktree::fs::Context {
34-
symlink: false,
29+
symlink,
3530
..Default::default()
3631
},
37-
};
32+
destination_is_initially_empty: true,
33+
}
34+
}
35+
36+
#[test]
37+
fn symlinks_become_files_if_disabled() -> crate::Result {
38+
let opts = opts_with_symlink(false);
3839
let (source_tree, destination) = setup_fixture_with_options(opts, "make_mixed_without_submodules")?;
3940

4041
assert_equality(&source_tree, &destination, opts.fs.symlink)?;

0 commit comments

Comments
 (0)
0