@@ -42,6 +42,11 @@ fn driver_exe() -> String {
42
42
exe
43
43
}
44
44
45
+ fn assure_is_empty ( dir : impl AsRef < Path > ) -> std:: io:: Result < ( ) > {
46
+ assert_eq ! ( std:: fs:: read_dir( dir) ?. count( ) , 0 ) ;
47
+ Ok ( ( ) )
48
+ }
49
+
45
50
#[ test]
46
51
fn submodules_are_instantiated_as_directories ( ) -> crate :: Result {
47
52
let mut opts = opts_from_probe ( ) ;
@@ -57,11 +62,6 @@ fn submodules_are_instantiated_as_directories() -> crate::Result {
57
62
Ok ( ( ) )
58
63
}
59
64
60
- fn assure_is_empty ( dir : impl AsRef < Path > ) -> std:: io:: Result < ( ) > {
61
- assert_eq ! ( std:: fs:: read_dir( dir) ?. count( ) , 0 ) ;
62
- Ok ( ( ) )
63
- }
64
-
65
65
#[ test]
66
66
fn accidental_writes_through_symlinks_are_prevented_if_overwriting_is_forbidden ( ) {
67
67
let mut opts = opts_from_probe ( ) ;
@@ -257,6 +257,25 @@ fn symlinks_become_files_if_disabled() -> crate::Result {
257
257
Ok ( ( ) )
258
258
}
259
259
260
+ #[ test]
261
+ fn dangling_symlinks_can_be_created ( ) -> crate :: Result {
262
+ let opts = opts_from_probe ( ) ;
263
+ if !opts. fs . symlink {
264
+ eprintln ! ( "Skipping dangling symlink test on filesystem that doesn't support it" ) ;
265
+ return Ok ( ( ) ) ;
266
+ }
267
+
268
+ let ( _source_tree, destination, _index, outcome) =
269
+ checkout_index_in_tmp_dir ( opts. clone ( ) , "make_dangling_symlink" ) ?;
270
+ let worktree_files = dir_structure ( & destination) ;
271
+ let worktree_files_stripped = stripped_prefix ( & destination, & worktree_files) ;
272
+
273
+ assert_eq ! ( worktree_files_stripped, paths( [ "dangling" ] ) ) ;
274
+ assert ! ( worktree_files[ 0 ] . symlink_metadata( ) ?. is_symlink( ) ) ;
275
+ assert ! ( outcome. collisions. is_empty( ) ) ;
276
+ Ok ( ( ) )
277
+ }
278
+
260
279
#[ test]
261
280
fn allow_or_disallow_symlinks ( ) -> crate :: Result {
262
281
let mut opts = opts_from_probe ( ) ;
0 commit comments