@@ -76,6 +76,17 @@ pub struct Outcome {
76
76
pub pack_size : u64 ,
77
77
}
78
78
79
+ /// Various ways in which a pack and index can be verified
80
+ #[ derive( Debug , Eq , PartialEq , Hash , Clone , Copy ) ]
81
+ pub enum Mode {
82
+ /// Validate SHA1 and CRC32
83
+ Sha1CRC32 ,
84
+ /// Validate SHA1 and CRC32, and decode each non-Blob object
85
+ Sha1CRC32Decode ,
86
+ /// Validate SHA1 and CRC32, and decode and encode each non-Blob object
87
+ Sha1CRC32DecodeEncode ,
88
+ }
89
+
79
90
/// Verify and validate the content of the index file
80
91
impl index:: File {
81
92
pub fn checksum_of_index ( & self ) -> owned:: Id {
@@ -94,6 +105,7 @@ impl index::File {
94
105
& self ,
95
106
pack : Option < & pack:: data:: File > ,
96
107
thread_limit : Option < usize > ,
108
+ mode : Mode ,
97
109
progress : Option < P > ,
98
110
make_cache : impl Fn ( ) -> C + Send + Sync ,
99
111
) -> Result < ( owned:: Id , Option < Outcome > ) , Error >
@@ -281,10 +293,9 @@ impl index::File {
281
293
} ) ;
282
294
}
283
295
if let Some ( desired_crc32) = index_entry. crc32 {
284
- let actual_crc32 = pack. entry_crc32 (
285
- index_entry. pack_offset ,
286
- ( pack_entry_data_offset - index_entry. pack_offset ) as usize + consumed_input,
287
- ) ;
296
+ let header_size = ( pack_entry_data_offset - index_entry. pack_offset ) as usize ;
297
+ let actual_crc32 =
298
+ pack. entry_crc32 ( index_entry. pack_offset , header_size + consumed_input) ;
288
299
if actual_crc32 != desired_crc32 {
289
300
return Err ( Error :: Crc32Mismatch {
290
301
actual : actual_crc32,
0 commit comments