Skip to content

Commit 8d05cae

Browse files
committed
fix: adjust tree parser to deal with even more unusual trees (#1096).
1 parent 1f9aca5 commit 8d05cae

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

gix-object/src/tree/ref_iter.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ impl TryFrom<u32> for tree::EntryMode {
101101
fn try_from(mode: u32) -> Result<Self, Self::Error> {
102102
Ok(match mode {
103103
0o40000 => tree::EntryMode::Tree,
104-
0o100644 => tree::EntryMode::Blob,
105-
0o100755 => tree::EntryMode::BlobExecutable,
106104
0o120000 => tree::EntryMode::Link,
107105
0o160000 => tree::EntryMode::Commit,
108-
0o100664 => tree::EntryMode::Blob, // rare and found in the linux kernel
109-
0o100640 => tree::EntryMode::Blob, // rare and found in the Rust repo
106+
blob_mode if blob_mode & 0o100000 == 0o100000 => {
107+
if blob_mode & 0o000100 == 0o000100 {
108+
tree::EntryMode::BlobExecutable
109+
} else {
110+
tree::EntryMode::Blob
111+
}
112+
}
110113
_ => return Err(mode),
111114
})
112115
}
651 Bytes
Binary file not shown.

gix-object/tests/tree/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ mod from_bytes {
135135
("special-2", 18),
136136
("special-3", 5),
137137
("special-4", 18),
138+
("special-5", 17),
138139
] {
139140
let fixture = fixture_name("tree", &format!("{name}.tree"));
140141
assert_eq!(

0 commit comments

Comments
 (0)