From 539edad216eadbc1c563acc02a525b90b2c19e0e Mon Sep 17 00:00:00 2001 From: dploch Date: Wed, 5 Jun 2024 15:45:22 -0400 Subject: [PATCH] diff_util: don't panic for file hashes < 10 hex chars --- cli/src/diff_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/src/diff_util.rs b/cli/src/diff_util.rs index c21b3f693..587dc67a6 100644 --- a/cli/src/diff_util.rs +++ b/cli/src/diff_util.rs @@ -638,7 +638,7 @@ fn git_diff_part( value: MaterializedTreeValue, ) -> Result { let mode; - let hash; + let mut hash; let mut contents: Vec; match value { MaterializedTreeValue::Absent => { @@ -693,7 +693,7 @@ fn git_diff_part( panic!("Unexpected tree in diff at path {path:?}"); } } - let hash = hash[0..10].to_string(); + hash.truncate(10); Ok(GitDiffPart { mode, hash,