Unified · Split
| @@ -87,10 +87,8 @@ impl Bundle { · 86 unmodified lines | ||
| 87 | 87 | C: pack::cache::DecodeEntry, |
| 88 | 88 | { |
| 89 | 89 | self.index.verify_checksum_of_index( |
| 90 | − Some(&self.pack), | |
| 90 | + Some((&self.pack, mode, pack::index::verify::Algorithm::default())), | |
| 91 | 91 | thread_limit, |
| 92 | − mode, | |
| 93 | − pack::index::verify::Algorithm::default(), | |
| 94 | 92 | progress, |
| 95 | 93 | make_cache, |
| 96 | 94 | ) |
| @@ -140,10 +140,8 @@ impl index::File { · 139 unmodified lines | ||
| 140 | 140 | /// redoing a lot of work across multiple objects. |
| 141 | 141 | pub fn verify_checksum_of_index<P, C>( |
| 142 | 142 | &self, |
| 143 | − pack: Option<&pack::data::File>, | |
| 143 | + pack: Option<(&pack::data::File, Mode, Algorithm)>, | |
| 144 | 144 | thread_limit: Option<usize>, |
| 145 | − mode: Mode, | |
| 146 | − algorithm: Algorithm, | |
| 147 | 145 | progress: Option<P>, |
| 148 | 146 | make_cache: impl Fn() -> C + Send + Sync, |
| 149 | 147 | ) -> Result<(owned::Id, Option<Outcome>), Error> |
| @@ -171,7 +169,7 @@ impl index::File { · 21 unmodified lines | ||
| 171 | 169 | }; |
| 172 | 170 | match pack { |
| 173 | 171 | None => verify_self().map(|id| (id, None)), |
| 174 | − Some(pack) => { | |
| 172 | + Some((pack, mode, algorithm)) => { | |
| 175 | 173 | if self.checksum_of_pack() != pack.checksum() { |
| 176 | 174 | return Err(Error::PackMismatch { |
| 177 | 175 | actual: pack.checksum(), |
| @@ -74,6 +74,17 @@ use common_macros::b_tree_map; · 73 unmodified lines | ||
| 74 | 74 | use git_features::progress::Discard; |
| 75 | 75 | use git_odb::pack::cache::DecodeEntryNoop; |
| 76 | 76 | |
| 77 | +static ALGOS: &[index::verify::Algorithm] = &[ | |
| 78 | + index::verify::Algorithm::Lookup, | |
| 79 | + index::verify::Algorithm::DeltaTreeLookup, | |
| 80 | +]; | |
| 81 | + | |
| 82 | +static MODES: &[index::verify::Mode] = &[ | |
| 83 | + index::verify::Mode::Sha1CRC32, | |
| 84 | + index::verify::Mode::Sha1CRC32Decode, | |
| 85 | + index::verify::Mode::Sha1CRC32DecodeEncode, | |
| 86 | +]; | |
| 87 | + | |
| 77 | 88 | #[test] |
| 78 | 89 | fn pack_lookup() { |
| 79 | 90 | for (index_path, pack_path, stats) in &[ |
| @@ -152,18 +163,15 @@ fn pack_lookup() { · 72 unmodified lines | ||
| 152 | 163 | |
| 153 | 164 | assert_eq!(pack.kind(), pack::data::Kind::V2); |
| 154 | 165 | assert_eq!(pack.num_objects(), idx.num_objects()); |
| 155 | − assert_eq!( | |
| 156 | − idx.verify_checksum_of_index( | |
| 157 | − Some(&pack), | |
| 158 | − None, | |
| 159 | − index::verify::Mode::Sha1CRC32DecodeEncode, | |
| 160 | − index::verify::Algorithm::Lookup, | |
| 161 | − Discard.into(), | |
| 162 | − || DecodeEntryNoop | |
| 163 | − ) | |
| 164 | − .unwrap(), | |
| 165 | − (idx.checksum_of_index(), Some(stats.to_owned())) | |
| 166 | − ); | |
| 166 | + for algo in ALGOS { | |
| 167 | + for mode in MODES { | |
| 168 | + assert_eq!( | |
| 169 | + idx.verify_checksum_of_index(Some((&pack, *mode, *algo)), None, Discard.into(), || DecodeEntryNoop) | |
| 170 | + .unwrap(), | |
| 171 | + (idx.checksum_of_index(), Some(stats.to_owned())) | |
| 172 | + ); | |
| 173 | + } | |
| 174 | + } | |
| 167 | 175 | let num_objects = stats |
| 168 | 176 | .objects_per_chain_length |
| 169 | 177 | .values() |
| @@ -212,15 +220,8 @@ fn iter() { · 42 unmodified lines | ||
| 212 | 220 | assert_eq!(idx.version(), *version); |
| 213 | 221 | assert_eq!(idx.num_objects(), *num_objects); |
| 214 | 222 | assert_eq!( |
| 215 | − idx.verify_checksum_of_index( | |
| 216 | − None, | |
| 217 | − None, | |
| 218 | − index::verify::Mode::Sha1CRC32Decode, | |
| 219 | − index::verify::Algorithm::Lookup, | |
| 220 | − Discard.into(), | |
| 221 | − || { DecodeEntryNoop } | |
| 222 | − ) | |
| 223 | − .unwrap(), | |
| 223 | + idx.verify_checksum_of_index(None, None, Discard.into(), || { DecodeEntryNoop }) | |
| 224 | + .unwrap(), | |
| 224 | 225 | (idx.checksum_of_index(), None) |
| 225 | 226 | ); |
| 226 | 227 | assert_eq!(idx.checksum_of_index(), hex_to_id(index_checksum)); |
| @@ -183,8 +183,13 @@ where · 182 unmodified lines | ||
| 183 | 183 | } |
| 184 | 184 | }; |
| 185 | 185 | |
| 186 | − idx.verify_checksum_of_index(pack.as_ref(), thread_limit, mode, algorithm.into(), progress, cache) | |
| 187 | − .with_context(|| "Verification failure")? | |
| 186 | + idx.verify_checksum_of_index( | |
| 187 | + pack.as_ref().map(|p| (p, mode, algorithm.into())), | |
| 188 | + thread_limit, | |
| 189 | + progress, | |
| 190 | + cache, | |
| 191 | + ) | |
| 192 | + .with_context(|| "Verification failure")? | |
| 188 | 193 | } |
| 189 | 194 | ext => return Err(anyhow!("Unknown extension {:?}, expecting 'idx' or 'pack'", ext)), |
| 190 | 195 | }; |
| @@ -29,6 +29,8 @@ · 28 unmodified lines | ||
| 29 | 29 | * [ ] `inc_by(step)` method |
| 30 | 30 | * [ ] a way to measure throughput on drop |
| 31 | 31 | * **plumbing - explode pack** |
| 32 | + * _useful for receiving packs that are small enough to warrant living as loose objects for a while | |
| 33 | + preventing pack buildup_ | |
| 32 | 34 | * [ ] write loose object |
| 33 | 35 | * [ ] single threaded |
| 34 | 36 | * [ ] multi-threaded |