diff --git a/gix-archive/tests/archive.rs b/gix-archive/tests/archive.rs index 1a0b1cf895a..9ffc9bf60ad 100644 --- a/gix-archive/tests/archive.rs +++ b/gix-archive/tests/archive.rs @@ -27,12 +27,6 @@ mod from_tree { entry.read_to_end(&mut buf).expect("stream can always be read"); } - let expected_link_mode = EntryKind::Link; - let expected_exe_mode = if cfg!(windows) { - EntryKind::Blob - } else { - EntryKind::BlobExecutable - }; assert_eq!( paths_and_modes, &[ @@ -48,7 +42,7 @@ mod from_tree { ), ( "symlink-to-a".into(), - expected_link_mode, + EntryKind::Link, hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e") ), ( @@ -58,7 +52,7 @@ mod from_tree { ), ( "dir/subdir/exe".into(), - expected_exe_mode, + EntryKind::BlobExecutable, hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") ), ( @@ -68,7 +62,11 @@ mod from_tree { ), ( "extra-exe".into(), - expected_exe_mode, + if cfg!(windows) { + EntryKind::Blob + } else { + EntryKind::BlobExecutable + }, hex_to_id("0000000000000000000000000000000000000000") ), ( @@ -78,7 +76,7 @@ mod from_tree { ), ( "extra-dir/symlink-to-extra".into(), - expected_link_mode, + EntryKind::Link, hex_to_id("0000000000000000000000000000000000000000") ) ] @@ -111,20 +109,23 @@ mod from_tree { header.mode()?, )); } - let expected_symlink_type = EntryType::Symlink; - let expected_exe_mode = if cfg!(windows) { 420 } else { 493 }; assert_eq!( out, [ ("prefix/.gitattributes", EntryType::Regular, 56, 420), ("prefix/a", EntryType::Regular, 3, 420), - ("prefix/symlink-to-a", expected_symlink_type, 0, 420), + ("prefix/symlink-to-a", EntryType::Symlink, 0, 420), ("prefix/dir/b", EntryType::Regular, 3, 420), - ("prefix/dir/subdir/exe", EntryType::Regular, 0, expected_exe_mode), + ("prefix/dir/subdir/exe", EntryType::Regular, 0, 493), ("prefix/extra-file", EntryType::Regular, 21, 420), - ("prefix/extra-exe", EntryType::Regular, 0, expected_exe_mode), + ( + "prefix/extra-exe", + EntryType::Regular, + 0, + if cfg!(windows) { 420 } else { 493 } + ), ("prefix/extra-dir-empty", EntryType::Directory, 0, 420), - ("prefix/extra-dir/symlink-to-extra", expected_symlink_type, 0, 420) + ("prefix/extra-dir/symlink-to-extra", EntryType::Symlink, 0, 420) ] .into_iter() .map(|(path, b, c, d)| (bstr::BStr::new(path).to_owned(), b, c, d)) diff --git a/gix-archive/tests/fixtures/basic.sh b/gix-archive/tests/fixtures/basic.sh index 5cd4c2e859c..f8a8c8bea3e 100755 --- a/gix-archive/tests/fixtures/basic.sh +++ b/gix-archive/tests/fixtures/basic.sh @@ -20,6 +20,7 @@ echo "/dir-ignored/ export-ignore" > .gitattributes echo "/file-ignored export-ignore" >> .gitattributes git add . +git update-index --chmod=+x dir/subdir/exe # For Windows. git commit -m "init" echo "extra to be streamed" > extra-file @@ -28,4 +29,3 @@ mkdir extra-dir-empty extra-dir ln -s ../extra-file extra-dir/symlink-to-extra git rev-parse @^{tree} > head.hex - diff --git a/gix-dir/tests/fixtures/many-symlinks.sh b/gix-dir/tests/fixtures/many-symlinks.sh index fdebe1021a7..8d3d60e4865 100755 --- a/gix-dir/tests/fixtures/many-symlinks.sh +++ b/gix-dir/tests/fixtures/many-symlinks.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail -# Note that symlink creation fails on Windows for some reason, -# so these tests shouldn't be run there. +# These fixtures use symlinks. See `many.sh` for some that don't. git init breakout-symlink (cd breakout-symlink @@ -20,7 +19,7 @@ git init immediate-breakout-symlink git init excluded-symlinks-to-dir (cd excluded-symlinks-to-dir - cat <.gitignore + cat <<'EOF' >.gitignore src1 src2/ file1 @@ -42,4 +41,4 @@ EOF ln -s src/file file2 ) -ln -s excluded-symlinks-to-dir worktree-root-is-symlink \ No newline at end of file +ln -s excluded-symlinks-to-dir worktree-root-is-symlink diff --git a/gix-dir/tests/fixtures/many.sh b/gix-dir/tests/fixtures/many.sh index 54ec1cf8dac..268932ff3cc 100755 --- a/gix-dir/tests/fixtures/many.sh +++ b/gix-dir/tests/fixtures/many.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail -# Nothing here may use symlinks so these fixtures can be used on windows as well. +# These fixtures don't use symlinks. See `many-symlinks.sh` for some that do. git init with-nested-dot-git (cd with-nested-dot-git diff --git a/gix-dir/tests/walk/mod.rs b/gix-dir/tests/walk/mod.rs index 057271e0968..e4d08f7b0cf 100644 --- a/gix-dir/tests/walk/mod.rs +++ b/gix-dir/tests/walk/mod.rs @@ -19,7 +19,6 @@ use gix_dir::walk::ForDeletionMode; use gix_ignore::Kind::*; #[test] -#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] fn symlink_to_dir_can_be_excluded() -> crate::Result { let root = fixture_in("many-symlinks", "excluded-symlinks-to-dir"); let ((out, _root), entries) = collect(&root, None, |keep, ctx| { @@ -94,7 +93,6 @@ fn symlink_to_dir_can_be_excluded() -> crate::Result { } #[test] -#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] fn root_may_not_lead_through_symlinks() -> crate::Result { for (name, intermediate, expected) in [ ("immediate-breakout-symlink", "", 0), @@ -121,7 +119,6 @@ fn root_may_not_lead_through_symlinks() -> crate::Result { } #[test] -#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] fn root_may_be_a_symlink_if_it_is_the_worktree() -> crate::Result { let root = fixture_in("many-symlinks", "worktree-root-is-symlink"); let ((_out, _root), entries) = collect(&root, None, |keep, ctx| { @@ -2702,7 +2699,6 @@ fn decomposed_unicode_in_directory_is_returned_precomposed() -> crate::Result { } #[test] -#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] fn worktree_root_can_be_symlink() -> crate::Result { let root = fixture_in("many-symlinks", "symlink-to-breakout-symlink"); let troot = root.join("file"); diff --git a/gix-index/tests/fixtures/generated-archives/v2_all_file_kinds.tar b/gix-index/tests/fixtures/generated-archives/v2_all_file_kinds.tar index ad35bdb4a35..01ceee8b2f6 100644 Binary files a/gix-index/tests/fixtures/generated-archives/v2_all_file_kinds.tar and b/gix-index/tests/fixtures/generated-archives/v2_all_file_kinds.tar differ diff --git a/gix-index/tests/fixtures/make_index/v2_all_file_kinds.sh b/gix-index/tests/fixtures/make_index/v2_all_file_kinds.sh index 0dae4a4027c..ebaab2d1e41 100755 --- a/gix-index/tests/fixtures/make_index/v2_all_file_kinds.sh +++ b/gix-index/tests/fixtures/make_index/v2_all_file_kinds.sh @@ -1,11 +1,10 @@ #!/usr/bin/env bash set -eu -o pipefail -export GIT_INDEX_VERSION=2; +export GIT_INDEX_VERSION=2 git init -q sub (cd sub - touch a b c git add . git commit -m "init" @@ -21,6 +20,7 @@ mkdir d (cd d && touch a b c) git add . +git update-index --chmod=+x b # For Windows. git commit -m "init" git rev-parse @^{tree} > head.tree diff --git a/gix-index/tests/fixtures/make_index/v2_deeper_tree.sh b/gix-index/tests/fixtures/make_index/v2_deeper_tree.sh index 09ba2a53464..a5734ad342d 100755 --- a/gix-index/tests/fixtures/make_index/v2_deeper_tree.sh +++ b/gix-index/tests/fixtures/make_index/v2_deeper_tree.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -o pipefail -export GIT_INDEX_VERSION=2; +export GIT_INDEX_VERSION=2 mkdir sub (cd sub @@ -25,4 +25,5 @@ mkdir d ) git add . +git update-index --chmod=+x b # For Windows. git commit -m "init" diff --git a/gix-merge/tests/fixtures/generated-archives/tree-baseline.tar b/gix-merge/tests/fixtures/generated-archives/tree-baseline.tar index 4b74b96874d..bd50e785648 100644 Binary files a/gix-merge/tests/fixtures/generated-archives/tree-baseline.tar and b/gix-merge/tests/fixtures/generated-archives/tree-baseline.tar differ diff --git a/gix-merge/tests/fixtures/tree-baseline.sh b/gix-merge/tests/fixtures/tree-baseline.sh index 928a52abea5..69b103ae986 100644 --- a/gix-merge/tests/fixtures/tree-baseline.sh +++ b/gix-merge/tests/fixtures/tree-baseline.sh @@ -475,8 +475,8 @@ git init same-rename-different-mode git checkout A write_lines 1 2 3 4 5 >a/x.f - chmod +x a/x.f - chmod +x a/w + chmod +x a/x.f a/w + git update-index --chmod=+x a/x.f a/w git mv a a-renamed git commit -am "changed all content, add +x, renamed a -> a-renamed" @@ -486,8 +486,8 @@ git init same-rename-different-mode git commit -am "changed all content, renamed a -> a-renamed" git checkout expected - chmod +x a/x.f - chmod +x a/w + chmod +x a/x.f a/w + git update-index --chmod=+x a/x.f a/w write_lines 1 2 3 4 5 6 >a/x.f git mv a a-renamed git commit -am "Git, when branches are reversed, doesn't keep the +x flag on a/w so we specify our own expectation" @@ -530,13 +530,13 @@ git init added-file-changed-content-and-mode git checkout B write_lines original 1 2 3 4 5 6 >new chmod +x new - git add . + git add --chmod=+x new git commit -m "add new with content B and +x" git checkout expected echo -n $'<<<<<<< A\n1\n2\n3\n4\n5\n=======\noriginal\n1\n2\n3\n4\n5\n6\n>>>>>>> B\n' >new chmod +x new - git add new + git add --chmod=+x new git commit -m "Git has a better merge here, but that's due to better hunk handling/hunk splitting. We, however, consistently use +x" ) diff --git a/gix-status/tests/fixtures/generated-archives/status_many.tar b/gix-status/tests/fixtures/generated-archives/status_many.tar index 91dd6a9110f..8e656859d8e 100644 Binary files a/gix-status/tests/fixtures/generated-archives/status_many.tar and b/gix-status/tests/fixtures/generated-archives/status_many.tar differ diff --git a/gix-status/tests/fixtures/generated-archives/status_removed.tar b/gix-status/tests/fixtures/generated-archives/status_removed.tar index 1828e56b980..ec26788a7dc 100644 Binary files a/gix-status/tests/fixtures/generated-archives/status_removed.tar and b/gix-status/tests/fixtures/generated-archives/status_removed.tar differ diff --git a/gix-status/tests/fixtures/status_changed.sh b/gix-status/tests/fixtures/status_changed.sh index 06ff09ebf3f..18be3d1d8ae 100755 --- a/gix-status/tests/fixtures/status_changed.sh +++ b/gix-status/tests/fixtures/status_changed.sh @@ -14,6 +14,7 @@ mkdir dir/sub-dir (cd dir/sub-dir && ln -sf ../content symlink) git add -A +git update-index --chmod=+x executable # For Windows. git commit -m "Commit" chmod +x dir/content @@ -23,4 +24,4 @@ echo -n "foo" > executable rm empty ln -sf dir/content empty -git reset \ No newline at end of file +git reset diff --git a/gix-status/tests/fixtures/status_many.sh b/gix-status/tests/fixtures/status_many.sh index a3d05017d3e..9a11f3f4f8d 100755 --- a/gix-status/tests/fixtures/status_many.sh +++ b/gix-status/tests/fixtures/status_many.sh @@ -12,6 +12,7 @@ git init -q changed-and-untracked echo "different content" > dir/content2 git add -A + git update-index --chmod=+x executable # For Windows. git commit -m "Commit" echo "change" >> executable diff --git a/gix-status/tests/fixtures/status_removed.sh b/gix-status/tests/fixtures/status_removed.sh index d6a06ec651b..c8249e10c89 100755 --- a/gix-status/tests/fixtures/status_removed.sh +++ b/gix-status/tests/fixtures/status_removed.sh @@ -13,6 +13,7 @@ mkdir dir/sub-dir (cd dir/sub-dir && ln -sf ../content symlink) git add -A +git update-index --chmod=+x executable # For Windows. git commit -m "Commit" rm -rf ./empty ./executable ./dir/content ./dir/sub-dir/symlink -git reset \ No newline at end of file +git reset diff --git a/gix-status/tests/fixtures/status_unchanged.sh b/gix-status/tests/fixtures/status_unchanged.sh index 14caa054cd9..a2beaa7e313 100755 --- a/gix-status/tests/fixtures/status_unchanged.sh +++ b/gix-status/tests/fixtures/status_unchanged.sh @@ -13,8 +13,9 @@ mkdir dir/sub-dir (cd dir/sub-dir && ln -sf ../content symlink) git add -A +git update-index --chmod=+x executable # For Windows. git commit -m "Commit" touch ./empty ./executable ./dir/content ./dir/sub-dir/symlink -git reset # ensure index timestamp is large enough to not mark everything racy \ No newline at end of file +git reset # ensure index timestamp is large enough to not mark everything racy diff --git a/gix-worktree-state/tests/fixtures/make_mixed.sh b/gix-worktree-state/tests/fixtures/make_mixed.sh index 8e23ccbfc30..47b112c07e4 100755 --- a/gix-worktree-state/tests/fixtures/make_mixed.sh +++ b/gix-worktree-state/tests/fixtures/make_mixed.sh @@ -17,6 +17,7 @@ mkdir dir/sub-dir (cd dir/sub-dir && ln -sf ../content symlink) git add -A +git update-index --chmod=+x executable # For Windows. git commit -m "Commit" git init module1 diff --git a/gix-worktree-state/tests/fixtures/make_mixed_without_submodules.sh b/gix-worktree-state/tests/fixtures/make_mixed_without_submodules.sh index 78d36a2f2d0..ace64b1cdde 100755 --- a/gix-worktree-state/tests/fixtures/make_mixed_without_submodules.sh +++ b/gix-worktree-state/tests/fixtures/make_mixed_without_submodules.sh @@ -17,4 +17,5 @@ mkdir dir/sub-dir (cd dir/sub-dir && ln -sf ../content symlink) git add -A +git update-index --chmod=+x executable # For Windows. git commit -m "Commit" diff --git a/gix-worktree-state/tests/fixtures/make_mixed_without_submodules_and_symlinks.sh b/gix-worktree-state/tests/fixtures/make_mixed_without_submodules_and_symlinks.sh index 77c3aea2362..cbaf0047d84 100755 --- a/gix-worktree-state/tests/fixtures/make_mixed_without_submodules_and_symlinks.sh +++ b/gix-worktree-state/tests/fixtures/make_mixed_without_submodules_and_symlinks.sh @@ -17,4 +17,5 @@ mkdir dir/sub-dir echo "even other content" > dir/sub-dir/file git add -A +git update-index --chmod=+x executable # For Windows. git commit -m "Commit" diff --git a/gix-worktree-state/tests/state/checkout.rs b/gix-worktree-state/tests/state/checkout.rs index 752277a48b7..c496d04688b 100644 --- a/gix-worktree-state/tests/state/checkout.rs +++ b/gix-worktree-state/tests/state/checkout.rs @@ -173,20 +173,13 @@ fn delayed_driver_process() -> crate::Result { } #[test] -#[cfg_attr( - windows, - ignore = "on windows, the symlink to a directory doesn't seem to work and we really want to test with symlinks" -)] fn overwriting_files_and_lone_directories_works() -> crate::Result { for delay in [ gix_filter::driver::apply::Delay::Allow, gix_filter::driver::apply::Delay::Forbid, ] { let mut opts = opts_from_probe(); - assert!( - opts.fs.symlink, - "BUG: the probe must detect to be able to generate symlinks" - ); + assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks"); opts.overwrite_existing = true; opts.filter_process_delay = delay; opts.destination_is_initially_empty = false; @@ -244,8 +237,7 @@ fn overwriting_files_and_lone_directories_works() -> crate::Result { ); let symlink = destination.path().join("dir/sub-dir/symlink"); - // on windows, git won't create symlinks as its probe won't detect the capability, even though we do. - assert_eq!(std::fs::symlink_metadata(&symlink)?.is_symlink(), cfg!(unix)); + assert!(std::fs::symlink_metadata(&symlink)?.is_symlink()); assert_eq!( std::fs::read(symlink)?.as_bstr(), "➡other content\r\n", @@ -270,10 +262,7 @@ fn symlinks_become_files_if_disabled() -> crate::Result { #[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(()); - } + assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks"); let (_source_tree, destination, _index, outcome) = checkout_index_in_tmp_dir(opts.clone(), "make_dir_symlink", None)?; @@ -298,10 +287,7 @@ fn symlinks_to_directories_are_usable() -> crate::Result { #[test] fn dangling_symlinks_can_be_created() -> crate::Result { let opts = opts_from_probe(); - if !opts.fs.symlink { - eprintln!("Skipping dangling symlink test on filesystem that doesn't support it"); - return Ok(()); - } + assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks"); for (fixture, symlink_name, target_name) in [ ("make_dangling_symlink", "dangling", "non-existing-target"), diff --git a/gix-worktree-stream/tests/fixtures/basic.sh b/gix-worktree-stream/tests/fixtures/basic.sh index 1a29eb68a8b..55015a7b2d8 100755 --- a/gix-worktree-stream/tests/fixtures/basic.sh +++ b/gix-worktree-stream/tests/fixtures/basic.sh @@ -23,6 +23,7 @@ echo "/file-ignored export-ignore" >> .gitattributes dd if=/dev/zero of=bigfile bs=1024 count=156 git add . +git update-index --chmod=+x dir/subdir/exe git commit -m "init" echo "extra" > extra-file @@ -32,4 +33,3 @@ ln -s ../extra-file extra-dir/symlink-to-extra dd if=/dev/zero of=extra-bigfile bs=1024 count=156 git rev-parse @^{tree} > head.hex - diff --git a/gix-worktree-stream/tests/stream.rs b/gix-worktree-stream/tests/stream.rs index a34e640a1a2..f66e24698f2 100644 --- a/gix-worktree-stream/tests/stream.rs +++ b/gix-worktree-stream/tests/stream.rs @@ -110,12 +110,6 @@ mod from_tree { } } - let expected_exe_mode = if cfg!(windows) { - EntryKind::Blob - } else { - EntryKind::BlobExecutable - }; - let expected_link_mode = EntryKind::Link; assert_eq!( paths_and_modes, &[ @@ -136,7 +130,7 @@ mod from_tree { ), ( "symlink-to-a".into(), - expected_link_mode, + EntryKind::Link, hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e") ), ( @@ -151,7 +145,7 @@ mod from_tree { ), ( "dir/subdir/exe".into(), - expected_exe_mode, + EntryKind::BlobExecutable, hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") ), ( @@ -171,7 +165,11 @@ mod from_tree { ), ( "extra-exe".into(), - expected_exe_mode, + if cfg!(windows) { + EntryKind::Blob + } else { + EntryKind::BlobExecutable + }, hex_to_id("0000000000000000000000000000000000000000") ), ( @@ -181,7 +179,7 @@ mod from_tree { ), ( "extra-dir/symlink-to-extra".into(), - expected_link_mode, + EntryKind::Link, hex_to_id("0000000000000000000000000000000000000000") ) ] diff --git a/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar b/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar index d6c7fa19114..538e9943fc5 100644 Binary files a/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar and b/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar differ diff --git a/gix/tests/fixtures/make_rev_spec_parse_repos.sh b/gix/tests/fixtures/make_rev_spec_parse_repos.sh index baa2d924df9..887f0f1d7ab 100755 --- a/gix/tests/fixtures/make_rev_spec_parse_repos.sh +++ b/gix/tests/fixtures/make_rev_spec_parse_repos.sh @@ -53,8 +53,8 @@ git init --bare blob.corrupt echo bnkxmdwz | git hash-object -w --stdin oid=$(echo bmwsjxzi | git hash-object -w --stdin) oidf=objects/$(oid_to_path "$oid") - chmod 755 $oidf - echo broken >$oidf + chmod -- 644 "$oidf" + echo broken >"$oidf" baseline "cafea" baseline "cafea^{object}" @@ -424,4 +424,4 @@ git init invalid-head rm .git/refs/heads/main baseline 'HEAD' baseline 'HEAD:file' -) \ No newline at end of file +)