Test cross-platform symlink and +x permission expectations on Windows
Unified · Split
| @@ -27,12 +27,6 @@ mod from_tree { · 26 unmodified lines | |||
| 27 | entry.read_to_end(&mut buf).expect("stream can always be read"); | 27 | entry.read_to_end(&mut buf).expect("stream can always be read"); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | let expected_link_mode = EntryKind::Link; | ||
| 31 | let expected_exe_mode = if cfg!(windows) { | ||
| 32 | EntryKind::Blob | ||
| 33 | } else { | ||
| 34 | EntryKind::BlobExecutable | ||
| 35 | }; | ||
| 36 | assert_eq!( | 30 | assert_eq!( |
| 37 | paths_and_modes, | 31 | paths_and_modes, |
| 38 | &[ | 32 | &[ |
| @@ -48,7 +42,7 @@ mod from_tree { · 9 unmodified lines | |||
| 48 | ), | 42 | ), |
| 49 | ( | 43 | ( |
| 50 | "symlink-to-a".into(), | 44 | "symlink-to-a".into(), |
| 51 | expected_link_mode, | 45 | EntryKind::Link, |
| 52 | hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e") | 46 | hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e") |
| 53 | ), | 47 | ), |
| 54 | ( | 48 | ( |
| @@ -58,7 +52,7 @@ mod from_tree { · 3 unmodified lines | |||
| 58 | ), | 52 | ), |
| 59 | ( | 53 | ( |
| 60 | "dir/subdir/exe".into(), | 54 | "dir/subdir/exe".into(), |
| 61 | expected_exe_mode, | 55 | EntryKind::BlobExecutable, |
| 62 | hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") | 56 | hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") |
| 63 | ), | 57 | ), |
| 64 | ( | 58 | ( |
| @@ -68,7 +62,11 @@ mod from_tree { · 3 unmodified lines | |||
| 68 | ), | 62 | ), |
| 69 | ( | 63 | ( |
| 70 | "extra-exe".into(), | 64 | "extra-exe".into(), |
| 71 | expected_exe_mode, | 65 | if cfg!(windows) { |
| 66 | EntryKind::Blob | ||
| 67 | } else { | ||
| 68 | EntryKind::BlobExecutable | ||
| 69 | }, | ||
| 72 | hex_to_id("0000000000000000000000000000000000000000") | 70 | hex_to_id("0000000000000000000000000000000000000000") |
| 73 | ), | 71 | ), |
| 74 | ( | 72 | ( |
| @@ -78,7 +76,7 @@ mod from_tree { · 3 unmodified lines | |||
| 78 | ), | 76 | ), |
| 79 | ( | 77 | ( |
| 80 | "extra-dir/symlink-to-extra".into(), | 78 | "extra-dir/symlink-to-extra".into(), |
| 81 | expected_link_mode, | 79 | EntryKind::Link, |
| 82 | hex_to_id("0000000000000000000000000000000000000000") | 80 | hex_to_id("0000000000000000000000000000000000000000") |
| 83 | ) | 81 | ) |
| 84 | ] | 82 | ] |
| @@ -111,20 +109,23 @@ mod from_tree { · 26 unmodified lines | |||
| 111 | header.mode()?, | 109 | header.mode()?, |
| 112 | )); | 110 | )); |
| 113 | } | 111 | } |
| 114 | let expected_symlink_type = EntryType::Symlink; | ||
| 115 | let expected_exe_mode = if cfg!(windows) { 420 } else { 493 }; | ||
| 116 | assert_eq!( | 112 | assert_eq!( |
| 117 | out, | 113 | out, |
| 118 | [ | 114 | [ |
| 119 | ("prefix/.gitattributes", EntryType::Regular, 56, 420), | 115 | ("prefix/.gitattributes", EntryType::Regular, 56, 420), |
| 120 | ("prefix/a", EntryType::Regular, 3, 420), | 116 | ("prefix/a", EntryType::Regular, 3, 420), |
| 121 | ("prefix/symlink-to-a", expected_symlink_type, 0, 420), | 117 | ("prefix/symlink-to-a", EntryType::Symlink, 0, 420), |
| 122 | ("prefix/dir/b", EntryType::Regular, 3, 420), | 118 | ("prefix/dir/b", EntryType::Regular, 3, 420), |
| 123 | ("prefix/dir/subdir/exe", EntryType::Regular, 0, expected_exe_mode), | 119 | ("prefix/dir/subdir/exe", EntryType::Regular, 0, 493), |
| 124 | ("prefix/extra-file", EntryType::Regular, 21, 420), | 120 | ("prefix/extra-file", EntryType::Regular, 21, 420), |
| 125 | ("prefix/extra-exe", EntryType::Regular, 0, expected_exe_mode), | 121 | ( |
| 122 | "prefix/extra-exe", | ||
| 123 | EntryType::Regular, | ||
| 124 | 0, | ||
| 125 | if cfg!(windows) { 420 } else { 493 } | ||
| 126 | ), | ||
| 126 | ("prefix/extra-dir-empty", EntryType::Directory, 0, 420), | 127 | ("prefix/extra-dir-empty", EntryType::Directory, 0, 420), |
| 127 | ("prefix/extra-dir/symlink-to-extra", expected_symlink_type, 0, 420) | 128 | ("prefix/extra-dir/symlink-to-extra", EntryType::Symlink, 0, 420) |
| 128 | ] | 129 | ] |
| 129 | .into_iter() | 130 | .into_iter() |
| 130 | .map(|(path, b, c, d)| (bstr::BStr::new(path).to_owned(), b, c, d)) | 131 | .map(|(path, b, c, d)| (bstr::BStr::new(path).to_owned(), b, c, d)) |
| @@ -20,6 +20,7 @@ echo "/dir-ignored/ export-ignore" > .gitattributes · 19 unmodified lines | |||
| 20 | echo "/file-ignored export-ignore" >> .gitattributes | 20 | echo "/file-ignored export-ignore" >> .gitattributes |
| 21 | 21 | ||
| 22 | git add . | 22 | git add . |
| 23 | git update-index --chmod=+x dir/subdir/exe # For Windows. | ||
| 23 | git commit -m "init" | 24 | git commit -m "init" |
| 24 | 25 | ||
| 25 | echo "extra to be streamed" > extra-file | 26 | echo "extra to be streamed" > extra-file |
| @@ -28,4 +29,3 @@ mkdir extra-dir-empty extra-dir · 2 unmodified lines | |||
| 28 | ln -s ../extra-file extra-dir/symlink-to-extra | 29 | ln -s ../extra-file extra-dir/symlink-to-extra |
| 29 | 30 | ||
| 30 | git rev-parse @^{tree} > head.hex | 31 | git rev-parse @^{tree} > head.hex |
| 31 | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | set -eu -o pipefail | 2 | set -eu -o pipefail |
| 3 | 3 | ||
| 4 | # Note that symlink creation fails on Windows for some reason, | 4 | # These fixtures use symlinks. See `many.sh` for some that don't. |
| 5 | # so these tests shouldn't be run there. | ||
| 6 | 5 | ||
| 7 | git init breakout-symlink | 6 | git init breakout-symlink |
| 8 | (cd breakout-symlink | 7 | (cd breakout-symlink |
| @@ -20,7 +19,7 @@ git init immediate-breakout-symlink · 11 unmodified lines | |||
| 20 | 19 | ||
| 21 | git init excluded-symlinks-to-dir | 20 | git init excluded-symlinks-to-dir |
| 22 | (cd excluded-symlinks-to-dir | 21 | (cd excluded-symlinks-to-dir |
| 23 | cat <<EOF >.gitignore | 22 | cat <<'EOF' >.gitignore |
| 24 | src1 | 23 | src1 |
| 25 | src2/ | 24 | src2/ |
| 26 | file1 | 25 | file1 |
| @@ -42,4 +41,4 @@ EOF · 15 unmodified lines | |||
| 42 | ln -s src/file file2 | 41 | ln -s src/file file2 |
| 43 | ) | 42 | ) |
| 44 | 43 | ||
| 45 | ln -s excluded-symlinks-to-dir worktree-root-is-symlink | 44 | ln -s excluded-symlinks-to-dir worktree-root-is-symlink |
| @@ -1,7 +1,7 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | set -eu -o pipefail | 2 | set -eu -o pipefail |
| 3 | 3 | ||
| 4 | # Nothing here may use symlinks so these fixtures can be used on windows as well. | 4 | # These fixtures don't use symlinks. See `many-symlinks.sh` for some that do. |
| 5 | 5 | ||
| 6 | git init with-nested-dot-git | 6 | git init with-nested-dot-git |
| 7 | (cd with-nested-dot-git | 7 | (cd with-nested-dot-git |
| @@ -19,7 +19,6 @@ use gix_dir::walk::ForDeletionMode; · 18 unmodified lines | |||
| 19 | use gix_ignore::Kind::*; | 19 | use gix_ignore::Kind::*; |
| 20 | 20 | ||
| 21 | #[test] | 21 | #[test] |
| 22 | #[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] | ||
| 23 | fn symlink_to_dir_can_be_excluded() -> crate::Result { | 22 | fn symlink_to_dir_can_be_excluded() -> crate::Result { |
| 24 | let root = fixture_in("many-symlinks", "excluded-symlinks-to-dir"); | 23 | let root = fixture_in("many-symlinks", "excluded-symlinks-to-dir"); |
| 25 | let ((out, _root), entries) = collect(&root, None, |keep, ctx| { | 24 | let ((out, _root), entries) = collect(&root, None, |keep, ctx| { |
| @@ -94,7 +93,6 @@ fn symlink_to_dir_can_be_excluded() -> crate::Result { · 68 unmodified lines | |||
| 94 | } | 93 | } |
| 95 | 94 | ||
| 96 | #[test] | 95 | #[test] |
| 97 | #[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] | ||
| 98 | fn root_may_not_lead_through_symlinks() -> crate::Result { | 96 | fn root_may_not_lead_through_symlinks() -> crate::Result { |
| 99 | for (name, intermediate, expected) in [ | 97 | for (name, intermediate, expected) in [ |
| 100 | ("immediate-breakout-symlink", "", 0), | 98 | ("immediate-breakout-symlink", "", 0), |
| @@ -121,7 +119,6 @@ fn root_may_not_lead_through_symlinks() -> crate::Result { · 20 unmodified lines | |||
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | #[test] | 121 | #[test] |
| 124 | #[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] | ||
| 125 | fn root_may_be_a_symlink_if_it_is_the_worktree() -> crate::Result { | 122 | fn root_may_be_a_symlink_if_it_is_the_worktree() -> crate::Result { |
| 126 | let root = fixture_in("many-symlinks", "worktree-root-is-symlink"); | 123 | let root = fixture_in("many-symlinks", "worktree-root-is-symlink"); |
| 127 | let ((_out, _root), entries) = collect(&root, None, |keep, ctx| { | 124 | let ((_out, _root), entries) = collect(&root, None, |keep, ctx| { |
| @@ -2702,7 +2699,6 @@ fn decomposed_unicode_in_directory_is_returned_precomposed() -> crate::Result { · 2574 unmodified lines | |||
| 2702 | } | 2699 | } |
| 2703 | 2700 | ||
| 2704 | #[test] | 2701 | #[test] |
| 2705 | #[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")] | ||
| 2706 | fn worktree_root_can_be_symlink() -> crate::Result { | 2702 | fn worktree_root_can_be_symlink() -> crate::Result { |
| 2707 | let root = fixture_in("many-symlinks", "symlink-to-breakout-symlink"); | 2703 | let root = fixture_in("many-symlinks", "symlink-to-breakout-symlink"); |
| 2708 | let troot = root.join("file"); | 2704 | let troot = root.join("file"); |
Binary file not shown.
| @@ -1,11 +1,10 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | set -eu -o pipefail | 2 | set -eu -o pipefail |
| 3 | 3 | ||
| 4 | export GIT_INDEX_VERSION=2; | 4 | export GIT_INDEX_VERSION=2 |
| 5 | 5 | ||
| 6 | git init -q sub | 6 | git init -q sub |
| 7 | (cd sub | 7 | (cd sub |
| 8 | |||
| 9 | touch a b c | 8 | touch a b c |
| 10 | git add . | 9 | git add . |
| 11 | git commit -m "init" | 10 | git commit -m "init" |
| @@ -21,6 +20,7 @@ mkdir d · 9 unmodified lines | |||
| 21 | (cd d && touch a b c) | 20 | (cd d && touch a b c) |
| 22 | 21 | ||
| 23 | git add . | 22 | git add . |
| 23 | git update-index --chmod=+x b # For Windows. | ||
| 24 | git commit -m "init" | 24 | git commit -m "init" |
| 25 | 25 | ||
| 26 | git rev-parse @^{tree} > head.tree | 26 | git rev-parse @^{tree} > head.tree |
| @@ -1,7 +1,7 @@ | |||
| 1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
| 2 | set -eu -o pipefail | 2 | set -eu -o pipefail |
| 3 | 3 | ||
| 4 | export GIT_INDEX_VERSION=2; | 4 | export GIT_INDEX_VERSION=2 |
| 5 | 5 | ||
| 6 | mkdir sub | 6 | mkdir sub |
| 7 | (cd sub | 7 | (cd sub |
| @@ -25,4 +25,5 @@ mkdir d · 17 unmodified lines | |||
| 25 | ) | 25 | ) |
| 26 | 26 | ||
| 27 | git add . | 27 | git add . |
| 28 | git update-index --chmod=+x b # For Windows. | ||
| 28 | git commit -m "init" | 29 | git commit -m "init" |
Binary file not shown.
| @@ -475,8 +475,8 @@ git init same-rename-different-mode · 474 unmodified lines | |||
| 475 | 475 | ||
| 476 | git checkout A | 476 | git checkout A |
| 477 | write_lines 1 2 3 4 5 >a/x.f | 477 | write_lines 1 2 3 4 5 >a/x.f |
| 478 | chmod +x a/x.f | 478 | chmod +x a/x.f a/w |
| 479 | chmod +x a/w | 479 | git update-index --chmod=+x a/x.f a/w |
| 480 | git mv a a-renamed | 480 | git mv a a-renamed |
| 481 | git commit -am "changed all content, add +x, renamed a -> a-renamed" | 481 | git commit -am "changed all content, add +x, renamed a -> a-renamed" |
| 482 | 482 | ||
| @@ -486,8 +486,8 @@ git init same-rename-different-mode · 3 unmodified lines | |||
| 486 | git commit -am "changed all content, renamed a -> a-renamed" | 486 | git commit -am "changed all content, renamed a -> a-renamed" |
| 487 | 487 | ||
| 488 | git checkout expected | 488 | git checkout expected |
| 489 | chmod +x a/x.f | 489 | chmod +x a/x.f a/w |
| 490 | chmod +x a/w | 490 | git update-index --chmod=+x a/x.f a/w |
| 491 | write_lines 1 2 3 4 5 6 >a/x.f | 491 | write_lines 1 2 3 4 5 6 >a/x.f |
| 492 | git mv a a-renamed | 492 | git mv a a-renamed |
| 493 | git commit -am "Git, when branches are reversed, doesn't keep the +x flag on a/w so we specify our own expectation" | 493 | 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 · 36 unmodified lines | |||
| 530 | git checkout B | 530 | git checkout B |
| 531 | write_lines original 1 2 3 4 5 6 >new | 531 | write_lines original 1 2 3 4 5 6 >new |
| 532 | chmod +x new | 532 | chmod +x new |
| 533 | git add . | 533 | git add --chmod=+x new |
| 534 | git commit -m "add new with content B and +x" | 534 | git commit -m "add new with content B and +x" |
| 535 | 535 | ||
| 536 | git checkout expected | 536 | git checkout expected |
| 537 | echo -n $'<<<<<<< A\n1\n2\n3\n4\n5\n=======\noriginal\n1\n2\n3\n4\n5\n6\n>>>>>>> B\n' >new | 537 | echo -n $'<<<<<<< A\n1\n2\n3\n4\n5\n=======\noriginal\n1\n2\n3\n4\n5\n6\n>>>>>>> B\n' >new |
| 538 | chmod +x new | 538 | chmod +x new |
| 539 | git add new | 539 | git add --chmod=+x new |
| 540 | git commit -m "Git has a better merge here, but that's due to better hunk handling/hunk splitting. We, however, consistently use +x" | 540 | git commit -m "Git has a better merge here, but that's due to better hunk handling/hunk splitting. We, however, consistently use +x" |
| 541 | ) | 541 | ) |
| 542 | 542 | ||
Binary file not shown.
Binary file not shown.
| @@ -14,6 +14,7 @@ mkdir dir/sub-dir · 13 unmodified lines | |||
| 14 | (cd dir/sub-dir && ln -sf ../content symlink) | 14 | (cd dir/sub-dir && ln -sf ../content symlink) |
| 15 | 15 | ||
| 16 | git add -A | 16 | git add -A |
| 17 | git update-index --chmod=+x executable # For Windows. | ||
| 17 | git commit -m "Commit" | 18 | git commit -m "Commit" |
| 18 | 19 | ||
| 19 | chmod +x dir/content | 20 | chmod +x dir/content |
| @@ -23,4 +24,4 @@ echo -n "foo" > executable · 3 unmodified lines | |||
| 23 | 24 | ||
| 24 | rm empty | 25 | rm empty |
| 25 | ln -sf dir/content empty | 26 | ln -sf dir/content empty |
| 26 | git reset | 27 | git reset |
| @@ -12,6 +12,7 @@ git init -q changed-and-untracked · 11 unmodified lines | |||
| 12 | echo "different content" > dir/content2 | 12 | echo "different content" > dir/content2 |
| 13 | 13 | ||
| 14 | git add -A | 14 | git add -A |
| 15 | git update-index --chmod=+x executable # For Windows. | ||
| 15 | git commit -m "Commit" | 16 | git commit -m "Commit" |
| 16 | echo "change" >> executable | 17 | echo "change" >> executable |
| 17 | 18 | ||
| @@ -13,6 +13,7 @@ mkdir dir/sub-dir · 12 unmodified lines | |||
| 13 | (cd dir/sub-dir && ln -sf ../content symlink) | 13 | (cd dir/sub-dir && ln -sf ../content symlink) |
| 14 | 14 | ||
| 15 | git add -A | 15 | git add -A |
| 16 | git update-index --chmod=+x executable # For Windows. | ||
| 16 | git commit -m "Commit" | 17 | git commit -m "Commit" |
| 17 | rm -rf ./empty ./executable ./dir/content ./dir/sub-dir/symlink | 18 | rm -rf ./empty ./executable ./dir/content ./dir/sub-dir/symlink |
| 18 | git reset | 19 | git reset |
| @@ -13,8 +13,9 @@ mkdir dir/sub-dir · 12 unmodified lines | |||
| 13 | (cd dir/sub-dir && ln -sf ../content symlink) | 13 | (cd dir/sub-dir && ln -sf ../content symlink) |
| 14 | 14 | ||
| 15 | git add -A | 15 | git add -A |
| 16 | git update-index --chmod=+x executable # For Windows. | ||
| 16 | git commit -m "Commit" | 17 | git commit -m "Commit" |
| 17 | 18 | ||
| 18 | touch ./empty ./executable ./dir/content ./dir/sub-dir/symlink | 19 | touch ./empty ./executable ./dir/content ./dir/sub-dir/symlink |
| 19 | 20 | ||
| 20 | git reset # ensure index timestamp is large enough to not mark everything racy | 21 | git reset # ensure index timestamp is large enough to not mark everything racy |
| @@ -17,6 +17,7 @@ mkdir dir/sub-dir · 16 unmodified lines | |||
| 17 | (cd dir/sub-dir && ln -sf ../content symlink) | 17 | (cd dir/sub-dir && ln -sf ../content symlink) |
| 18 | 18 | ||
| 19 | git add -A | 19 | git add -A |
| 20 | git update-index --chmod=+x executable # For Windows. | ||
| 20 | git commit -m "Commit" | 21 | git commit -m "Commit" |
| 21 | 22 | ||
| 22 | git init module1 | 23 | git init module1 |
| @@ -17,4 +17,5 @@ mkdir dir/sub-dir · 16 unmodified lines | |||
| 17 | (cd dir/sub-dir && ln -sf ../content symlink) | 17 | (cd dir/sub-dir && ln -sf ../content symlink) |
| 18 | 18 | ||
| 19 | git add -A | 19 | git add -A |
| 20 | git update-index --chmod=+x executable # For Windows. | ||
| 20 | git commit -m "Commit" | 21 | git commit -m "Commit" |
| @@ -17,4 +17,5 @@ mkdir dir/sub-dir · 16 unmodified lines | |||
| 17 | echo "even other content" > dir/sub-dir/file | 17 | echo "even other content" > dir/sub-dir/file |
| 18 | 18 | ||
| 19 | git add -A | 19 | git add -A |
| 20 | git update-index --chmod=+x executable # For Windows. | ||
| 20 | git commit -m "Commit" | 21 | git commit -m "Commit" |
| @@ -173,20 +173,13 @@ fn delayed_driver_process() -> crate::Result { · 172 unmodified lines | |||
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | #[test] | 175 | #[test] |
| 176 | #[cfg_attr( | ||
| 177 | windows, | ||
| 178 | ignore = "on windows, the symlink to a directory doesn't seem to work and we really want to test with symlinks" | ||
| 179 | )] | ||
| 180 | fn overwriting_files_and_lone_directories_works() -> crate::Result { | 176 | fn overwriting_files_and_lone_directories_works() -> crate::Result { |
| 181 | for delay in [ | 177 | for delay in [ |
| 182 | gix_filter::driver::apply::Delay::Allow, | 178 | gix_filter::driver::apply::Delay::Allow, |
| 183 | gix_filter::driver::apply::Delay::Forbid, | 179 | gix_filter::driver::apply::Delay::Forbid, |
| 184 | ] { | 180 | ] { |
| 185 | let mut opts = opts_from_probe(); | 181 | let mut opts = opts_from_probe(); |
| 186 | assert!( | 182 | assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks"); |
| 187 | opts.fs.symlink, | ||
| 188 | "BUG: the probe must detect to be able to generate symlinks" | ||
| 189 | ); | ||
| 190 | opts.overwrite_existing = true; | 183 | opts.overwrite_existing = true; |
| 191 | opts.filter_process_delay = delay; | 184 | opts.filter_process_delay = delay; |
| 192 | opts.destination_is_initially_empty = false; | 185 | opts.destination_is_initially_empty = false; |
| @@ -244,8 +237,7 @@ fn overwriting_files_and_lone_directories_works() -> crate::Result { · 51 unmodified lines | |||
| 244 | ); | 237 | ); |
| 245 | 238 | ||
| 246 | let symlink = destination.path().join("dir/sub-dir/symlink"); | 239 | let symlink = destination.path().join("dir/sub-dir/symlink"); |
| 247 | // on windows, git won't create symlinks as its probe won't detect the capability, even though we do. | 240 | assert!(std::fs::symlink_metadata(&symlink)?.is_symlink()); |
| 248 | assert_eq!(std::fs::symlink_metadata(&symlink)?.is_symlink(), cfg!(unix)); | ||
| 249 | assert_eq!( | 241 | assert_eq!( |
| 250 | std::fs::read(symlink)?.as_bstr(), | 242 | std::fs::read(symlink)?.as_bstr(), |
| 251 | "➡other content\r\n", | 243 | "➡other content\r\n", |
| @@ -270,10 +262,7 @@ fn symlinks_become_files_if_disabled() -> crate::Result { · 18 unmodified lines | |||
| 270 | #[test] | 262 | #[test] |
| 271 | fn symlinks_to_directories_are_usable() -> crate::Result { | 263 | fn symlinks_to_directories_are_usable() -> crate::Result { |
| 272 | let opts = opts_from_probe(); | 264 | let opts = opts_from_probe(); |
| 273 | if !opts.fs.symlink { | 265 | assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks"); |
| 274 | eprintln!("Skipping directory symlink test on filesystem that doesn't support it"); | ||
| 275 | return Ok(()); | ||
| 276 | } | ||
| 277 | 266 | ||
| 278 | let (_source_tree, destination, _index, outcome) = | 267 | let (_source_tree, destination, _index, outcome) = |
| 279 | checkout_index_in_tmp_dir(opts.clone(), "make_dir_symlink", None)?; | 268 | checkout_index_in_tmp_dir(opts.clone(), "make_dir_symlink", None)?; |
| @@ -298,10 +287,7 @@ fn symlinks_to_directories_are_usable() -> crate::Result { · 18 unmodified lines | |||
| 298 | #[test] | 287 | #[test] |
| 299 | fn dangling_symlinks_can_be_created() -> crate::Result { | 288 | fn dangling_symlinks_can_be_created() -> crate::Result { |
| 300 | let opts = opts_from_probe(); | 289 | let opts = opts_from_probe(); |
| 301 | if !opts.fs.symlink { | 290 | assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks"); |
| 302 | eprintln!("Skipping dangling symlink test on filesystem that doesn't support it"); | ||
| 303 | return Ok(()); | ||
| 304 | } | ||
| 305 | 291 | ||
| 306 | for (fixture, symlink_name, target_name) in [ | 292 | for (fixture, symlink_name, target_name) in [ |
| 307 | ("make_dangling_symlink", "dangling", "non-existing-target"), | 293 | ("make_dangling_symlink", "dangling", "non-existing-target"), |
| @@ -23,6 +23,7 @@ echo "/file-ignored export-ignore" >> .gitattributes · 22 unmodified lines | |||
| 23 | dd if=/dev/zero of=bigfile bs=1024 count=156 | 23 | dd if=/dev/zero of=bigfile bs=1024 count=156 |
| 24 | 24 | ||
| 25 | git add . | 25 | git add . |
| 26 | git update-index --chmod=+x dir/subdir/exe | ||
| 26 | git commit -m "init" | 27 | git commit -m "init" |
| 27 | 28 | ||
| 28 | echo "extra" > extra-file | 29 | echo "extra" > extra-file |
| @@ -32,4 +33,3 @@ ln -s ../extra-file extra-dir/symlink-to-extra · 3 unmodified lines | |||
| 32 | dd if=/dev/zero of=extra-bigfile bs=1024 count=156 | 33 | dd if=/dev/zero of=extra-bigfile bs=1024 count=156 |
| 33 | 34 | ||
| 34 | git rev-parse @^{tree} > head.hex | 35 | git rev-parse @^{tree} > head.hex |
| 35 | |||
| @@ -110,12 +110,6 @@ mod from_tree { · 109 unmodified lines | |||
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | let expected_exe_mode = if cfg!(windows) { | ||
| 114 | EntryKind::Blob | ||
| 115 | } else { | ||
| 116 | EntryKind::BlobExecutable | ||
| 117 | }; | ||
| 118 | let expected_link_mode = EntryKind::Link; | ||
| 119 | assert_eq!( | 113 | assert_eq!( |
| 120 | paths_and_modes, | 114 | paths_and_modes, |
| 121 | &[ | 115 | &[ |
| @@ -136,7 +130,7 @@ mod from_tree { · 14 unmodified lines | |||
| 136 | ), | 130 | ), |
| 137 | ( | 131 | ( |
| 138 | "symlink-to-a".into(), | 132 | "symlink-to-a".into(), |
| 139 | expected_link_mode, | 133 | EntryKind::Link, |
| 140 | hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e") | 134 | hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e") |
| 141 | ), | 135 | ), |
| 142 | ( | 136 | ( |
| @@ -151,7 +145,7 @@ mod from_tree { · 8 unmodified lines | |||
| 151 | ), | 145 | ), |
| 152 | ( | 146 | ( |
| 153 | "dir/subdir/exe".into(), | 147 | "dir/subdir/exe".into(), |
| 154 | expected_exe_mode, | 148 | EntryKind::BlobExecutable, |
| 155 | hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") | 149 | hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391") |
| 156 | ), | 150 | ), |
| 157 | ( | 151 | ( |
| @@ -171,7 +165,11 @@ mod from_tree { · 13 unmodified lines | |||
| 171 | ), | 165 | ), |
| 172 | ( | 166 | ( |
| 173 | "extra-exe".into(), | 167 | "extra-exe".into(), |
| 174 | expected_exe_mode, | 168 | if cfg!(windows) { |
| 169 | EntryKind::Blob | ||
| 170 | } else { | ||
| 171 | EntryKind::BlobExecutable | ||
| 172 | }, | ||
| 175 | hex_to_id("0000000000000000000000000000000000000000") | 173 | hex_to_id("0000000000000000000000000000000000000000") |
| 176 | ), | 174 | ), |
| 177 | ( | 175 | ( |
| @@ -181,7 +179,7 @@ mod from_tree { · 3 unmodified lines | |||
| 181 | ), | 179 | ), |
| 182 | ( | 180 | ( |
| 183 | "extra-dir/symlink-to-extra".into(), | 181 | "extra-dir/symlink-to-extra".into(), |
| 184 | expected_link_mode, | 182 | EntryKind::Link, |
| 185 | hex_to_id("0000000000000000000000000000000000000000") | 183 | hex_to_id("0000000000000000000000000000000000000000") |
| 186 | ) | 184 | ) |
| 187 | ] | 185 | ] |
Binary file not shown.
| @@ -53,8 +53,8 @@ git init --bare blob.corrupt · 52 unmodified lines | |||
| 53 | echo bnkxmdwz | git hash-object -w --stdin | 53 | echo bnkxmdwz | git hash-object -w --stdin |
| 54 | oid=$(echo bmwsjxzi | git hash-object -w --stdin) | 54 | oid=$(echo bmwsjxzi | git hash-object -w --stdin) |
| 55 | oidf=objects/$(oid_to_path "$oid") | 55 | oidf=objects/$(oid_to_path "$oid") |
| 56 | chmod 755 $oidf | 56 | chmod -- 644 "$oidf" |
| 57 | echo broken >$oidf | 57 | echo broken >"$oidf" |
| 58 | 58 | ||
| 59 | baseline "cafea" | 59 | baseline "cafea" |
| 60 | baseline "cafea^{object}" | 60 | baseline "cafea^{object}" |
| @@ -424,4 +424,4 @@ git init invalid-head · 363 unmodified lines | |||
| 424 | rm .git/refs/heads/main | 424 | rm .git/refs/heads/main |
| 425 | baseline 'HEAD' | 425 | baseline 'HEAD' |
| 426 | baseline 'HEAD:file' | 426 | baseline 'HEAD:file' |
| 427 | ) | 427 | ) |