diff --git a/gix-worktree-state/tests/fixtures/make_dir_symlink.sh b/gix-worktree-state/tests/fixtures/make_dir_symlink.sh new file mode 100755 index 00000000000..e0acd233ab3 --- /dev/null +++ b/gix-worktree-state/tests/fixtures/make_dir_symlink.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eu -o pipefail + +git init -q + +target_oid=$(echo -n "." | git hash-object -w --stdin) + +git update-index --index-info < crate::Result { Ok(()) } +#[test] +fn symlinks_to_directories_are_usable() -> crate::Result { + let opts = opts_from_probe(); + if !opts.fs.symlink { + eprintln!("Skipping directory symlink test on filesystem that doesn't support it"); + return Ok(()); + } + + let (_source_tree, destination, _index, outcome) = + checkout_index_in_tmp_dir(opts.clone(), "make_dir_symlink", None)?; + let worktree_files = dir_structure(&destination); + let worktree_files_stripped = stripped_prefix(&destination, &worktree_files); + + assert_eq!(worktree_files_stripped, paths(["symlink"])); + let symlink_path = &worktree_files[0]; + assert!(symlink_path + .symlink_metadata() + .expect("symlink is on disk") + .is_symlink()); + assert!(symlink_path + .metadata() + .expect("metadata accessible through symlink") + .is_dir()); + assert_eq!(std::fs::read_link(symlink_path)?, Path::new(".")); + assert!(outcome.collisions.is_empty()); + Ok(()) +} + #[test] fn dangling_symlinks_can_be_created() -> crate::Result { let opts = opts_from_probe();