Unified · Split
| @@ -21,7 +21,7 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 20 unmodified lines | ||
| 21 | 21 | * [x] [pack verify](https://asciinema.org/a/346975) |
| 22 | 22 | * [x] [pack index verify](https://asciinema.org/a/346976) including each object sha1 and statistics |
| 23 | 23 | * [x] pack explode, useful for transforming packs into loose objects for inspection or restoration |
| 24 | − * [ ] verify written objects (by reading them back from disk) | |
| 24 | + * [x] verify written objects (by reading them back from disk) | |
| 25 | 25 | * **git-object** |
| 26 | 26 | * *decode (zero-copy)* borrowed objects |
| 27 | 27 | * [x] commit |
| @@ -46,7 +46,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 18 unmodified lines | ||
| 46 | 46 | * [x] traverse pack index |
| 47 | 47 | * [x] object abstraction |
| 48 | 48 | * [x] decode (zero copy) |
| 49 | − * [x] verify | |
| 49 | + * [x] verify checksum | |
| 50 | + * [x] easy and fast pack traversal | |
| 50 | 51 | * [x] decode |
| 51 | 52 | * [x] full objects |
| 52 | 53 | * [x] deltified objects |
| @@ -57,8 +58,8 @@ Please see _'Development Status'_ for a listing of all crates and their capabili · 4 unmodified lines | ||
| 57 | 58 | * [ ] create new pack |
| 58 | 59 | * [ ] create 'thin' pack |
| 59 | 60 | * [x] verify pack with statistics |
| 60 | − * [ ] brute force - less memory | |
| 61 | − * [ ] indexed - more memory | |
| 61 | + * [x] brute force - less memory | |
| 62 | + * [x] indexed - more memory | |
| 62 | 63 | * [ ] pack streaming (i.e. indexing + resolution) |
| 63 | 64 | * [ ] API documentation with examples |
| 64 | 65 | * **sink** |
| @@ -0,0 +1,33 @@ | ||
| 1 | +use crate::pack; | |
| 2 | +use std::{fs, io}; | |
| 3 | + | |
| 4 | +#[derive(Debug)] | |
| 5 | +pub struct Iter<R> { | |
| 6 | + read: R, | |
| 7 | +} | |
| 8 | + | |
| 9 | +impl<R> Iter<R> | |
| 10 | +where | |
| 11 | + R: io::Read, | |
| 12 | +{ | |
| 13 | + pub fn new(read: R) -> Self { | |
| 14 | + Iter { read } | |
| 15 | + } | |
| 16 | +} | |
| 17 | + | |
| 18 | +impl<R> Iterator for Iter<R> | |
| 19 | +where | |
| 20 | + R: io::Read, | |
| 21 | +{ | |
| 22 | + type Item = (); | |
| 23 | + | |
| 24 | + fn next(&mut self) -> Option<Self::Item> { | |
| 25 | + unimplemented!("iter") | |
| 26 | + } | |
| 27 | +} | |
| 28 | + | |
| 29 | +impl pack::data::File { | |
| 30 | + pub fn iter(&self) -> io::Result<impl Iterator<Item = ()>> { | |
| 31 | + Ok(Iter::new(io::BufReader::new(fs::File::open(&self.path)?))) | |
| 32 | + } | |
| 33 | +} | |
| @@ -1,3 +1,4 @@ | ||
| 1 | +//! data within a pack file | |
| 1 | 2 | use filebuffer::FileBuffer; |
| 2 | 3 | use std::path::Path; |
| 3 | 4 | |
| @@ -6,6 +7,7 @@ mod decoded; · 2 unmodified lines | ||
| 6 | 7 | pub use decoded::*; |
| 7 | 8 | |
| 8 | 9 | pub mod init; |
| 10 | +pub mod iter; | |
| 9 | 11 | pub mod parse; |
| 10 | 12 | pub mod verify; |
| 11 | 13 | |
| @@ -1,3 +1,5 @@ | ||
| 1 | +//! an index into the pack file | |
| 2 | +//! | |
| 1 | 3 | /// From itertools |
| 2 | 4 | /// Create an iterator running multiple iterators in lockstep. |
| 3 | 5 | /// |
| @@ -7,8 +7,7 @@ fn pack_at(at: &str) -> pack::data::File { · 6 unmodified lines | ||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | mod method { |
| 10 | − use crate::pack::file::pack_at; | |
| 11 | − use crate::pack::SMALL_PACK; | |
| 10 | + use crate::{pack::file::pack_at, pack::SMALL_PACK}; | |
| 12 | 11 | |
| 13 | 12 | #[test] |
| 14 | 13 | fn checksum() { |
| @@ -24,6 +23,13 @@ mod method { · 9 unmodified lines | ||
| 24 | 23 | let p = pack_at(SMALL_PACK); |
| 25 | 24 | assert_eq!(p.verify_checksum().unwrap(), p.checksum()); |
| 26 | 25 | } |
| 26 | + | |
| 27 | + #[test] | |
| 28 | + fn iter() { | |
| 29 | + let pack = pack_at(SMALL_PACK); | |
| 30 | + let it = pack.iter().unwrap(); | |
| 31 | + assert_eq!(it.count(), pack.num_objects() as usize); | |
| 32 | + } | |
| 27 | 33 | } |
| 28 | 34 | |
| 29 | 35 | /// All hardcoded offsets are obtained via `git pack-verify --verbose tests/fixtures/packs/pack-a2bf8e71d8c18879e499335762dd95119d93d9f1.idx` |
| @@ -187,6 +187,7 @@ fn pack_lookup() { · 186 unmodified lines | ||
| 187 | 187 | assert_ne!(pack_entry.data_offset, idx_entry.pack_offset); |
| 188 | 188 | assert!(sorted_offsets.binary_search(&idx_entry.pack_offset).is_ok()); |
| 189 | 189 | } |
| 190 | + // TODO: test iteration by sorted offsets yields the correct result when using the pack iterator | |
| 190 | 191 | } |
| 191 | 192 | } |
| 192 | 193 | |