Skip to content

Commit 5aa1d1a

Browse files
committed
Set +x in index in gix-worktree-stream basic fixture, adjust test
As in 470c76e, this updates tests to reflect the ability of Git repositories to represent Unix-style executable permissions in an index and commits, and the ability of gitoxide to operate on this, on all platforms, including Windows where the filesystem itself does not support this kind of executable permissons. Changes: 1. Adds a `git update-index --chmod=+x` command in the basic.sh fixture for gix-worktree-steam, so `dir/subtree/exe` is marked executable in the repository, even on Windows where the filesystem itself does not support Unix-style executable permissions and where, in Git Bash, `chmod +x` has no effect. This does not affect `extra-exe`, which is never staged. Since `extra-exe` is just an extra file in the working tree, it cannot be marked `+x` on Windows. 2. Updates the `paths_and_modes` assertion in `will_provide_all_information_and_respect_export_ignore` to assert the correct mode, with `+x` set, in the staged/committed file `dir/subtree/exe`. The `extra-exe` part of the assertion is unchanged in meaning, but the `expected_exe_mode` would only be used in that one place now, so this removes it and replaces it with the conditional expression for its value based on whether we are using Windows. While doing that refactoring, this also removes the `expected_link_mode` constant, which has unconditionally aliased `EntryKind::Link` since 93e088a (GitoxideLabs#1444). These changes are directly analogous to (1) and (2) in 470c76e. Here, they are made to the gix-worktree-stream tests, while in 470c76e they were made to the gix-archive tests (along with another related change, in (3), for which there is nothing anlogous to be done here). For reference, with *this* commit's change (1) described above but without *this* commit's change (2), the failure is: --- STDERR: gix-worktree-stream::stream from_tree::will_provide_all_information_and_respect_export_ignore --- Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.45s thread 'from_tree::will_provide_all_information_and_respect_export_ignore' panicked at gix-worktree-stream\tests\stream.rs:119:9: assertion `left == right` failed left: [(".gitattributes", Blob, Sha1(45c160c35c17ad264b96431cceb9793160396e99)), ("a", Blob, Sha1(45b983be36b73c0788dc9cbcb76cbb80fc7bb057)), ("bigfile", Blob, Sha1(4995fde49ed64e043977e22539f66a0d372dd129)), ("symlink-to-a", Link, Sha1(2e65efe2a145dda7ee51d1741299f848e5bf752e)), ("dir/.gitattributes", Blob, Sha1(81b9a375276405703e05be6cecf0fc1c8b8eed64)), ("dir/b", Blob, Sha1(ab4a98190cf776b43cb0fe57cef231fb93fd07e6)), ("dir/subdir/exe", BlobExecutable, Sha1(e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)), ("dir/subdir/streamed", Blob, Sha1(08991f58f4de5d85b61c0f87f3ac053c79d0e739)), ("extra-file", Blob, Sha1(0000000000000000000000000000000000000000)), ("extra-bigfile", Blob, Sha1(0000000000000000000000000000000000000000)), ("extra-exe", Blob, Sha1(0000000000000000000000000000000000000000)), ("extra-dir-empty", Tree, Sha1(0000000000000000000000000000000000000000)), ("extra-dir/symlink-to-extra", Link, Sha1(0000000000000000000000000000000000000000))] right: [(".gitattributes", Blob, Sha1(45c160c35c17ad264b96431cceb9793160396e99)), ("a", Blob, Sha1(45b983be36b73c0788dc9cbcb76cbb80fc7bb057)), ("bigfile", Blob, Sha1(4995fde49ed64e043977e22539f66a0d372dd129)), ("symlink-to-a", Link, Sha1(2e65efe2a145dda7ee51d1741299f848e5bf752e)), ("dir/.gitattributes", Blob, Sha1(81b9a375276405703e05be6cecf0fc1c8b8eed64)), ("dir/b", Blob, Sha1(ab4a98190cf776b43cb0fe57cef231fb93fd07e6)), ("dir/subdir/exe", Blob, Sha1(e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)), ("dir/subdir/streamed", Blob, Sha1(08991f58f4de5d85b61c0f87f3ac053c79d0e739)), ("extra-file", Blob, Sha1(0000000000000000000000000000000000000000)), ("extra-bigfile", Blob, Sha1(0000000000000000000000000000000000000000)), ("extra-exe", Blob, Sha1(0000000000000000000000000000000000000000)), ("extra-dir-empty", Tree, Sha1(0000000000000000000000000000000000000000)), ("extra-dir/symlink-to-extra", Link, Sha1(0000000000000000000000000000000000000000))] note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1 parent 22e7f33 commit 5aa1d1a

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

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-

gix-worktree-stream/tests/stream.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,6 @@ mod from_tree {
110110
}
111111
}
112112

113-
let expected_exe_mode = if cfg!(windows) {
114-
EntryKind::Blob
115-
} else {
116-
EntryKind::BlobExecutable
117-
};
118-
let expected_link_mode = EntryKind::Link;
119113
assert_eq!(
120114
paths_and_modes,
121115
&[
@@ -136,7 +130,7 @@ mod from_tree {
136130
),
137131
(
138132
"symlink-to-a".into(),
139-
expected_link_mode,
133+
EntryKind::Link,
140134
hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e")
141135
),
142136
(
@@ -151,7 +145,7 @@ mod from_tree {
151145
),
152146
(
153147
"dir/subdir/exe".into(),
154-
expected_exe_mode,
148+
EntryKind::BlobExecutable,
155149
hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391")
156150
),
157151
(
@@ -171,7 +165,7 @@ mod from_tree {
171165
),
172166
(
173167
"extra-exe".into(),
174-
expected_exe_mode,
168+
if cfg!(windows) { EntryKind::Blob } else { EntryKind::BlobExecutable },
175169
hex_to_id("0000000000000000000000000000000000000000")
176170
),
177171
(
@@ -181,7 +175,7 @@ mod from_tree {
181175
),
182176
(
183177
"extra-dir/symlink-to-extra".into(),
184-
expected_link_mode,
178+
EntryKind::Link,
185179
hex_to_id("0000000000000000000000000000000000000000")
186180
)
187181
]

0 commit comments

Comments
 (0)