diff_util: don't panic for file hashes < 10 hex chars

This commit is contained in:
dploch 2024-06-05 15:45:22 -04:00 committed by Daniel Ploch
parent 9fb5307b78
commit 539edad216

View file

@ -638,7 +638,7 @@ fn git_diff_part(
value: MaterializedTreeValue, value: MaterializedTreeValue,
) -> Result<GitDiffPart, DiffRenderError> { ) -> Result<GitDiffPart, DiffRenderError> {
let mode; let mode;
let hash; let mut hash;
let mut contents: Vec<u8>; let mut contents: Vec<u8>;
match value { match value {
MaterializedTreeValue::Absent => { MaterializedTreeValue::Absent => {
@ -693,7 +693,7 @@ fn git_diff_part(
panic!("Unexpected tree in diff at path {path:?}"); panic!("Unexpected tree in diff at path {path:?}");
} }
} }
let hash = hash[0..10].to_string(); hash.truncate(10);
Ok(GitDiffPart { Ok(GitDiffPart {
mode, mode,
hash, hash,