Skip to content

Commit e153340

Browse files
author
Sidney Douw
committed
add test fixture and adjust
1 parent 09948a5 commit e153340

File tree

5 files changed

+41
-24
lines changed

5 files changed

+41
-24
lines changed

git-index/src/init.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ impl EntryBuilder {
6767
let mode = match entry.mode {
6868
EntryMode::Tree => unreachable!("visit_non_tree() called us"),
6969
EntryMode::Blob => Mode::FILE,
70-
EntryMode::BlobExecutable => todo!("executable"),
71-
EntryMode::Link => todo!("symlink"),
72-
EntryMode::Commit => todo!("submodule"),
70+
EntryMode::BlobExecutable => Mode::FILE_EXECUTABLE,
71+
EntryMode::Link => Mode::SYMLINK,
72+
EntryMode::Commit => Mode::COMMIT,
7373
};
7474

7575
let path_start = self.path_backing.len();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:2b034a569959fd83c39e7aa870fea63b5fd8b87b5665e65881fade92592fc2c3
3+
size 11040
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -eu -o pipefail
3+
4+
export GIT_INDEX_VERSION=2;
5+
6+
git init -q sub
7+
cd sub
8+
9+
touch a b c
10+
git add .
11+
git commit -m "empty"
12+
13+
cd ..
14+
15+
git init -q
16+
git config index.threads 1
17+
18+
touch a b
19+
chmod +x b
20+
ln -s a c
21+
mkdir d
22+
(cd d && touch a b c)
23+
24+
git add .
25+
git commit -m "empty"

git-index/tests/index/file/write.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn roundtrips() -> crate::Result {
2020
(Generated("v2"), Options::default()),
2121
(Generated("V2_empty"), Options::default()),
2222
(Generated("v2_more_files"), all_ext_but_eoie()),
23+
(Generated("v2_all_file_kinds"), all_ext_but_eoie()),
2324
];
2425

2526
for (fixture, options) in input {
@@ -72,6 +73,7 @@ fn state_comparisons_with_various_extension_configurations() {
7273
Generated("V2_empty"),
7374
Generated("v2"),
7475
Generated("v2_more_files"),
76+
Generated("v2_all_file_kinds"),
7577
Generated("v2_split_index"),
7678
Generated("v4_more_files_IEOT"),
7779
] {

git-index/tests/index/init.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn tree_to_state() -> crate::Result {
99
let fixtures = [
1010
"make_index/v2.sh",
1111
"make_index/v2_more_files.sh",
12+
"make_index/v2_all_file_kinds.sh",
1213
"make_index/v4_more_files_IEOT.sh",
1314
];
1415

@@ -33,28 +34,14 @@ fn compare_states(actual: &State, expected: &State, fixture: &str) {
3334
assert_eq!(
3435
actual.entries().len(),
3536
expected.entries().len(),
36-
"entry count mismatch in {}",
37+
"entry count mismatch in {:?}",
3738
fixture
3839
);
3940

40-
assert_eq!(
41-
actual
42-
.entries()
43-
.iter()
44-
.map(|e| (e.id, e.flags, e.mode))
45-
.collect::<Vec<_>>(),
46-
expected
47-
.entries()
48-
.iter()
49-
.map(|e| (e.id, e.flags, e.mode))
50-
.collect::<Vec<_>>()
51-
);
52-
53-
// TODO: check if path_backing needs to be sorted like entries are
54-
// assert_eq!(
55-
// actual.path_backing(),
56-
// expected.path_backing(),
57-
// "path_backing mismatch in {}",
58-
// fixture
59-
// );
41+
actual.entries().iter().zip(expected.entries()).for_each(|(a, e)| {
42+
assert_eq!(a.id, e.id, "entry id mismatch in {:?}", fixture);
43+
assert_eq!(a.flags, e.flags, "entry flags mismatch in {:?}", fixture);
44+
assert_eq!(a.mode, e.mode, "entry mode mismatch in {:?}", fixture);
45+
assert_eq!(a.path(actual), e.path(expected), "entry path mismatch in {:?}", fixture);
46+
})
6047
}

0 commit comments

Comments
 (0)