From 6945969015741a54b324056e769501fd3f42d6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Tue, 21 Apr 2026 20:34:35 +0200 Subject: [PATCH 1/8] Remove profile.release section in gix-imara-diff This fixes the following warning: ``` warning: profiles for the non root package will be ignored, specify profiles at the workspace root: package: .../gix-imara-diff/Cargo.toml workspace: .../Cargo.toml ``` --- gix-imara-diff/Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/gix-imara-diff/Cargo.toml b/gix-imara-diff/Cargo.toml index 1bb2eb1cc..52cb0376e 100644 --- a/gix-imara-diff/Cargo.toml +++ b/gix-imara-diff/Cargo.toml @@ -32,9 +32,6 @@ gix-object = { version = "^0.58.0", path = "../gix-object", features = ["sha1"] cov-mark = "2.1.0" expect-test = "1.4.0" -[profile.release] -debug = true - # [[bench]] # name = "git_repo" # harness = false From dd1fbe7775446c73686a53d49955e0ba9654a7d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Tue, 21 Apr 2026 20:35:39 +0200 Subject: [PATCH 2/8] Run gix-diff-tests with GIX_TEST_FIXTURE_HASH=sha1 as well --- justfile | 1 + 1 file changed, 1 insertion(+) diff --git a/justfile b/justfile index b507d4a2d..ce8130ace 100755 --- a/justfile +++ b/justfile @@ -224,6 +224,7 @@ unit-tests: cargo nextest run -p gix-odb-tests --features gix-features-parallel --no-fail-fast env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-pack --all-features --no-fail-fast env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-pack --all-features --no-fail-fast + env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-diff-tests --no-fail-fast env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-diff-tests --no-fail-fast cargo nextest run -p gix-pack-tests --features all-features --no-fail-fast cargo nextest run -p gix-pack-tests --features gix-features-parallel --no-fail-fast From a78304c300f1aa366f4ed86ad345df14bcf715b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Tue, 21 Apr 2026 20:38:20 +0200 Subject: [PATCH 3/8] Use GIX_TEST_FIXTURE_HASH for gix-diff --- Cargo.lock | 1 + gix-diff/Cargo.toml | 3 ++- gix-diff/src/tree/function.rs | 2 +- gix-diff/tests/diff/main.rs | 6 +++++- justfile | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 749068e37..438fba565 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1715,6 +1715,7 @@ dependencies = [ "gix-path", "gix-pathspec", "gix-tempfile", + "gix-testtools", "gix-trace", "gix-traverse", "gix-worktree", diff --git a/gix-diff/Cargo.toml b/gix-diff/Cargo.toml index 9014c156e..dc2fdf02b 100644 --- a/gix-diff/Cargo.toml +++ b/gix-diff/Cargo.toml @@ -69,7 +69,8 @@ document-features = { version = "0.2.0", optional = true } [dev-dependencies] criterion = "0.8.2" -gix-hash = { path = "../gix-hash", features = ["sha1"] } +gix-hash = { path = "../gix-hash", features = ["sha1", "sha256"] } +gix-testtools = { path = "../tests/tools" } [package.metadata.docs.rs] all-features = true diff --git a/gix-diff/src/tree/function.rs b/gix-diff/src/tree/function.rs index f9930f945..06ccd8fb2 100644 --- a/gix-diff/src/tree/function.rs +++ b/gix-diff/src/tree/function.rs @@ -425,7 +425,7 @@ mod tests { #[test] fn compare_select_samples() { - let null = gix_hash::ObjectId::null(gix_hash::Kind::Sha1); + let null = gix_hash::ObjectId::null(gix_testtools::hash_kind_from_env().unwrap_or_default()); let actual = compare( &EntryRef { mode: EntryKind::Blob.into(), diff --git a/gix-diff/tests/diff/main.rs b/gix-diff/tests/diff/main.rs index 320e030d6..cc9ae53f0 100644 --- a/gix-diff/tests/diff/main.rs +++ b/gix-diff/tests/diff/main.rs @@ -180,7 +180,11 @@ mod util { impl ObjectDb { /// Insert `data` and return its hash. That can be used to find it again. pub fn insert(&mut self, data: &str) -> Result { - let id = gix_object::compute_hash(gix_hash::Kind::Sha1, gix_object::Kind::Blob, data.as_bytes())?; + let id = gix_object::compute_hash( + gix_testtools::hash_kind_from_env().unwrap_or_default(), + gix_object::Kind::Blob, + data.as_bytes(), + )?; self.data_by_id.insert(id, data.into()); Ok(id) } diff --git a/justfile b/justfile index ce8130ace..3a22b7b73 100755 --- a/justfile +++ b/justfile @@ -201,6 +201,8 @@ unit-tests: cargo nextest run -p gix-archive --no-default-features --features tar --no-fail-fast cargo nextest run -p gix-archive --no-default-features --features tar_gz --no-fail-fast cargo nextest run -p gix-archive --no-default-features --features zip --no-fail-fast + env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-diff --no-fail-fast + env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-diff --no-fail-fast cargo nextest run -p gix-status-tests --features gix-features-parallel --no-fail-fast cargo nextest run -p gix-worktree-state-tests --features gix-features-parallel --no-fail-fast cargo nextest run -p gix-worktree-tests --features gix-features-parallel --no-fail-fast From dc6fe6b23acae9047c688c258f6e1bd34a0d0ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Fri, 24 Apr 2026 20:40:29 +0200 Subject: [PATCH 4/8] Make NULL_ID depend on fixture_hash_kind() --- gix-diff/tests/diff/rewrites/mod.rs | 18 ++++++++++-------- gix-diff/tests/diff/rewrites/tracker.rs | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gix-diff/tests/diff/rewrites/mod.rs b/gix-diff/tests/diff/rewrites/mod.rs index cbad0fc56..965b3c328 100644 --- a/gix-diff/tests/diff/rewrites/mod.rs +++ b/gix-diff/tests/diff/rewrites/mod.rs @@ -1,3 +1,5 @@ +use std::sync::LazyLock; + use gix_diff::{ rewrites::tracker::ChangeKind, tree::visit::{ChangeId, Relation}, @@ -37,12 +39,12 @@ impl gix_diff::rewrites::tracker::Change for Change { } } -const NULL_ID: gix_hash::ObjectId = gix_hash::Kind::Sha1.null(); +const NULL_ID: LazyLock = LazyLock::new(|| crate::fixture_hash_kind().null()); impl Change { fn modification() -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Modification, mode: EntryKind::Blob.into(), relation: None, @@ -50,7 +52,7 @@ impl Change { } fn deletion() -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Deletion, mode: EntryKind::Blob.into(), relation: None, @@ -58,7 +60,7 @@ impl Change { } fn addition() -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Addition, mode: EntryKind::Blob.into(), relation: None, @@ -67,7 +69,7 @@ impl Change { fn addition_in_tree(id: ChangeId) -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Addition, mode: EntryKind::Blob.into(), relation: Some(Relation::ChildOfParent(id)), @@ -76,7 +78,7 @@ impl Change { fn deletion_in_tree(id: ChangeId) -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Deletion, mode: EntryKind::Blob.into(), relation: Some(Relation::ChildOfParent(id)), @@ -85,7 +87,7 @@ impl Change { fn tree_addition(id: ChangeId) -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Addition, mode: EntryKind::Tree.into(), relation: Some(Relation::Parent(id)), @@ -94,7 +96,7 @@ impl Change { fn tree_deletion(id: ChangeId) -> Self { Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Deletion, mode: EntryKind::Tree.into(), relation: Some(Relation::Parent(id)), diff --git a/gix-diff/tests/diff/rewrites/tracker.rs b/gix-diff/tests/diff/rewrites/tracker.rs index 72d7108fc..df83b6be3 100644 --- a/gix-diff/tests/diff/rewrites/tracker.rs +++ b/gix-diff/tests/diff/rewrites/tracker.rs @@ -50,7 +50,7 @@ fn rename_by_id() -> crate::Result { src.unwrap(), Source { entry_mode: EntryKind::Blob.into(), - id: NULL_ID, + id: *NULL_ID, kind: SourceKind::Rename, location: "b".into(), change: &Change::deletion(), @@ -535,7 +535,7 @@ fn directories_without_relation_are_ignored() -> crate::Result { let mut track = util::new_tracker(Default::default()); for mode in [EntryKind::Tree, EntryKind::Commit] { let tree_without_relation = Change { - id: NULL_ID, + id: *NULL_ID, kind: ChangeKind::Deletion, mode: mode.into(), relation: None, From 8996e5a5419aebc943ddc7e03a477a2c861d2fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Fri, 24 Apr 2026 20:44:24 +0200 Subject: [PATCH 5/8] Hardcode expected SHA-256 hashes --- gix-diff/tests/diff/blob/platform.rs | 26 +- gix-diff/tests/diff/index.rs | 33 +- gix-diff/tests/diff/main.rs | 18 +- gix-diff/tests/diff/rewrites/tracker.rs | 619 +++++++++++++++++------- gix-diff/tests/diff/tree.rs | 339 +++++++++---- 5 files changed, 712 insertions(+), 323 deletions(-) diff --git a/gix-diff/tests/diff/blob/platform.rs b/gix-diff/tests/diff/blob/platform.rs index a9a40043d..e515018c1 100644 --- a/gix-diff/tests/diff/blob/platform.rs +++ b/gix-diff/tests/diff/blob/platform.rs @@ -48,7 +48,11 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { assert_eq!(new.data.as_slice().expect("present").as_bstr(), a_content); assert_eq!(new.driver_index, Some(0)); assert_eq!(new.mode, EntryKind::BlobExecutable); - assert_eq!(new.id, hex_to_id("4c469b6c8c4486fdc9ded9d597d8f6816a455707")); + let new_id = hex_to_id( + "4c469b6c8c4486fdc9ded9d597d8f6816a455707", + "061557fb6e67e1be5d41f8e83962699fce2a7d168ccfb2b5743d27ab06038da8", + ); + assert_eq!(new.id, new_id); assert_eq!(new.rela_path, "a", "location is kept directly as provided"); let out = platform.prepare_diff()?; @@ -70,7 +74,14 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { 2, 3 )), - format!("{}test a 0000000000000000000000000000000000000000 100644 4c469b6c8c4486fdc9ded9d597d8f6816a455707 100755", if !cfg!(windows) { "GIT_DIFF_PATH_COUNTER=3 GIT_DIFF_PATH_TOTAL=3 GIT_DIR=. " } else { Default::default() }), + format!( + "{}test a 0000000000000000000000000000000000000000 100644 {new_id} 100755", + if !cfg!(windows) { + "GIT_DIFF_PATH_COUNTER=3 GIT_DIFF_PATH_TOTAL=3 GIT_DIR=. " + } else { + Default::default() + } + ), "in this case, there is no rename-to field as last argument, it's based on the resource paths being different" ); @@ -95,7 +106,7 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { a_content, "despite the same content" ); - assert_eq!(new.id, hex_to_id("4c469b6c8c4486fdc9ded9d597d8f6816a455707")); + assert_eq!(new.id, new_id); assert_eq!(new.rela_path, "a"); let out = platform.prepare_diff()?; @@ -117,7 +128,14 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { 0, 1 )), - format!("{}test a 0000000000000000000000000000000000000000 100644 4c469b6c8c4486fdc9ded9d597d8f6816a455707 120000", if !cfg!(windows) { r#"GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1 GIT_DIR=. "# } else { Default::default() }), + format!( + "{}test a 0000000000000000000000000000000000000000 100644 {new_id} 120000", + if !cfg!(windows) { + r#"GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1 GIT_DIR=. "# + } else { + Default::default() + } + ), "Also obvious that symlinks are definitely special, but it's what git does as well" ); diff --git a/gix-diff/tests/diff/index.rs b/gix-diff/tests/diff/index.rs index 9c831237f..d359324e7 100644 --- a/gix-diff/tests/diff/index.rs +++ b/gix-diff/tests/diff/index.rs @@ -328,21 +328,24 @@ fn renames_by_similarity_with_limit() -> crate::Result { assert_eq!(actual_entry_modes, [Mode::FILE, Mode::FILE, Mode::FILE, Mode::FILE]); let actual_ids: Vec<_> = changes.iter().map(ChangeRef::id).collect(); - let expected_ids = match crate::fixture_hash_kind() { - gix_hash::Kind::Sha1 => [ - crate::hex_to_id("f00c965d8307308469e537302baa73048488f162"), - crate::hex_to_id("683cfcc0f47566c332aa45d81c5cc98acb4aab49"), - crate::hex_to_id("3bb459b831ea471b9cd1cbb7c6d54a74251a711b"), - crate::hex_to_id("0a805f8e02d72bd354c1f00607906de2e49e00d6"), - ], - gix_hash::Kind::Sha256 => [ - crate::hex_to_id("300fc9db3fb50e3794eb4013cfe2c9f6c0fa1d8db7f9e3a4f6f0158b3b62cc69"), - crate::hex_to_id("b863f94555dd058a680cca6d4afa1bad30b5f9c36122c7089f853081aa1c5a28"), - crate::hex_to_id("19ebb6b2c2f3a64e6578013f680ec39330ce158af5977a1b17be0d551185fbab"), - crate::hex_to_id("6271a9ad76b692e75a96d260cf02c4cd89e1d2071256447ff50e8a8f443299b4"), - ], - _ => unreachable!("tests only support sha1 and sha256 fixtures"), - }; + let expected_ids = [ + crate::hex_to_id( + "f00c965d8307308469e537302baa73048488f162", + "300fc9db3fb50e3794eb4013cfe2c9f6c0fa1d8db7f9e3a4f6f0158b3b62cc69", + ), + crate::hex_to_id( + "683cfcc0f47566c332aa45d81c5cc98acb4aab49", + "b863f94555dd058a680cca6d4afa1bad30b5f9c36122c7089f853081aa1c5a28", + ), + crate::hex_to_id( + "3bb459b831ea471b9cd1cbb7c6d54a74251a711b", + "19ebb6b2c2f3a64e6578013f680ec39330ce158af5977a1b17be0d551185fbab", + ), + crate::hex_to_id( + "0a805f8e02d72bd354c1f00607906de2e49e00d6", + "6271a9ad76b692e75a96d260cf02c4cd89e1d2071256447ff50e8a8f443299b4", + ), + ]; assert_eq!(actual_ids, expected_ids); let out = out.expect("tracking enabled"); diff --git a/gix-diff/tests/diff/main.rs b/gix-diff/tests/diff/main.rs index cc9ae53f0..f16631d81 100644 --- a/gix-diff/tests/diff/main.rs +++ b/gix-diff/tests/diff/main.rs @@ -1,8 +1,12 @@ use gix_testtools::Result; use std::collections::HashMap; -fn hex_to_id(hex: &str) -> gix_hash::ObjectId { - gix_hash::ObjectId::from_hex(hex.as_bytes()).expect("valid hex id") +fn hex_to_id(hex_sha1: &str, hex_sha256: &str) -> gix_hash::ObjectId { + match gix_testtools::hash_kind_from_env().unwrap_or_default() { + gix_hash::Kind::Sha1 => gix_hash::ObjectId::from_hex(hex_sha1.as_bytes()).expect("40 bytes hex"), + gix_hash::Kind::Sha256 => gix_hash::ObjectId::from_hex(hex_sha256.as_bytes()).expect("64 bytes hex"), + _ => unimplemented!(), + } } fn fixture_hash_kind() -> gix_hash::Kind { @@ -121,16 +125,6 @@ fn assert_hash_agnostic_patch_eq(actual: &str, expected: &str) { pretty_assertions::assert_eq!(normalize_patch_snapshot(expected), normalize_patch_snapshot(actual)); } -macro_rules! assert_hash_agnostic_eq { - ($left:expr, $right:expr $(, $($arg:tt)+)?) => {{ - pretty_assertions::assert_eq!( - crate::normalize_debug_snapshot(&($left)), - crate::normalize_debug_snapshot(&($right)) - $(, $($arg)+)? - ); - }}; -} - mod blob; mod index; mod rewrites; diff --git a/gix-diff/tests/diff/rewrites/tracker.rs b/gix-diff/tests/diff/rewrites/tracker.rs index df83b6be3..a6d3872eb 100644 --- a/gix-diff/tests/diff/rewrites/tracker.rs +++ b/gix-diff/tests/diff/rewrites/tracker.rs @@ -151,7 +151,10 @@ fn copy_by_id() -> crate::Result { let out = util::assert_emit_with_objects( &mut track, |dst, src| { - let id = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e"); + let id = hex_to_id( + "2e65efe2a145dda7ee51d1741299f848e5bf752e", + "eb337bcee2061c5313c9a1392116b6c76039e9e30d71467ae359b36277e17dc7", + ); let source_a = Source { entry_mode: EntryKind::Blob.into(), id, @@ -220,61 +223,126 @@ fn copy_by_id_search_in_all_sources() -> crate::Result { ], )?; - let mut calls = 0; - let content_id = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e"); - let out = util::assert_emit_with_objects_and_sources( - &mut track, - |dst, src| { - let source_a = Source { - entry_mode: EntryKind::Blob.into(), - id: content_id, - kind: SourceKind::Copy, - location: "a-src".into(), - change: &Change { - id: content_id, - ..Change::modification() - }, - diff: None, - }; - match calls { - 0 => { - assert_eq!(src.unwrap(), source_a); - assert_eq!( - dst.location, "a-cpy-1", - "it just finds the first possible match in order, ignoring other candidates" - ); - } - 1 => { - assert_eq!(src.unwrap(), source_a, "copy-sources can be used multiple times"); - assert_eq!(dst.location, "a-cpy-2"); - } - 2 => { - assert!(src.is_none()); - assert_eq!(dst.location, "d"); - } - _ => panic!("too many emissions"), - } - calls += 1; - std::ops::ControlFlow::Continue(()) - }, - odb, - [( - { - let mut c = Change::modification(); - c.id = content_id; - c - }, - "a-src", - )], - ); - assert_eq!( - out, - rewrites::Outcome { - options: rewrites, - ..Default::default() - }, - "no similarity check was performed, it was all matched by id" + let content_id = hex_to_id( + "2e65efe2a145dda7ee51d1741299f848e5bf752e", + "f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b", ); + + match crate::fixture_hash_kind() { + gix_hash::Kind::Sha1 => { + let mut calls = 0; + let out = util::assert_emit_with_objects_and_sources( + &mut track, + |dst, src| { + let source_a = Source { + entry_mode: EntryKind::Blob.into(), + id: content_id, + kind: SourceKind::Copy, + location: "a-src".into(), + change: &Change { + id: content_id, + ..Change::modification() + }, + diff: None, + }; + match calls { + 0 => { + assert_eq!(src.unwrap(), source_a); + assert_eq!( + dst.location, "a-cpy-1", + "it just finds the first possible match in order, ignoring other candidates" + ); + } + 1 => { + assert_eq!(src.unwrap(), source_a, "copy-sources can be used multiple times"); + assert_eq!(dst.location, "a-cpy-2"); + } + 2 => { + assert!(src.is_none()); + assert_eq!(dst.location, "d"); + } + _ => panic!("too many emissions"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + odb, + [( + { + let mut c = Change::modification(); + c.id = content_id; + c + }, + "a-src", + )], + ); + assert_eq!( + out, + rewrites::Outcome { + options: rewrites, + ..Default::default() + }, + "no similarity check was performed, it was all matched by id" + ); + } + gix_hash::Kind::Sha256 => { + let mut calls = 0; + let out = util::assert_emit_with_objects_and_sources( + &mut track, + |dst, src| { + let source_a = Source { + entry_mode: EntryKind::Blob.into(), + id: content_id, + kind: SourceKind::Copy, + location: "a-src".into(), + change: &Change { + id: content_id, + ..Change::modification() + }, + diff: None, + }; + match calls { + 0 => { + assert!(src.is_none()); + assert_eq!(dst.location, "a-cpy-1"); + } + 1 => { + assert!(src.is_none()); + assert_eq!(dst.location, "a-cpy-2"); + } + 2 => { + assert_eq!(src.unwrap(), source_a); + assert_eq!( + dst.location, "a-cpy-1", + "it just finds the first possible match in order, ignoring other candidates" + ); + } + _ => panic!("too many emissions"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + odb, + [( + { + let mut c = Change::modification(); + c.id = content_id; + c + }, + "a-src", + )], + ); + assert_eq!( + out, + rewrites::Outcome { + options: rewrites, + ..Default::default() + }, + "no similarity check was performed, it was all matched by id" + ); + } + _ => todo!(), + }; } Ok(()) } @@ -305,7 +373,10 @@ fn copy_by_50_percent_similarity() -> crate::Result { let out = util::assert_emit_with_objects( &mut track, |dst, src| { - let id = hex_to_id("78981922613b2afb6025042ff6bd878ac1994e85"); + let id = hex_to_id( + "78981922613b2afb6025042ff6bd878ac1994e85", + "f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b", + ); let source_a = Source { entry_mode: EntryKind::Blob.into(), id, @@ -477,56 +548,120 @@ fn rename_by_50_percent_similarity() -> crate::Result { ], )?; - let mut calls = 0; - let out = util::assert_emit_with_objects( - &mut track, - |dst, src| { - match calls { - 0 => { - let id = hex_to_id("66a52ee7a1d803dc57859c3e95ac9dcdc87c0164"); - assert_eq!( - src.unwrap(), - Source { - entry_mode: EntryKind::Blob.into(), - id, - kind: SourceKind::Rename, - location: "a".into(), - change: &Change { - id, - ..Change::deletion() - }, - diff: Some(DiffLineStats { - removals: 1, - insertions: 1, - before: 2, - after: 2, - similarity: 0.53846157 - }) + match crate::fixture_hash_kind() { + gix_hash::Kind::Sha1 => { + let mut calls = 0; + let out = util::assert_emit_with_objects( + &mut track, + |dst, src| { + match calls { + 0 => { + let id = hex_to_id( + "66a52ee7a1d803dc57859c3e95ac9dcdc87c0164", + "fdf2fd32de1d33ee5744979b40b07e0930a12c59dfbc5b3b6d34b807f944ba6e", + ); + assert_eq!( + src.unwrap(), + Source { + entry_mode: EntryKind::Blob.into(), + id, + kind: SourceKind::Rename, + location: "a".into(), + change: &Change { + id, + ..Change::deletion() + }, + diff: Some(DiffLineStats { + removals: 1, + insertions: 1, + before: 2, + after: 2, + similarity: 0.53846157 + }) + } + ); + assert_eq!(dst.location, "b"); } - ); - assert_eq!(dst.location, "b"); - } - 1 => { - assert!(src.is_none(), "pair already found"); - assert_eq!(dst.location, "c"); - } - _ => panic!("too many elements emitted"), - } - calls += 1; - std::ops::ControlFlow::Continue(()) - }, - odb, - ); - assert_eq!( - out, - rewrites::Outcome { - options: rewrites, - num_similarity_checks: 1, - ..Default::default() - }, - "the first attempt already yields the one pair, so it doesn't participate anymore\ + 1 => { + assert!(src.is_none(), "pair already found"); + assert_eq!(dst.location, "c"); + } + _ => panic!("too many elements emitted"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + odb, + ); + assert_eq!( + out, + rewrites::Outcome { + options: rewrites, + num_similarity_checks: 1, + ..Default::default() + }, + "the first attempt already yields the one pair, so it doesn't participate anymore\ - we don't have best candidates yet, thus only one check" - ); + ); + } + gix_hash::Kind::Sha256 => { + let mut calls = 0; + let out = util::assert_emit_with_objects( + &mut track, + |dst, src| { + match calls { + 0 => { + let id = hex_to_id( + "66a52ee7a1d803dc57859c3e95ac9dcdc87c0164", + "fdf2fd32de1d33ee5744979b40b07e0930a12c59dfbc5b3b6d34b807f944ba6e", + ); + assert_eq!( + src.unwrap(), + Source { + entry_mode: EntryKind::Blob.into(), + id, + kind: SourceKind::Rename, + location: "a".into(), + change: &Change { + id, + ..Change::deletion() + }, + diff: Some(DiffLineStats { + removals: 1, + insertions: 1, + before: 2, + after: 2, + similarity: 0.53846157 + }) + } + ); + assert_eq!(dst.location, "b"); + } + 1 => { + assert!(src.is_none(), "pair already found"); + assert_eq!(dst.location, "c"); + } + _ => panic!("too many elements emitted"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + odb, + ); + assert_eq!( + out, + rewrites::Outcome { + options: rewrites, + num_similarity_checks: 2, + ..Default::default() + }, + "the first attempt already yields the one pair, so it doesn't participate anymore\ + - we don't have best candidates yet, thus only one check" + ); + } + _ => todo!(), + }; + Ok(()) } @@ -559,7 +694,10 @@ fn directory_renames_by_id_can_fail_gracefully() -> crate::Result { }; let mut track = util::new_tracker(rename_by_similarity); let tree_dst_id = 1; - let tree_id = hex_to_id("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); + let tree_id = hex_to_id( + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + ); assert!(track .try_push_change( Change { @@ -573,7 +711,10 @@ fn directory_renames_by_id_can_fail_gracefully() -> crate::Result { .is_none()); let tree_src_id = 3; - let tree_id = hex_to_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + let tree_id = hex_to_id( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + ); assert!(track .try_push_change( Change { @@ -598,46 +739,93 @@ fn directory_renames_by_id_can_fail_gracefully() -> crate::Result { ], )?; - let mut calls = 0; - let out = util::assert_emit_with_objects( - &mut track, - |dst, src| { - match calls { - 0..=2 => { - let src = src.unwrap(); - let (expected_src, expected_dst) = - &[("d/a", "d-renamed/a"), ("d/c", "d-renamed/subdir/c"), ("a", "b")][calls]; - assert_eq!(src.location, expected_src); - assert_eq!(dst.location, expected_dst); - } - 3 => { - assert_eq!(src.unwrap().location, "d"); - assert_eq!( - dst.location, "d-renamed", - "it can now track modified and renamed directories" - ); + match crate::fixture_hash_kind() { + gix_hash::Kind::Sha1 => { + let mut calls = 0; + let out = util::assert_emit_with_objects( + &mut track, + |dst, src| { + match calls { + 0..=2 => { + let src = src.unwrap(); + let (expected_src, expected_dst) = + &[("d/a", "d-renamed/a"), ("d/c", "d-renamed/subdir/c"), ("a", "b")][calls]; + assert_eq!(src.location, expected_src); + assert_eq!(dst.location, expected_dst); + } + 3 => { + assert_eq!(src.unwrap().location, "d"); + assert_eq!( + dst.location, "d-renamed", + "it can now track modified and renamed directories" + ); + } + 4 => { + assert_eq!(src, None); + assert_eq!(dst.change.kind, ChangeKind::Deletion); + assert_eq!(dst.location, "d/subdir/d"); + } + _ => unreachable!("Should have expected emission call {calls}"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + &odb, + ); + assert_eq!( + out, + rewrites::Outcome { + options: rename_by_similarity, + num_similarity_checks: 1, + ..Default::default() } - 4 => { - assert_eq!(src, None); - assert_eq!(dst.change.kind, ChangeKind::Deletion); - assert_eq!(dst.location, "d/subdir/d"); + ); + assert_eq!(calls, 5, "Should not have too few calls"); + } + gix_hash::Kind::Sha256 => { + let mut calls = 0; + let out = util::assert_emit_with_objects( + &mut track, + |dst, src| { + match calls { + 0..=2 => { + let src = src.unwrap(); + let (expected_src, expected_dst) = + &[("d/c", "d-renamed/subdir/c"), ("d/a", "d-renamed/a"), ("a", "b")][calls]; + assert_eq!(src.location, expected_src); + assert_eq!(dst.location, expected_dst); + } + 3 => { + assert_eq!(src.unwrap().location, "d"); + assert_eq!( + dst.location, "d-renamed", + "it can now track modified and renamed directories" + ); + } + 4 => { + assert_eq!(src, None); + assert_eq!(dst.change.kind, ChangeKind::Deletion); + assert_eq!(dst.location, "d/subdir/d"); + } + _ => unreachable!("Should have expected emission call {calls}"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + &odb, + ); + assert_eq!( + out, + rewrites::Outcome { + options: rename_by_similarity, + num_similarity_checks: 2, + ..Default::default() } - _ => unreachable!("Should have expected emission call {calls}"), - } - calls += 1; - std::ops::ControlFlow::Continue(()) - }, - &odb, - ); - assert_eq!( - out, - rewrites::Outcome { - options: rename_by_similarity, - num_similarity_checks: 1, - ..Default::default() + ); + assert_eq!(calls, 5, "Should not have too few calls"); } - ); - assert_eq!(calls, 5, "Should not have too few calls"); + _ => todo!(), + } Ok(()) } @@ -658,7 +846,10 @@ fn simple_directory_rename_by_id() -> crate::Result { assert!(track .try_push_change(Change::tree_deletion(tree_src_id), "d".into()) .is_none()); - let tree_id = hex_to_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + let tree_id = hex_to_id( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + ); assert!( track .try_push_change( @@ -700,51 +891,105 @@ fn simple_directory_rename_by_id() -> crate::Result { (Change::addition(), "b", "firt\nsecond\n"), ], ); - let mut calls = 0; - let out = util::assert_emit(&mut track, |dst, src| { - match calls { - 0 => { - let src = src.unwrap(); - assert_eq!(src.location, "d"); - assert_eq!(src.entry_mode.kind(), EntryKind::Tree); - assert_eq!(src.change.relation, Some(Relation::Parent(3))); - assert_eq!(dst.location, "d-renamed", "it found the renamed directory"); - assert_eq!(dst.change.relation, Some(Relation::Parent(1))); - assert_eq!(dst.change.mode.kind(), EntryKind::Tree); - } - 1..=5 => { - let src = src.unwrap(); - let (expected_src, expected_dst) = &[ - ("d/a", "d-renamed/a"), - ("d/c", "d-renamed/c"), - ("d/b", "d-renamed/b"), - ("d/subdir", "d-renamed/subdir"), - ("d/subdir/d", "d-renamed/subdir/d"), - ][calls - 1]; - assert_eq!(src.location, expected_src); - assert_eq!(dst.location, expected_dst); - } - 6 => { - assert_eq!(src, None); - assert_eq!(dst.location, "a"); - } - 7 => { - assert_eq!(src, None); - assert_eq!(dst.location, "b"); - } - _ => unreachable!("Should have expected emission call {calls}"), + + match crate::fixture_hash_kind() { + gix_hash::Kind::Sha1 => { + let mut calls = 0; + let out = util::assert_emit(&mut track, |dst, src| { + match calls { + 0 => { + let src = src.unwrap(); + assert_eq!(src.location, "d"); + assert_eq!(src.entry_mode.kind(), EntryKind::Tree); + assert_eq!(src.change.relation, Some(Relation::Parent(3))); + assert_eq!(dst.location, "d-renamed", "it found the renamed directory"); + assert_eq!(dst.change.relation, Some(Relation::Parent(1))); + assert_eq!(dst.change.mode.kind(), EntryKind::Tree); + } + 1..=5 => { + let src = src.unwrap(); + let (expected_src, expected_dst) = &[ + ("d/a", "d-renamed/a"), + ("d/c", "d-renamed/c"), + ("d/b", "d-renamed/b"), + ("d/subdir", "d-renamed/subdir"), + ("d/subdir/d", "d-renamed/subdir/d"), + ][calls - 1]; + assert_eq!(src.location, expected_src); + assert_eq!(dst.location, expected_dst); + } + 6 => { + assert_eq!(src, None); + assert_eq!(dst.location, "a"); + } + 7 => { + assert_eq!(src, None); + assert_eq!(dst.location, "b"); + } + _ => unreachable!("Should have expected emission call {calls}"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }); + assert_eq!( + out, + rewrites::Outcome { + options: renames_by_identity, + ..Default::default() + } + ); + assert_eq!(calls, 8, "Should not have too few calls"); } - calls += 1; - std::ops::ControlFlow::Continue(()) - }); - assert_eq!( - out, - rewrites::Outcome { - options: renames_by_identity, - ..Default::default() + gix_hash::Kind::Sha256 => { + let mut calls = 0; + let out = util::assert_emit(&mut track, |dst, src| { + match calls { + 0 => { + let src = src.unwrap(); + assert_eq!(src.location, "d"); + assert_eq!(src.entry_mode.kind(), EntryKind::Tree); + assert_eq!(src.change.relation, Some(Relation::Parent(3))); + assert_eq!(dst.location, "d-renamed", "it found the renamed directory"); + assert_eq!(dst.change.relation, Some(Relation::Parent(1))); + assert_eq!(dst.change.mode.kind(), EntryKind::Tree); + } + 1..=5 => { + let src = src.unwrap(); + let (expected_src, expected_dst) = &[ + ("d/subdir/d", "d-renamed/subdir/d"), + ("d/b", "d-renamed/b"), + ("d/subdir", "d-renamed/subdir"), + ("d/c", "d-renamed/c"), + ("d/a", "d-renamed/a"), + ][calls - 1]; + assert_eq!(src.location, expected_src); + assert_eq!(dst.location, expected_dst); + } + 6 => { + assert_eq!(src, None); + assert_eq!(dst.location, "a"); + } + 7 => { + assert_eq!(src, None); + assert_eq!(dst.location, "b"); + } + _ => unreachable!("Should have expected emission call {calls}"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }); + assert_eq!( + out, + rewrites::Outcome { + options: renames_by_identity, + ..Default::default() + } + ); + assert_eq!(calls, 8, "Should not have too few calls"); } - ); - assert_eq!(calls, 8, "Should not have too few calls"); + _ => todo!(), + } + Ok(()) } diff --git a/gix-diff/tests/diff/tree.rs b/gix-diff/tests/diff/tree.rs index 8e4a55eac..f8a35db4e 100644 --- a/gix-diff/tests/diff/tree.rs +++ b/gix-diff/tests/diff/tree.rs @@ -159,34 +159,37 @@ mod changes { fn many_different_states() -> crate::Result { let db = db(None)?; let all_commits = all_commits(&db); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f added"])?, vec![Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "f".into(), relation: None }], ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f modified"])?, vec![Modification { previous_entry_mode: EntryKind::Blob.into(), - previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"), + oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"), path: "f".into() }], ":100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 28ce6a8b26aa170e1de65536fe8abe1832bd3242 M f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f deleted"])?, vec![Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"), + oid: hex_to_id( + "28ce6a8b26aa170e1de65536fe8abe1832bd3242", + "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1" + ), path: "f".into(), relation: None }], @@ -194,24 +197,24 @@ mod changes { " ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f mode modified to dir f/"])?, vec![ Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"), + oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"), path: "f".into(), relation: None }, Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7"), + oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7", "9e220e584599b9cff376b638fa71675280f4582a87138b6be425258dbb85f94c"), path: "f".into(), relation: Some(Relation::Parent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"), + oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"), path: "f/f".into(), relation: Some(Relation::ChildOfParent(1)), } @@ -220,18 +223,18 @@ mod changes { :000000 100644 0000000000000000000000000000000000000000 28ce6a8b26aa170e1de65536fe8abe1832bd3242 A f/f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["a renamed to b"])?, vec![ Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "a".into(), relation: None }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "b".into(), relation: None } @@ -242,43 +245,49 @@ mod changes { ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f/f modified"])?, vec![ Modification { previous_entry_mode: EntryKind::Tree.into(), - previous_oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7"), + previous_oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7", "9e220e584599b9cff376b638fa71675280f4582a87138b6be425258dbb85f94c"), entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("ebbe0b3000afdfd1aed15000094b59a2800328eb"), + oid: hex_to_id("ebbe0b3000afdfd1aed15000094b59a2800328eb", "ca3ee6fe1455fc077ae53f0fe7af54153feb35d52a892b1377e9c0b6828428d4"), path: "f".into() }, Modification { previous_entry_mode: EntryKind::Blob.into(), - previous_oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"), + previous_oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"), entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a"), + oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a", "ab879bd65609705434bab6bc157306769fd1053c6d86d82c89e76df9bee62809"), path: "f/f".into() }, ], ":100644 100644 28ce6a8b26aa170e1de65536fe8abe1832bd3242 13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a M f/f" ); - let tree_with_link_id = hex_to_id("7e26dba59b6336f87d1d4ae3505a2da302b91c76"); - let link_entry_oid = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e"); + let tree_with_link_id = hex_to_id( + "7e26dba59b6336f87d1d4ae3505a2da302b91c76", + "825cbacedb89cffe4fd6532846f376ab9cb8bc9e5cb399620d3592b714c2e95f", + ); + let link_entry_oid = hex_to_id( + "2e65efe2a145dda7ee51d1741299f848e5bf752e", + "eb337bcee2061c5313c9a1392116b6c76039e9e30d71467ae359b36277e17dc7", + ); let link_entry_mode = EntryKind::Link; - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f/f mode changed to link"])?, vec![ Modification { previous_entry_mode: EntryKind::Tree.into(), - previous_oid: hex_to_id("849bd76db90b65ebbd2e6d3970ca70c96ee5592c"), + previous_oid: hex_to_id("849bd76db90b65ebbd2e6d3970ca70c96ee5592c", "003781d2cca9a680f5ccfe0963614bb813dea1654968713b48a6a27490c3771e"), entry_mode: EntryKind::Tree.into(), oid: tree_with_link_id, path: "f".into() }, Modification { previous_entry_mode: EntryKind::Blob.into(), - previous_oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a"), + previous_oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a", "ab879bd65609705434bab6bc157306769fd1053c6d86d82c89e76df9bee62809"), entry_mode: link_entry_mode.into(), oid: link_entry_oid, path: "f/f".into() @@ -287,12 +296,12 @@ mod changes { ":100644 120000 13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a 2e65efe2a145dda7ee51d1741299f848e5bf752e T f/f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f/ changed into file f"])?, vec![ Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "f".into(), relation: None }, @@ -304,13 +313,13 @@ mod changes { }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "f/a".into(), relation: Some(Relation::ChildOfParent(1)) }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "f/b".into(), relation: Some(Relation::ChildOfParent(1)) }, @@ -326,42 +335,51 @@ mod changes { :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f/b :120000 000000 2e65efe2a145dda7ee51d1741299f848e5bf752e 0000000000000000000000000000000000000000 D f/f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["delete d/"])?, vec![ Deletion { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"), + oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df", "1f5422fc234c61cf503a86521bcafcb86cc48653c5d80d4e93a6cc677e345b40"), path: "d".into(), relation: Some(Relation::Parent(1)) }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "d/f".into(), relation: Some(Relation::ChildOfParent(1)) }, ], ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D d/f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["add /c /d /e"])?, vec![ Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "c".into(), relation: None, }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "d".into(), relation: None, }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "e".into(), relation: None, }, @@ -370,42 +388,51 @@ mod changes { :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A d :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A e" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["add g/a"])?, vec![ Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"), + oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba", "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"), path: "g".into(), relation: Some(Relation::Parent(1)) }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "g/a".into(), relation: Some(Relation::ChildOfParent(1)) }, ], ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A g/a" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["remove /c /d /e"])?, vec![ Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "c".into(), relation: None }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "d".into(), relation: None }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "e".into(), relation: None }, @@ -414,18 +441,18 @@ mod changes { :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D d :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D e" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["rm /f, add /ff"])?, vec![ Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "f".into(), relation: None }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "ff".into(), relation: None }, @@ -433,25 +460,25 @@ mod changes { ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A ff" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["rm g/a, add g/aa"])?, vec![ Modification { previous_entry_mode: EntryKind::Tree.into(), - previous_oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"), + previous_oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba", "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"), entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678"), + oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678", "c56aa83b78552302a7ab7c6377d8a54573a3845e10242df3eae849394ab91b53"), path: "g".into() }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "g/a".into(), relation: None }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "g/aa".into(), relation: None }, @@ -459,18 +486,18 @@ mod changes { ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D g/a :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A g/aa" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["rm /ff, add /f"])?, vec![ Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "f".into(), relation: None, }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "ff".into(), relation: None, }, @@ -478,25 +505,25 @@ mod changes { ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A ff" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["rm g/aa, add g/a"])?, vec![ Modification { previous_entry_mode: EntryKind::Tree.into(), - previous_oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678"), + previous_oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678", "c56aa83b78552302a7ab7c6377d8a54573a3845e10242df3eae849394ab91b53"), entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"), + oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba", "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"), path: "g".into() }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "g/a".into(), relation: None, }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "g/aa".into(), relation: None, }, @@ -512,39 +539,39 @@ mod changes { let db = db(["a"].iter().copied())?; let all_commits = all_commits(&db); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f added"])?, vec![ Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"), + oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df", "1f5422fc234c61cf503a86521bcafcb86cc48653c5d80d4e93a6cc677e345b40"), path: "a".into(), relation: Some(Relation::Parent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), path: "a/f".into(), relation: Some(Relation::ChildOfParent(1)), } ], ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A a/f" ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["f modified"])?, vec![ Modification { previous_entry_mode: EntryKind::Tree.into(), - previous_oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"), + previous_oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df", "1f5422fc234c61cf503a86521bcafcb86cc48653c5d80d4e93a6cc677e345b40"), entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7"), + oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7", "9e220e584599b9cff376b638fa71675280f4582a87138b6be425258dbb85f94c"), path: "a".into() }, Modification { previous_entry_mode: EntryKind::Blob.into(), - previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"), entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"), + oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"), path: "a/f".into() } ], @@ -567,47 +594,65 @@ mod changes { let last_commit = all_commits["rm g/aa, add g/a"]; let first_commit = all_commits["f added"]; - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_commits(&db, first_commit.to_owned(), &last_commit, None)?, vec![ Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "".into(), relation: None }, Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"), + oid: hex_to_id( + "496d6428b9cf92981dc9495211e6e1120fb6f2ba", + "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff" + ), path: "".into(), relation: Some(Relation::Parent(1)) }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "".into(), relation: Some(Relation::ChildOfParent(1)) } ] ); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_commits(&db, last_commit.to_owned(), &first_commit, Location::FileName.into())?, vec![ Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "b".into(), relation: None }, Deletion { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"), + oid: hex_to_id( + "496d6428b9cf92981dc9495211e6e1120fb6f2ba", + "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff" + ), path: "g".into(), relation: Some(Relation::Parent(1)) }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a".into(), relation: Some(Relation::ChildOfParent(1)) } @@ -621,54 +666,78 @@ mod changes { let db = db(["a"].iter().copied())?; let all_commits = all_commits(&db); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_commits(&db, None::, &all_commits["add g/a"], Some(Location::Path))?, vec![ Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("0df4d0ed769eacd0a231e7512fca25d3cabdeca4"), + oid: hex_to_id( + "0df4d0ed769eacd0a231e7512fca25d3cabdeca4", + "dac24a12e6d43c6ad271e7ea4f021093dac44f15f99317b2e0d54753b4f09099" + ), path: "a".into(), relation: Some(Relation::Parent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a/b".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a/c".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a/d".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a/e".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a/f".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"), + oid: hex_to_id( + "496d6428b9cf92981dc9495211e6e1120fb6f2ba", + "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff" + ), path: "a/g".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "a/g/a".into(), relation: Some(Relation::ChildOfParent(1)), } @@ -682,66 +751,96 @@ mod changes { let db = db(None)?; let all_commits = all_commits(&db); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["rename git-sec to gix-sec"])?, vec![ Deletion { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"), + oid: hex_to_id( + "d8c30fb72173778ed57fac5813c5e37038a8746c", + "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad" + ), path: "git-sec".into(), relation: Some(Relation::Parent(1)), }, Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"), + oid: hex_to_id( + "d8c30fb72173778ed57fac5813c5e37038a8746c", + "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad" + ), path: "gix-sec".into(), relation: Some(Relation::Parent(2)), }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "git-sec/2".into(), relation: Some(Relation::ChildOfParent(1)), }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "git-sec/7".into(), relation: Some(Relation::ChildOfParent(1)), }, Deletion { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"), + oid: hex_to_id( + "fd7938a0c18f993c89eda3f40a6d06fa6785833c", + "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae" + ), path: "git-sec/subdir".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "gix-sec/2".into(), relation: Some(Relation::ChildOfParent(2)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "gix-sec/7".into(), relation: Some(Relation::ChildOfParent(2)), }, Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"), + oid: hex_to_id( + "fd7938a0c18f993c89eda3f40a6d06fa6785833c", + "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae" + ), path: "gix-sec/subdir".into(), relation: Some(Relation::ChildOfParent(2)), }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "git-sec/subdir/6".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "gix-sec/subdir/6".into(), relation: Some(Relation::ChildOfParent(2)), } @@ -755,66 +854,96 @@ mod changes { let db = db(None)?; let all_commits = all_commits(&db); - assert_hash_agnostic_eq!( + pretty_assertions::assert_eq!( diff_with_previous_commit_from(&db, &all_commits["rename gix-sec to git-sec"])?, vec![ Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"), + oid: hex_to_id( + "d8c30fb72173778ed57fac5813c5e37038a8746c", + "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad" + ), path: "git-sec".into(), relation: Some(Relation::Parent(1)), }, Deletion { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"), + oid: hex_to_id( + "d8c30fb72173778ed57fac5813c5e37038a8746c", + "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad" + ), path: "gix-sec".into(), relation: Some(Relation::Parent(2)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "git-sec/2".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "git-sec/7".into(), relation: Some(Relation::ChildOfParent(1)), }, Addition { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"), + oid: hex_to_id( + "fd7938a0c18f993c89eda3f40a6d06fa6785833c", + "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae" + ), path: "git-sec/subdir".into(), relation: Some(Relation::ChildOfParent(1)), }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "gix-sec/2".into(), relation: Some(Relation::ChildOfParent(2)), }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "gix-sec/7".into(), relation: Some(Relation::ChildOfParent(2)), }, Deletion { entry_mode: EntryKind::Tree.into(), - oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"), + oid: hex_to_id( + "fd7938a0c18f993c89eda3f40a6d06fa6785833c", + "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae" + ), path: "gix-sec/subdir".into(), relation: Some(Relation::ChildOfParent(2)), }, Addition { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "git-sec/subdir/6".into(), relation: Some(Relation::ChildOfParent(1)), }, Deletion { entry_mode: EntryKind::Blob.into(), - oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"), + oid: hex_to_id( + "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", + "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813" + ), path: "gix-sec/subdir/6".into(), relation: Some(Relation::ChildOfParent(2)), } From f5859cff5978bfe42a528cfe9ce2cf61e2d79330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Fri, 24 Apr 2026 20:44:46 +0200 Subject: [PATCH 6/8] Use fixture_hash_kind() --- gix-diff/tests/diff/main.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gix-diff/tests/diff/main.rs b/gix-diff/tests/diff/main.rs index f16631d81..16e8994d3 100644 --- a/gix-diff/tests/diff/main.rs +++ b/gix-diff/tests/diff/main.rs @@ -174,11 +174,7 @@ mod util { impl ObjectDb { /// Insert `data` and return its hash. That can be used to find it again. pub fn insert(&mut self, data: &str) -> Result { - let id = gix_object::compute_hash( - gix_testtools::hash_kind_from_env().unwrap_or_default(), - gix_object::Kind::Blob, - data.as_bytes(), - )?; + let id = gix_object::compute_hash(super::fixture_hash_kind(), gix_object::Kind::Blob, data.as_bytes())?; self.data_by_id.insert(id, data.into()); Ok(id) } From 85daa235210a4c06b29d470aab1589e84ec4ae2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Fri, 24 Apr 2026 21:23:18 +0200 Subject: [PATCH 7/8] Thanks clippy --- gix-diff/tests/diff/rewrites/mod.rs | 2 +- gix-diff/tests/diff/rewrites/tracker.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gix-diff/tests/diff/rewrites/mod.rs b/gix-diff/tests/diff/rewrites/mod.rs index 965b3c328..ab8a92600 100644 --- a/gix-diff/tests/diff/rewrites/mod.rs +++ b/gix-diff/tests/diff/rewrites/mod.rs @@ -39,7 +39,7 @@ impl gix_diff::rewrites::tracker::Change for Change { } } -const NULL_ID: LazyLock = LazyLock::new(|| crate::fixture_hash_kind().null()); +static NULL_ID: LazyLock = LazyLock::new(|| crate::fixture_hash_kind().null()); impl Change { fn modification() -> Self { diff --git a/gix-diff/tests/diff/rewrites/tracker.rs b/gix-diff/tests/diff/rewrites/tracker.rs index a6d3872eb..dd092979f 100644 --- a/gix-diff/tests/diff/rewrites/tracker.rs +++ b/gix-diff/tests/diff/rewrites/tracker.rs @@ -342,7 +342,7 @@ fn copy_by_id_search_in_all_sources() -> crate::Result { ); } _ => todo!(), - }; + } } Ok(()) } @@ -660,7 +660,7 @@ fn rename_by_50_percent_similarity() -> crate::Result { ); } _ => todo!(), - }; + } Ok(()) } From 0748449d779187504bfda5e797f4583f2f5aff07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20R=C3=BC=C3=9Fler?= Date: Sat, 25 Apr 2026 09:31:08 +0200 Subject: [PATCH 8/8] Fix incorrect SHA-256 hash Collapse match as the two branches are not identical as they should have been from the start. --- gix-diff/tests/diff/rewrites/tracker.rs | 169 ++++++++---------------- 1 file changed, 54 insertions(+), 115 deletions(-) diff --git a/gix-diff/tests/diff/rewrites/tracker.rs b/gix-diff/tests/diff/rewrites/tracker.rs index dd092979f..3d7cbf06b 100644 --- a/gix-diff/tests/diff/rewrites/tracker.rs +++ b/gix-diff/tests/diff/rewrites/tracker.rs @@ -225,124 +225,63 @@ fn copy_by_id_search_in_all_sources() -> crate::Result { let content_id = hex_to_id( "2e65efe2a145dda7ee51d1741299f848e5bf752e", - "f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b", + "eb337bcee2061c5313c9a1392116b6c76039e9e30d71467ae359b36277e17dc7", ); - match crate::fixture_hash_kind() { - gix_hash::Kind::Sha1 => { - let mut calls = 0; - let out = util::assert_emit_with_objects_and_sources( - &mut track, - |dst, src| { - let source_a = Source { - entry_mode: EntryKind::Blob.into(), - id: content_id, - kind: SourceKind::Copy, - location: "a-src".into(), - change: &Change { - id: content_id, - ..Change::modification() - }, - diff: None, - }; - match calls { - 0 => { - assert_eq!(src.unwrap(), source_a); - assert_eq!( - dst.location, "a-cpy-1", - "it just finds the first possible match in order, ignoring other candidates" - ); - } - 1 => { - assert_eq!(src.unwrap(), source_a, "copy-sources can be used multiple times"); - assert_eq!(dst.location, "a-cpy-2"); - } - 2 => { - assert!(src.is_none()); - assert_eq!(dst.location, "d"); - } - _ => panic!("too many emissions"), - } - calls += 1; - std::ops::ControlFlow::Continue(()) - }, - odb, - [( - { - let mut c = Change::modification(); - c.id = content_id; - c - }, - "a-src", - )], - ); - assert_eq!( - out, - rewrites::Outcome { - options: rewrites, - ..Default::default() - }, - "no similarity check was performed, it was all matched by id" - ); - } - gix_hash::Kind::Sha256 => { - let mut calls = 0; - let out = util::assert_emit_with_objects_and_sources( - &mut track, - |dst, src| { - let source_a = Source { - entry_mode: EntryKind::Blob.into(), - id: content_id, - kind: SourceKind::Copy, - location: "a-src".into(), - change: &Change { - id: content_id, - ..Change::modification() - }, - diff: None, - }; - match calls { - 0 => { - assert!(src.is_none()); - assert_eq!(dst.location, "a-cpy-1"); - } - 1 => { - assert!(src.is_none()); - assert_eq!(dst.location, "a-cpy-2"); - } - 2 => { - assert_eq!(src.unwrap(), source_a); - assert_eq!( - dst.location, "a-cpy-1", - "it just finds the first possible match in order, ignoring other candidates" - ); - } - _ => panic!("too many emissions"), - } - calls += 1; - std::ops::ControlFlow::Continue(()) - }, - odb, - [( - { - let mut c = Change::modification(); - c.id = content_id; - c - }, - "a-src", - )], - ); - assert_eq!( - out, - rewrites::Outcome { - options: rewrites, - ..Default::default() + let mut calls = 0; + let out = util::assert_emit_with_objects_and_sources( + &mut track, + |dst, src| { + let source_a = Source { + entry_mode: EntryKind::Blob.into(), + id: content_id, + kind: SourceKind::Copy, + location: "a-src".into(), + change: &Change { + id: content_id, + ..Change::modification() }, - "no similarity check was performed, it was all matched by id" - ); - } - _ => todo!(), - } + diff: None, + }; + match calls { + 0 => { + assert_eq!(src.unwrap(), source_a); + assert_eq!( + dst.location, "a-cpy-1", + "it just finds the first possible match in order, ignoring other candidates" + ); + } + 1 => { + assert_eq!(src.unwrap(), source_a, "copy-sources can be used multiple times"); + assert_eq!(dst.location, "a-cpy-2"); + } + 2 => { + assert!(src.is_none()); + assert_eq!(dst.location, "d"); + } + _ => panic!("too many emissions"), + } + calls += 1; + std::ops::ControlFlow::Continue(()) + }, + odb, + [( + { + let mut c = Change::modification(); + c.id = content_id; + c + }, + "a-src", + )], + ); + assert_eq!( + out, + rewrites::Outcome { + options: rewrites, + ..Default::default() + }, + "no similarity check was performed, it was all matched by id" + ); } Ok(()) }