Skip to content

Commit

Permalink
change!: remove Sha1 mentions in index::verify::Mode::* variants (#279
Browse files Browse the repository at this point in the history
)

The hash is repository defined and not hard-coded
  • Loading branch information
Byron committed Dec 29, 2021
1 parent 80b120d commit c2679a0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion git-pack/src/bundle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod verify {
self.index.verify_integrity(
Some(crate::index::verify::PackContext {
data: &self.pack,
verify_mode: verify_mode,
verify_mode,
traversal_algorithm: traversal,
make_cache_fn: make_pack_lookup_cache,
}),
Expand Down
2 changes: 1 addition & 1 deletion git-pack/src/index/traverse/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Error<E: std::error::Error + Send + Sync + 'static> {
expected: git_hash::ObjectId,
actual: git_hash::ObjectId,
},
#[error("The SHA1 of {kind} object at offset {offset} didn't match the checksum in the index file: expected {expected}, got {actual}")]
#[error("The hash of {kind} object at offset {offset} didn't match the checksum in the index file: expected {expected}, got {actual}")]
PackObjectMismatch {
expected: git_hash::ObjectId,
actual: git_hash::ObjectId,
Expand Down
16 changes: 8 additions & 8 deletions git-pack/src/index/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ pub mod checksum {
/// Various ways in which a pack and index can be verified
#[derive(Debug, Eq, PartialEq, Hash, Clone, Copy)]
pub enum Mode {
/// Validate SHA1 and CRC32
Sha1Crc32,
/// Validate SHA1 and CRC32, and decode each non-Blob object.
/// Validate the object hash and CRC32
HashCrc32,
/// Validate hash and CRC32, and decode each non-Blob object.
/// Each object should be valid, i.e. be decodable.
Sha1Crc32Decode,
/// Validate SHA1 and CRC32, and decode and encode each non-Blob object.
HashCrc32Decode,
/// Validate hash and CRC32, and decode and encode each non-Blob object.
/// Each object should yield exactly the same hash when re-encoded.
Sha1Crc32DecodeEncode,
HashCrc32DecodeEncode,
}

/// Information to allow verifying the integrity of an index with the help of its corresponding pack.
Expand Down Expand Up @@ -175,7 +175,7 @@ impl index::File {
where
P: Progress,
{
if let Mode::Sha1Crc32Decode | Mode::Sha1Crc32DecodeEncode = mode {
if let Mode::HashCrc32Decode | Mode::HashCrc32DecodeEncode = mode {
use git_object::Kind::*;
match object_kind {
Tree | Commit | Tag => {
Expand All @@ -186,7 +186,7 @@ impl index::File {
id: index_entry.oid,
}
})?;
if let Mode::Sha1Crc32DecodeEncode = mode {
if let Mode::HashCrc32DecodeEncode = mode {
encode_buf.clear();
object
.write_to(&mut *encode_buf)
Expand Down
2 changes: 1 addition & 1 deletion git-pack/tests/pack/data/output/count_and_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ fn write_and_verify(
}

bundle.verify_integrity(
pack::index::verify::Mode::Sha1Crc32DecodeEncode,
pack::index::verify::Mode::HashCrc32DecodeEncode,
pack::index::traverse::Algorithm::Lookup,
|| pack::cache::Never,
None,
Expand Down
6 changes: 3 additions & 3 deletions git-pack/tests/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ mod file {
];

static MODES: &[index::verify::Mode] = &[
index::verify::Mode::Sha1Crc32,
index::verify::Mode::Sha1Crc32Decode,
index::verify::Mode::Sha1Crc32DecodeEncode,
index::verify::Mode::HashCrc32,
index::verify::Mode::HashCrc32Decode,
index::verify::Mode::HashCrc32DecodeEncode,
];

#[test]
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Default for Context<Vec<u8>, Vec<u8>> {
Context {
output_statistics: None,
thread_limit: None,
mode: index::verify::Mode::Sha1Crc32,
mode: index::verify::Mode::HashCrc32,
algorithm: Algorithm::LessMemory,
out: Vec::new(),
err: Vec::new(),
Expand Down
6 changes: 3 additions & 3 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ pub fn main() -> Result<()> {
None,
move |progress, out, err| {
let mode = match (decode, re_encode) {
(true, false) => verify::Mode::Sha1Crc32Decode,
(true, true) | (false, true) => verify::Mode::Sha1Crc32DecodeEncode,
(false, false) => verify::Mode::Sha1Crc32,
(true, false) => verify::Mode::HashCrc32Decode,
(true, true) | (false, true) => verify::Mode::HashCrc32DecodeEncode,
(false, false) => verify::Mode::HashCrc32,
};
let output_statistics = if statistics { Some(format) } else { None };
verify::pack_or_pack_index(
Expand Down

0 comments on commit c2679a0

Please sign in to comment.