Commit 3556af4 1 parent b14ac1e commit 3556af4 Copy full SHA for 3556af4
File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ pub mod checkout {
8
8
pub struct Options {
9
9
/// capabilities of the file system
10
10
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 ,
11
14
}
12
15
13
16
quick_error ! {
@@ -42,6 +45,9 @@ pub fn checkout<Find>(
42
45
where
43
46
Find : for < ' a > FnMut ( & oid , & ' a mut Vec < u8 > ) -> Option < git_object:: BlobRef < ' a > > ,
44
47
{
48
+ if !options. destination_is_initially_empty {
49
+ todo ! ( "non-clone logic isn't implemented or vetted yet" ) ;
50
+ }
45
51
let root = path. as_ref ( ) ;
46
52
let mut buf = Vec :: new ( ) ;
47
53
for ( entry, entry_path) in index. entries_mut_with_paths ( ) {
@@ -76,6 +82,7 @@ pub(crate) mod entry {
76
82
root : & std:: path:: Path ,
77
83
index:: checkout:: Options {
78
84
fs : crate :: fs:: Context { symlink, .. } ,
85
+ ..
79
86
} : index:: checkout:: Options ,
80
87
buf : & mut Vec < u8 > ,
81
88
) -> Result < ( ) , index:: checkout:: Error >
Original file line number Diff line number Diff line change @@ -9,32 +9,33 @@ mod checkout {
9
9
use git_object:: bstr:: ByteSlice ;
10
10
use git_odb:: FindExt ;
11
11
use git_worktree:: index;
12
+ use git_worktree:: index:: checkout:: Options ;
12
13
use tempfile:: TempDir ;
13
14
14
15
use crate :: fixture_path;
15
16
16
17
#[ test]
17
18
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 ) ;
24
20
let ( source_tree, destination) = setup_fixture_with_options ( opts, "make_mixed_without_submodules" ) ?;
25
21
26
22
assert_equality ( & source_tree, & destination, opts. fs . symlink ) ?;
27
23
Ok ( ( ) )
28
24
}
29
25
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 {
33
28
fs : git_worktree:: fs:: Context {
34
- symlink : false ,
29
+ symlink,
35
30
..Default :: default ( )
36
31
} ,
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 ) ;
38
39
let ( source_tree, destination) = setup_fixture_with_options ( opts, "make_mixed_without_submodules" ) ?;
39
40
40
41
assert_equality ( & source_tree, & destination, opts. fs . symlink ) ?;
You can’t perform that action at this time.
0 commit comments