Skip to content

Commit

Permalink
fix: adjust tree parser to deal with even more unusual trees (#1096).
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 10, 2023
1 parent 1f9aca5 commit 8d05cae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gix-object/src/tree/ref_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ impl TryFrom<u32> for tree::EntryMode {
fn try_from(mode: u32) -> Result<Self, Self::Error> {
Ok(match mode {
0o40000 => tree::EntryMode::Tree,
0o100644 => tree::EntryMode::Blob,
0o100755 => tree::EntryMode::BlobExecutable,
0o120000 => tree::EntryMode::Link,
0o160000 => tree::EntryMode::Commit,
0o100664 => tree::EntryMode::Blob, // rare and found in the linux kernel
0o100640 => tree::EntryMode::Blob, // rare and found in the Rust repo
blob_mode if blob_mode & 0o100000 == 0o100000 => {
if blob_mode & 0o000100 == 0o000100 {
tree::EntryMode::BlobExecutable
} else {
tree::EntryMode::Blob
}
}
_ => return Err(mode),
})
}
Expand Down
Binary file added gix-object/tests/fixtures/tree/special-5.tree
Binary file not shown.
1 change: 1 addition & 0 deletions gix-object/tests/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ mod from_bytes {
("special-2", 18),
("special-3", 5),
("special-4", 18),
("special-5", 17),
] {
let fixture = fixture_name("tree", &format!("{name}.tree"));
assert_eq!(
Expand Down

0 comments on commit 8d05cae

Please sign in to comment.