Skip to content

Commit 8e99eba

Browse files
authored
Merge pull request #1652 from EliahKagan/run-ci/chmod
Test cross-platform symlink and +x permission expectations on Windows
2 parents 3fb989b + d03971b commit 8e99eba

File tree

24 files changed

+58
-70
lines changed

24 files changed

+58
-70
lines changed

gix-archive/tests/archive.rs

+17-16
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ mod from_tree {
2727
entry.read_to_end(&mut buf).expect("stream can always be read");
2828
}
2929

30-
let expected_link_mode = EntryKind::Link;
31-
let expected_exe_mode = if cfg!(windows) {
32-
EntryKind::Blob
33-
} else {
34-
EntryKind::BlobExecutable
35-
};
3630
assert_eq!(
3731
paths_and_modes,
3832
&[
@@ -48,7 +42,7 @@ mod from_tree {
4842
),
4943
(
5044
"symlink-to-a".into(),
51-
expected_link_mode,
45+
EntryKind::Link,
5246
hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e")
5347
),
5448
(
@@ -58,7 +52,7 @@ mod from_tree {
5852
),
5953
(
6054
"dir/subdir/exe".into(),
61-
expected_exe_mode,
55+
EntryKind::BlobExecutable,
6256
hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391")
6357
),
6458
(
@@ -68,7 +62,11 @@ mod from_tree {
6862
),
6963
(
7064
"extra-exe".into(),
71-
expected_exe_mode,
65+
if cfg!(windows) {
66+
EntryKind::Blob
67+
} else {
68+
EntryKind::BlobExecutable
69+
},
7270
hex_to_id("0000000000000000000000000000000000000000")
7371
),
7472
(
@@ -78,7 +76,7 @@ mod from_tree {
7876
),
7977
(
8078
"extra-dir/symlink-to-extra".into(),
81-
expected_link_mode,
79+
EntryKind::Link,
8280
hex_to_id("0000000000000000000000000000000000000000")
8381
)
8482
]
@@ -111,20 +109,23 @@ mod from_tree {
111109
header.mode()?,
112110
));
113111
}
114-
let expected_symlink_type = EntryType::Symlink;
115-
let expected_exe_mode = if cfg!(windows) { 420 } else { 493 };
116112
assert_eq!(
117113
out,
118114
[
119115
("prefix/.gitattributes", EntryType::Regular, 56, 420),
120116
("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),
122118
("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),
124120
("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+
),
126127
("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)
128129
]
129130
.into_iter()
130131
.map(|(path, b, c, d)| (bstr::BStr::new(path).to_owned(), b, c, d))

gix-archive/tests/fixtures/basic.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ echo "/dir-ignored/ export-ignore" > .gitattributes
2020
echo "/file-ignored export-ignore" >> .gitattributes
2121

2222
git add .
23+
git update-index --chmod=+x dir/subdir/exe # For Windows.
2324
git commit -m "init"
2425

2526
echo "extra to be streamed" > extra-file
@@ -28,4 +29,3 @@ mkdir extra-dir-empty extra-dir
2829
ln -s ../extra-file extra-dir/symlink-to-extra
2930

3031
git rev-parse @^{tree} > head.hex
31-

gix-dir/tests/fixtures/many-symlinks.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env bash
22
set -eu -o pipefail
33

4-
# Note that symlink creation fails on Windows for some reason,
5-
# so these tests shouldn't be run there.
4+
# These fixtures use symlinks. See `many.sh` for some that don't.
65

76
git init breakout-symlink
87
(cd breakout-symlink
@@ -20,7 +19,7 @@ git init immediate-breakout-symlink
2019

2120
git init excluded-symlinks-to-dir
2221
(cd excluded-symlinks-to-dir
23-
cat <<EOF >.gitignore
22+
cat <<'EOF' >.gitignore
2423
src1
2524
src2/
2625
file1
@@ -42,4 +41,4 @@ EOF
4241
ln -s src/file file2
4342
)
4443

45-
ln -s excluded-symlinks-to-dir worktree-root-is-symlink
44+
ln -s excluded-symlinks-to-dir worktree-root-is-symlink

gix-dir/tests/fixtures/many.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -eu -o pipefail
33

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.
55

66
git init with-nested-dot-git
77
(cd with-nested-dot-git

gix-dir/tests/walk/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use gix_dir::walk::ForDeletionMode;
1919
use gix_ignore::Kind::*;
2020

2121
#[test]
22-
#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")]
2322
fn symlink_to_dir_can_be_excluded() -> crate::Result {
2423
let root = fixture_in("many-symlinks", "excluded-symlinks-to-dir");
2524
let ((out, _root), entries) = collect(&root, None, |keep, ctx| {
@@ -94,7 +93,6 @@ fn symlink_to_dir_can_be_excluded() -> crate::Result {
9493
}
9594

9695
#[test]
97-
#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")]
9896
fn root_may_not_lead_through_symlinks() -> crate::Result {
9997
for (name, intermediate, expected) in [
10098
("immediate-breakout-symlink", "", 0),
@@ -121,7 +119,6 @@ fn root_may_not_lead_through_symlinks() -> crate::Result {
121119
}
122120

123121
#[test]
124-
#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")]
125122
fn root_may_be_a_symlink_if_it_is_the_worktree() -> crate::Result {
126123
let root = fixture_in("many-symlinks", "worktree-root-is-symlink");
127124
let ((_out, _root), entries) = collect(&root, None, |keep, ctx| {
@@ -2702,7 +2699,6 @@ fn decomposed_unicode_in_directory_is_returned_precomposed() -> crate::Result {
27022699
}
27032700

27042701
#[test]
2705-
#[cfg_attr(windows, ignore = "symlinks the way they are organized don't yet work on windows")]
27062702
fn worktree_root_can_be_symlink() -> crate::Result {
27072703
let root = fixture_in("many-symlinks", "symlink-to-breakout-symlink");
27082704
let troot = root.join("file");
Binary file not shown.

gix-index/tests/fixtures/make_index/v2_all_file_kinds.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env bash
22
set -eu -o pipefail
33

4-
export GIT_INDEX_VERSION=2;
4+
export GIT_INDEX_VERSION=2
55

66
git init -q sub
77
(cd sub
8-
98
touch a b c
109
git add .
1110
git commit -m "init"
@@ -21,6 +20,7 @@ mkdir d
2120
(cd d && touch a b c)
2221

2322
git add .
23+
git update-index --chmod=+x b # For Windows.
2424
git commit -m "init"
2525

2626
git rev-parse @^{tree} > head.tree

gix-index/tests/fixtures/make_index/v2_deeper_tree.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
set -eu -o pipefail
33

4-
export GIT_INDEX_VERSION=2;
4+
export GIT_INDEX_VERSION=2
55

66
mkdir sub
77
(cd sub
@@ -25,4 +25,5 @@ mkdir d
2525
)
2626

2727
git add .
28+
git update-index --chmod=+x b # For Windows.
2829
git commit -m "init"
Binary file not shown.

gix-merge/tests/fixtures/tree-baseline.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ git init same-rename-different-mode
475475

476476
git checkout A
477477
write_lines 1 2 3 4 5 >a/x.f
478-
chmod +x a/x.f
479-
chmod +x a/w
478+
chmod +x a/x.f a/w
479+
git update-index --chmod=+x a/x.f a/w
480480
git mv a a-renamed
481481
git commit -am "changed all content, add +x, renamed a -> a-renamed"
482482

@@ -486,8 +486,8 @@ git init same-rename-different-mode
486486
git commit -am "changed all content, renamed a -> a-renamed"
487487

488488
git checkout expected
489-
chmod +x a/x.f
490-
chmod +x a/w
489+
chmod +x a/x.f a/w
490+
git update-index --chmod=+x a/x.f a/w
491491
write_lines 1 2 3 4 5 6 >a/x.f
492492
git mv a a-renamed
493493
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
530530
git checkout B
531531
write_lines original 1 2 3 4 5 6 >new
532532
chmod +x new
533-
git add .
533+
git add --chmod=+x new
534534
git commit -m "add new with content B and +x"
535535

536536
git checkout expected
537537
echo -n $'<<<<<<< A\n1\n2\n3\n4\n5\n=======\noriginal\n1\n2\n3\n4\n5\n6\n>>>>>>> B\n' >new
538538
chmod +x new
539-
git add new
539+
git add --chmod=+x new
540540
git commit -m "Git has a better merge here, but that's due to better hunk handling/hunk splitting. We, however, consistently use +x"
541541
)
542542

Binary file not shown.
Binary file not shown.

gix-status/tests/fixtures/status_changed.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mkdir dir/sub-dir
1414
(cd dir/sub-dir && ln -sf ../content symlink)
1515

1616
git add -A
17+
git update-index --chmod=+x executable # For Windows.
1718
git commit -m "Commit"
1819

1920
chmod +x dir/content
@@ -23,4 +24,4 @@ echo -n "foo" > executable
2324

2425
rm empty
2526
ln -sf dir/content empty
26-
git reset
27+
git reset

gix-status/tests/fixtures/status_many.sh

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ git init -q changed-and-untracked
1212
echo "different content" > dir/content2
1313

1414
git add -A
15+
git update-index --chmod=+x executable # For Windows.
1516
git commit -m "Commit"
1617
echo "change" >> executable
1718

gix-status/tests/fixtures/status_removed.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mkdir dir/sub-dir
1313
(cd dir/sub-dir && ln -sf ../content symlink)
1414

1515
git add -A
16+
git update-index --chmod=+x executable # For Windows.
1617
git commit -m "Commit"
1718
rm -rf ./empty ./executable ./dir/content ./dir/sub-dir/symlink
18-
git reset
19+
git reset

gix-status/tests/fixtures/status_unchanged.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ mkdir dir/sub-dir
1313
(cd dir/sub-dir && ln -sf ../content symlink)
1414

1515
git add -A
16+
git update-index --chmod=+x executable # For Windows.
1617
git commit -m "Commit"
1718

1819
touch ./empty ./executable ./dir/content ./dir/sub-dir/symlink
1920

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

gix-worktree-state/tests/fixtures/make_mixed.sh

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mkdir dir/sub-dir
1717
(cd dir/sub-dir && ln -sf ../content symlink)
1818

1919
git add -A
20+
git update-index --chmod=+x executable # For Windows.
2021
git commit -m "Commit"
2122

2223
git init module1

gix-worktree-state/tests/fixtures/make_mixed_without_submodules.sh

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ mkdir dir/sub-dir
1717
(cd dir/sub-dir && ln -sf ../content symlink)
1818

1919
git add -A
20+
git update-index --chmod=+x executable # For Windows.
2021
git commit -m "Commit"

gix-worktree-state/tests/fixtures/make_mixed_without_submodules_and_symlinks.sh

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ mkdir dir/sub-dir
1717
echo "even other content" > dir/sub-dir/file
1818

1919
git add -A
20+
git update-index --chmod=+x executable # For Windows.
2021
git commit -m "Commit"

gix-worktree-state/tests/state/checkout.rs

+4-18
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,13 @@ fn delayed_driver_process() -> crate::Result {
173173
}
174174

175175
#[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-
)]
180176
fn overwriting_files_and_lone_directories_works() -> crate::Result {
181177
for delay in [
182178
gix_filter::driver::apply::Delay::Allow,
183179
gix_filter::driver::apply::Delay::Forbid,
184180
] {
185181
let mut opts = opts_from_probe();
186-
assert!(
187-
opts.fs.symlink,
188-
"BUG: the probe must detect to be able to generate symlinks"
189-
);
182+
assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks");
190183
opts.overwrite_existing = true;
191184
opts.filter_process_delay = delay;
192185
opts.destination_is_initially_empty = false;
@@ -244,8 +237,7 @@ fn overwriting_files_and_lone_directories_works() -> crate::Result {
244237
);
245238

246239
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.
248-
assert_eq!(std::fs::symlink_metadata(&symlink)?.is_symlink(), cfg!(unix));
240+
assert!(std::fs::symlink_metadata(&symlink)?.is_symlink());
249241
assert_eq!(
250242
std::fs::read(symlink)?.as_bstr(),
251243
"➡other content\r\n",
@@ -270,10 +262,7 @@ fn symlinks_become_files_if_disabled() -> crate::Result {
270262
#[test]
271263
fn symlinks_to_directories_are_usable() -> crate::Result {
272264
let opts = opts_from_probe();
273-
if !opts.fs.symlink {
274-
eprintln!("Skipping directory symlink test on filesystem that doesn't support it");
275-
return Ok(());
276-
}
265+
assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks");
277266

278267
let (_source_tree, destination, _index, outcome) =
279268
checkout_index_in_tmp_dir(opts.clone(), "make_dir_symlink", None)?;
@@ -298,10 +287,7 @@ fn symlinks_to_directories_are_usable() -> crate::Result {
298287
#[test]
299288
fn dangling_symlinks_can_be_created() -> crate::Result {
300289
let opts = opts_from_probe();
301-
if !opts.fs.symlink {
302-
eprintln!("Skipping dangling symlink test on filesystem that doesn't support it");
303-
return Ok(());
304-
}
290+
assert!(opts.fs.symlink, "The probe must detect to be able to generate symlinks");
305291

306292
for (fixture, symlink_name, target_name) in [
307293
("make_dangling_symlink", "dangling", "non-existing-target"),

gix-worktree-stream/tests/fixtures/basic.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ echo "/file-ignored export-ignore" >> .gitattributes
2323
dd if=/dev/zero of=bigfile bs=1024 count=156
2424

2525
git add .
26+
git update-index --chmod=+x dir/subdir/exe
2627
git commit -m "init"
2728

2829
echo "extra" > extra-file
@@ -32,4 +33,3 @@ ln -s ../extra-file extra-dir/symlink-to-extra
3233
dd if=/dev/zero of=extra-bigfile bs=1024 count=156
3334

3435
git rev-parse @^{tree} > head.hex
35-

0 commit comments

Comments
 (0)