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