History

Merge pull request #2532 from cruessler/run-gix-diff-tests-with-sha-256

Use `GIX_TEST_FIXTURE_HASH` for `gix-diff`

Sebastian Thiel committed 6 months ago

Commit 7fbb9be2 parents 048e8df 3660cef11 files · +454 −239Browse files

Unified · Split

11 files
  1. Cargo.lock +1 −0
  2. gix-diff/Cargo.toml +2 −1
  3. gix-diff/src/tree/function.rs +1 −1
  4. gix-diff/tests/diff/blob/platform.rs +22 −4
  5. gix-diff/tests/diff/index.rs +18 −15
  6. gix-diff/tests/diff/main.rs +7 −13
  7. gix-diff/tests/diff/rewrites/mod.rs +10 −8
  8. gix-diff/tests/diff/rewrites/tracker.rs +220 −89
  9. gix-diff/tests/diff/tree.rs +170 −105
  10. gix-imara-diff/Cargo.toml +0 −3
  11. justfile +3 −0
Cargo.lock+1−0
@@ -1711,6 +1711,7 @@ dependencies = [ · 1710 unmodified lines
1711 "gix-path",1711 "gix-path",
1712 "gix-pathspec",1712 "gix-pathspec",
1713 "gix-tempfile",1713 "gix-tempfile",
1714 "gix-testtools",
1714 "gix-trace",1715 "gix-trace",
1715 "gix-traverse",1716 "gix-traverse",
1716 "gix-worktree",1717 "gix-worktree",
gix-diff/Cargo.toml+2−1
@@ -69,7 +69,8 @@ document-features = { version = "0.2.0", optional = true } · 68 unmodified lines
69 69
70[dev-dependencies]70[dev-dependencies]
71criterion = "0.8.2"71criterion = "0.8.2"
72gix-hash = { path = "../gix-hash", features = ["sha1"] }72gix-hash = { path = "../gix-hash", features = ["sha1", "sha256"] }
73gix-testtools = { path = "../tests/tools" }
73 74
74[package.metadata.docs.rs]75[package.metadata.docs.rs]
75all-features = true76all-features = true
gix-diff/src/tree/function.rs+1−1
@@ -425,7 +425,7 @@ mod tests { · 424 unmodified lines
425 425
426 #[test]426 #[test]
427 fn compare_select_samples() {427 fn compare_select_samples() {
428 let null = gix_hash::ObjectId::null(gix_hash::Kind::Sha1);428 let null = gix_testtools::hash_kind_from_env().unwrap_or_default().null();
429 let actual = compare(429 let actual = compare(
430 &EntryRef {430 &EntryRef {
431 mode: EntryKind::Blob.into(),431 mode: EntryKind::Blob.into(),
gix-diff/tests/diff/blob/platform.rs+22−4
@@ -48,7 +48,11 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { · 47 unmodified lines
48 assert_eq!(new.data.as_slice().expect("present").as_bstr(), a_content);48 assert_eq!(new.data.as_slice().expect("present").as_bstr(), a_content);
49 assert_eq!(new.driver_index, Some(0));49 assert_eq!(new.driver_index, Some(0));
50 assert_eq!(new.mode, EntryKind::BlobExecutable);50 assert_eq!(new.mode, EntryKind::BlobExecutable);
51 assert_eq!(new.id, hex_to_id("4c469b6c8c4486fdc9ded9d597d8f6816a455707"));51 let new_id = hex_to_id(
52 "4c469b6c8c4486fdc9ded9d597d8f6816a455707",
53 "061557fb6e67e1be5d41f8e83962699fce2a7d168ccfb2b5743d27ab06038da8",
54 );
55 assert_eq!(new.id, new_id);
52 assert_eq!(new.rela_path, "a", "location is kept directly as provided");56 assert_eq!(new.rela_path, "a", "location is kept directly as provided");
53 57
54 let out = platform.prepare_diff()?;58 let out = platform.prepare_diff()?;
@@ -70,7 +74,14 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { · 15 unmodified lines
70 2,74 2,
71 375 3
72 )),76 )),
73 format!("{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> 4c469b6c8c4486fdc9ded9d597d8f6816a455707 100755", if !cfg!(windows) { "GIT_DIFF_PATH_COUNTER=3 GIT_DIFF_PATH_TOTAL=3 GIT_DIR=. " } else { Default::default() }),77 format!(
78 "{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> {new_id} 100755",
79 if !cfg!(windows) {
80 "GIT_DIFF_PATH_COUNTER=3 GIT_DIFF_PATH_TOTAL=3 GIT_DIR=. "
81 } else {
82 ""
83 }
84 ),
74 "in this case, there is no rename-to field as last argument, it's based on the resource paths being different"85 "in this case, there is no rename-to field as last argument, it's based on the resource paths being different"
75 );86 );
76 87
@@ -95,7 +106,7 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { · 18 unmodified lines
95 a_content,106 a_content,
96 "despite the same content"107 "despite the same content"
97 );108 );
98 assert_eq!(new.id, hex_to_id("4c469b6c8c4486fdc9ded9d597d8f6816a455707"));109 assert_eq!(new.id, new_id);
99 assert_eq!(new.rela_path, "a");110 assert_eq!(new.rela_path, "a");
100 111
101 let out = platform.prepare_diff()?;112 let out = platform.prepare_diff()?;
@@ -117,7 +128,14 @@ fn resources_of_worktree_and_odb_and_check_link() -> crate::Result { · 15 unmodified lines
117 0,128 0,
118 1129 1
119 )),130 )),
120 format!("{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> 4c469b6c8c4486fdc9ded9d597d8f6816a455707 120000", if !cfg!(windows) { r#"GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1 GIT_DIR=. "# } else { Default::default() }),131 format!(
132 "{}test a <tmp-path> 0000000000000000000000000000000000000000 100644 <tmp-path> {new_id} 120000",
133 if !cfg!(windows) {
134 r#"GIT_DIFF_PATH_COUNTER=1 GIT_DIFF_PATH_TOTAL=1 GIT_DIR=. "#
135 } else {
136 ""
137 }
138 ),
121 "Also obvious that symlinks are definitely special, but it's what git does as well"139 "Also obvious that symlinks are definitely special, but it's what git does as well"
122 );140 );
123 141
gix-diff/tests/diff/index.rs+18−15
@@ -328,21 +328,24 @@ fn renames_by_similarity_with_limit() -> crate::Result { · 327 unmodified lines
328 assert_eq!(actual_entry_modes, [Mode::FILE, Mode::FILE, Mode::FILE, Mode::FILE]);328 assert_eq!(actual_entry_modes, [Mode::FILE, Mode::FILE, Mode::FILE, Mode::FILE]);
329 329
330 let actual_ids: Vec<_> = changes.iter().map(ChangeRef::id).collect();330 let actual_ids: Vec<_> = changes.iter().map(ChangeRef::id).collect();
331 let expected_ids = match crate::fixture_hash_kind() {331 let expected_ids = [
332 gix_hash::Kind::Sha1 => [332 crate::hex_to_id(
333 crate::hex_to_id("f00c965d8307308469e537302baa73048488f162"),333 "f00c965d8307308469e537302baa73048488f162",
334 crate::hex_to_id("683cfcc0f47566c332aa45d81c5cc98acb4aab49"),334 "300fc9db3fb50e3794eb4013cfe2c9f6c0fa1d8db7f9e3a4f6f0158b3b62cc69",
335 crate::hex_to_id("3bb459b831ea471b9cd1cbb7c6d54a74251a711b"),335 ),
336 crate::hex_to_id("0a805f8e02d72bd354c1f00607906de2e49e00d6"),336 crate::hex_to_id(
337 ],337 "683cfcc0f47566c332aa45d81c5cc98acb4aab49",
338 gix_hash::Kind::Sha256 => [338 "b863f94555dd058a680cca6d4afa1bad30b5f9c36122c7089f853081aa1c5a28",
339 crate::hex_to_id("300fc9db3fb50e3794eb4013cfe2c9f6c0fa1d8db7f9e3a4f6f0158b3b62cc69"),339 ),
340 crate::hex_to_id("b863f94555dd058a680cca6d4afa1bad30b5f9c36122c7089f853081aa1c5a28"),340 crate::hex_to_id(
341 crate::hex_to_id("19ebb6b2c2f3a64e6578013f680ec39330ce158af5977a1b17be0d551185fbab"),341 "3bb459b831ea471b9cd1cbb7c6d54a74251a711b",
342 crate::hex_to_id("6271a9ad76b692e75a96d260cf02c4cd89e1d2071256447ff50e8a8f443299b4"),342 "19ebb6b2c2f3a64e6578013f680ec39330ce158af5977a1b17be0d551185fbab",
343 ],343 ),
344 _ => unreachable!("tests only support sha1 and sha256 fixtures"),344 crate::hex_to_id(
345 };345 "0a805f8e02d72bd354c1f00607906de2e49e00d6",
346 "6271a9ad76b692e75a96d260cf02c4cd89e1d2071256447ff50e8a8f443299b4",
347 ),
348 ];
346 assert_eq!(actual_ids, expected_ids);349 assert_eq!(actual_ids, expected_ids);
347 350
348 let out = out.expect("tracking enabled");351 let out = out.expect("tracking enabled");
gix-diff/tests/diff/main.rs+7−13
@@ -1,8 +1,12 @@
1use gix_testtools::Result;1use gix_testtools::Result;
2use std::collections::HashMap;2use std::collections::HashMap;
3 3
4fn hex_to_id(hex: &str) -> gix_hash::ObjectId {4fn hex_to_id(hex_sha1: &str, hex_sha256: &str) -> gix_hash::ObjectId {
5 gix_hash::ObjectId::from_hex(hex.as_bytes()).expect("valid hex id")5 match gix_testtools::hash_kind_from_env().unwrap_or_default() {
6 gix_hash::Kind::Sha1 => gix_hash::ObjectId::from_hex(hex_sha1.as_bytes()).expect("40 bytes hex"),
7 gix_hash::Kind::Sha256 => gix_hash::ObjectId::from_hex(hex_sha256.as_bytes()).expect("64 bytes hex"),
8 _ => unimplemented!(),
9 }
6}10}
7 11
8fn fixture_hash_kind() -> gix_hash::Kind {12fn fixture_hash_kind() -> gix_hash::Kind {
@@ -121,16 +125,6 @@ fn assert_hash_agnostic_patch_eq(actual: &str, expected: &str) { · 112 unmodified lines
121 pretty_assertions::assert_eq!(normalize_patch_snapshot(expected), normalize_patch_snapshot(actual));125 pretty_assertions::assert_eq!(normalize_patch_snapshot(expected), normalize_patch_snapshot(actual));
122}126}
123 127
124macro_rules! assert_hash_agnostic_eq {
125 ($left:expr, $right:expr $(, $($arg:tt)+)?) => {{
126 pretty_assertions::assert_eq!(
127 crate::normalize_debug_snapshot(&($left)),
128 crate::normalize_debug_snapshot(&($right))
129 $(, $($arg)+)?
130 );
131 }};
132}
133
134mod blob;128mod blob;
135mod index;129mod index;
136mod rewrites;130mod rewrites;
@@ -180,7 +174,7 @@ mod util { · 43 unmodified lines
180 impl ObjectDb {174 impl ObjectDb {
181 /// Insert `data` and return its hash. That can be used to find it again.175 /// Insert `data` and return its hash. That can be used to find it again.
182 pub fn insert(&mut self, data: &str) -> Result<gix_hash::ObjectId, Error> {176 pub fn insert(&mut self, data: &str) -> Result<gix_hash::ObjectId, Error> {
183 let id = gix_object::compute_hash(gix_hash::Kind::Sha1, gix_object::Kind::Blob, data.as_bytes())?;177 let id = gix_object::compute_hash(super::fixture_hash_kind(), gix_object::Kind::Blob, data.as_bytes())?;
184 self.data_by_id.insert(id, data.into());178 self.data_by_id.insert(id, data.into());
185 Ok(id)179 Ok(id)
186 }180 }
gix-diff/tests/diff/rewrites/mod.rs+10−8
@@ -1,3 +1,5 @@
1use std::sync::LazyLock;
2
1use gix_diff::{3use gix_diff::{
2 rewrites::tracker::ChangeKind,4 rewrites::tracker::ChangeKind,
3 tree::visit::{ChangeId, Relation},5 tree::visit::{ChangeId, Relation},
@@ -37,12 +39,12 @@ impl gix_diff::rewrites::tracker::Change for Change { · 33 unmodified lines
37 }39 }
38}40}
39 41
40const NULL_ID: gix_hash::ObjectId = gix_hash::Kind::Sha1.null();42static NULL_ID: LazyLock<gix_hash::ObjectId> = LazyLock::new(|| crate::fixture_hash_kind().null());
41 43
42impl Change {44impl Change {
43 fn modification() -> Self {45 fn modification() -> Self {
44 Change {46 Change {
45 id: NULL_ID,47 id: *NULL_ID,
46 kind: ChangeKind::Modification,48 kind: ChangeKind::Modification,
47 mode: EntryKind::Blob.into(),49 mode: EntryKind::Blob.into(),
48 relation: None,50 relation: None,
@@ -50,7 +52,7 @@ impl Change { · 1 unmodified line
50 }52 }
51 fn deletion() -> Self {53 fn deletion() -> Self {
52 Change {54 Change {
53 id: NULL_ID,55 id: *NULL_ID,
54 kind: ChangeKind::Deletion,56 kind: ChangeKind::Deletion,
55 mode: EntryKind::Blob.into(),57 mode: EntryKind::Blob.into(),
56 relation: None,58 relation: None,
@@ -58,7 +60,7 @@ impl Change { · 1 unmodified line
58 }60 }
59 fn addition() -> Self {61 fn addition() -> Self {
60 Change {62 Change {
61 id: NULL_ID,63 id: *NULL_ID,
62 kind: ChangeKind::Addition,64 kind: ChangeKind::Addition,
63 mode: EntryKind::Blob.into(),65 mode: EntryKind::Blob.into(),
64 relation: None,66 relation: None,
@@ -67,7 +69,7 @@ impl Change { · 2 unmodified lines
67 69
68 fn addition_in_tree(id: ChangeId) -> Self {70 fn addition_in_tree(id: ChangeId) -> Self {
69 Change {71 Change {
70 id: NULL_ID,72 id: *NULL_ID,
71 kind: ChangeKind::Addition,73 kind: ChangeKind::Addition,
72 mode: EntryKind::Blob.into(),74 mode: EntryKind::Blob.into(),
73 relation: Some(Relation::ChildOfParent(id)),75 relation: Some(Relation::ChildOfParent(id)),
@@ -76,7 +78,7 @@ impl Change { · 2 unmodified lines
76 78
77 fn deletion_in_tree(id: ChangeId) -> Self {79 fn deletion_in_tree(id: ChangeId) -> Self {
78 Change {80 Change {
79 id: NULL_ID,81 id: *NULL_ID,
80 kind: ChangeKind::Deletion,82 kind: ChangeKind::Deletion,
81 mode: EntryKind::Blob.into(),83 mode: EntryKind::Blob.into(),
82 relation: Some(Relation::ChildOfParent(id)),84 relation: Some(Relation::ChildOfParent(id)),
@@ -85,7 +87,7 @@ impl Change { · 2 unmodified lines
85 87
86 fn tree_addition(id: ChangeId) -> Self {88 fn tree_addition(id: ChangeId) -> Self {
87 Change {89 Change {
88 id: NULL_ID,90 id: *NULL_ID,
89 kind: ChangeKind::Addition,91 kind: ChangeKind::Addition,
90 mode: EntryKind::Tree.into(),92 mode: EntryKind::Tree.into(),
91 relation: Some(Relation::Parent(id)),93 relation: Some(Relation::Parent(id)),
@@ -94,7 +96,7 @@ impl Change { · 2 unmodified lines
94 96
95 fn tree_deletion(id: ChangeId) -> Self {97 fn tree_deletion(id: ChangeId) -> Self {
96 Change {98 Change {
97 id: NULL_ID,99 id: *NULL_ID,
98 kind: ChangeKind::Deletion,100 kind: ChangeKind::Deletion,
99 mode: EntryKind::Tree.into(),101 mode: EntryKind::Tree.into(),
100 relation: Some(Relation::Parent(id)),102 relation: Some(Relation::Parent(id)),
gix-diff/tests/diff/rewrites/tracker.rs+220−89
@@ -50,7 +50,7 @@ fn rename_by_id() -> crate::Result { · 49 unmodified lines
50 src.unwrap(),50 src.unwrap(),
51 Source {51 Source {
52 entry_mode: EntryKind::Blob.into(),52 entry_mode: EntryKind::Blob.into(),
53 id: NULL_ID,53 id: *NULL_ID,
54 kind: SourceKind::Rename,54 kind: SourceKind::Rename,
55 location: "b".into(),55 location: "b".into(),
56 change: &Change::deletion(),56 change: &Change::deletion(),
@@ -151,7 +151,10 @@ fn copy_by_id() -> crate::Result { · 94 unmodified lines
151 let out = util::assert_emit_with_objects(151 let out = util::assert_emit_with_objects(
152 &mut track,152 &mut track,
153 |dst, src| {153 |dst, src| {
154 let id = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e");154 let id = hex_to_id(
155 "2e65efe2a145dda7ee51d1741299f848e5bf752e",
156 "eb337bcee2061c5313c9a1392116b6c76039e9e30d71467ae359b36277e17dc7",
157 );
155 let source_a = Source {158 let source_a = Source {
156 entry_mode: EntryKind::Blob.into(),159 entry_mode: EntryKind::Blob.into(),
157 id,160 id,
@@ -220,8 +223,12 @@ fn copy_by_id_search_in_all_sources() -> crate::Result { · 62 unmodified lines
220 ],223 ],
221 )?;224 )?;
222 225
226 let content_id = hex_to_id(
227 "2e65efe2a145dda7ee51d1741299f848e5bf752e",
228 "eb337bcee2061c5313c9a1392116b6c76039e9e30d71467ae359b36277e17dc7",
229 );
230
223 let mut calls = 0;231 let mut calls = 0;
224 let content_id = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e");
225 let out = util::assert_emit_with_objects_and_sources(232 let out = util::assert_emit_with_objects_and_sources(
226 &mut track,233 &mut track,
227 |dst, src| {234 |dst, src| {
@@ -305,7 +312,10 @@ fn copy_by_50_percent_similarity() -> crate::Result { · 77 unmodified lines
305 let out = util::assert_emit_with_objects(312 let out = util::assert_emit_with_objects(
306 &mut track,313 &mut track,
307 |dst, src| {314 |dst, src| {
308 let id = hex_to_id("78981922613b2afb6025042ff6bd878ac1994e85");315 let id = hex_to_id(
316 "78981922613b2afb6025042ff6bd878ac1994e85",
317 "f8625e43f9e04f24291f77cdbe4c71b3c2a3b0003f60419b3ed06a058d766c8b",
318 );
309 let source_a = Source {319 let source_a = Source {
310 entry_mode: EntryKind::Blob.into(),320 entry_mode: EntryKind::Blob.into(),
311 id,321 id,
@@ -483,7 +493,10 @@ fn rename_by_50_percent_similarity() -> crate::Result { · 171 unmodified lines
483 |dst, src| {493 |dst, src| {
484 match calls {494 match calls {
485 0 => {495 0 => {
486 let id = hex_to_id("66a52ee7a1d803dc57859c3e95ac9dcdc87c0164");496 let id = hex_to_id(
497 "66a52ee7a1d803dc57859c3e95ac9dcdc87c0164",
498 "fdf2fd32de1d33ee5744979b40b07e0930a12c59dfbc5b3b6d34b807f944ba6e",
499 );
487 assert_eq!(500 assert_eq!(
488 src.unwrap(),501 src.unwrap(),
489 Source {502 Source {
@@ -517,16 +530,27 @@ fn rename_by_50_percent_similarity() -> crate::Result { · 27 unmodified lines
517 },530 },
518 odb,531 odb,
519 );532 );
520 assert_eq!(533
521 out,534 // The rename tracker currently sorts by hash, hence the outcome is hash-dependent.
522 rewrites::Outcome {535 let expected = match crate::fixture_hash_kind() {
536 gix_hash::Kind::Sha1 => rewrites::Outcome {
523 options: rewrites,537 options: rewrites,
524 num_similarity_checks: 1,538 num_similarity_checks: 1,
525 ..Default::default()539 ..Default::default()
526 },540 },
541 gix_hash::Kind::Sha256 => rewrites::Outcome {
542 options: rewrites,
543 num_similarity_checks: 2,
544 ..Default::default()
545 },
546 _ => todo!(),
547 };
548 assert_eq!(
549 out, expected,
527 "the first attempt already yields the one pair, so it doesn't participate anymore\550 "the first attempt already yields the one pair, so it doesn't participate anymore\
528 - we don't have best candidates yet, thus only one check"551 - we don't have best candidates yet, thus only one check"
529 );552 );
553
530 Ok(())554 Ok(())
531}555}
532 556
@@ -535,7 +559,7 @@ fn directories_without_relation_are_ignored() -> crate::Result { · 2 unmodified lines
535 let mut track = util::new_tracker(Default::default());559 let mut track = util::new_tracker(Default::default());
536 for mode in [EntryKind::Tree, EntryKind::Commit] {560 for mode in [EntryKind::Tree, EntryKind::Commit] {
537 let tree_without_relation = Change {561 let tree_without_relation = Change {
538 id: NULL_ID,562 id: *NULL_ID,
539 kind: ChangeKind::Deletion,563 kind: ChangeKind::Deletion,
540 mode: mode.into(),564 mode: mode.into(),
541 relation: None,565 relation: None,
@@ -559,7 +583,10 @@ fn directory_renames_by_id_can_fail_gracefully() -> crate::Result { · 17 unmodified lines
559 };583 };
560 let mut track = util::new_tracker(rename_by_similarity);584 let mut track = util::new_tracker(rename_by_similarity);
561 let tree_dst_id = 1;585 let tree_dst_id = 1;
562 let tree_id = hex_to_id("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");586 let tree_id = hex_to_id(
587 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
588 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
589 );
563 assert!(track590 assert!(track
564 .try_push_change(591 .try_push_change(
565 Change {592 Change {
@@ -573,7 +600,10 @@ fn directory_renames_by_id_can_fail_gracefully() -> crate::Result { · 7 unmodified lines
573 .is_none());600 .is_none());
574 601
575 let tree_src_id = 3;602 let tree_src_id = 3;
576 let tree_id = hex_to_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");603 let tree_id = hex_to_id(
604 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
605 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
606 );
577 assert!(track607 assert!(track
578 .try_push_change(608 .try_push_change(
579 Change {609 Change {
@@ -598,45 +628,92 @@ fn directory_renames_by_id_can_fail_gracefully() -> crate::Result { · 18 unmodified lines
598 ],628 ],
599 )?;629 )?;
600 630
631 // The rename tracker currently sorts by hash, hence the outcome is hash-dependent.
601 let mut calls = 0;632 let mut calls = 0;
602 let out = util::assert_emit_with_objects(633 match crate::fixture_hash_kind() {
603 &mut track,634 gix_hash::Kind::Sha1 => {
604 |dst, src| {635 let out = util::assert_emit_with_objects(
605 match calls {636 &mut track,
606 0..=2 => {637 |dst, src| {
607 let src = src.unwrap();638 match calls {
608 let (expected_src, expected_dst) =639 0..=2 => {
609 &[("d/a", "d-renamed/a"), ("d/c", "d-renamed/subdir/c"), ("a", "b")][calls];640 let src = src.unwrap();
610 assert_eq!(src.location, expected_src);641 let (expected_src, expected_dst) =
611 assert_eq!(dst.location, expected_dst);642 &[("d/a", "d-renamed/a"), ("d/c", "d-renamed/subdir/c"), ("a", "b")][calls];
612 }643 assert_eq!(src.location, expected_src);
613 3 => {644 assert_eq!(dst.location, expected_dst);
614 assert_eq!(src.unwrap().location, "d");645 }
615 assert_eq!(646 3 => {
616 dst.location, "d-renamed",647 assert_eq!(src.unwrap().location, "d");
617 "it can now track modified and renamed directories"648 assert_eq!(
618 );649 dst.location, "d-renamed",
650 "it can now track modified and renamed directories"
651 );
652 }
653 4 => {
654 assert_eq!(src, None);
655 assert_eq!(dst.change.kind, ChangeKind::Deletion);
656 assert_eq!(dst.location, "d/subdir/d");
657 }
658 _ => unreachable!("Should have expected emission call {calls}"),
659 }
660 calls += 1;
661 std::ops::ControlFlow::Continue(())
662 },
663 &odb,
664 );
665 assert_eq!(
666 out,
667 rewrites::Outcome {
668 options: rename_by_similarity,
669 num_similarity_checks: 1,
670 ..Default::default()
619 }671 }
620 4 => {672 );
621 assert_eq!(src, None);673 }
622 assert_eq!(dst.change.kind, ChangeKind::Deletion);674 gix_hash::Kind::Sha256 => {
623 assert_eq!(dst.location, "d/subdir/d");675 let out = util::assert_emit_with_objects(
676 &mut track,
677 |dst, src| {
678 match calls {
679 0..=2 => {
680 let src = src.unwrap();
681 let (expected_src, expected_dst) =
682 &[("d/c", "d-renamed/subdir/c"), ("d/a", "d-renamed/a"), ("a", "b")][calls];
683 assert_eq!(src.location, expected_src);
684 assert_eq!(dst.location, expected_dst);
685 }
686 3 => {
687 assert_eq!(src.unwrap().location, "d");
688 assert_eq!(
689 dst.location, "d-renamed",
690 "it can now track modified and renamed directories"
691 );
692 }
693 4 => {
694 assert_eq!(src, None);
695 assert_eq!(dst.change.kind, ChangeKind::Deletion);
696 assert_eq!(dst.location, "d/subdir/d");
697 }
698 _ => unreachable!("Should have expected emission call {calls}"),
699 }
700 calls += 1;
701 std::ops::ControlFlow::Continue(())
702 },
703 &odb,
704 );
705 assert_eq!(
706 out,
707 rewrites::Outcome {
708 options: rename_by_similarity,
709 num_similarity_checks: 2,
710 ..Default::default()
624 }711 }
625 _ => unreachable!("Should have expected emission call {calls}"),712 );
626 }713 assert_eq!(calls, 5, "Should not have too few calls");
627 calls += 1;
628 std::ops::ControlFlow::Continue(())
629 },
630 &odb,
631 );
632 assert_eq!(
633 out,
634 rewrites::Outcome {
635 options: rename_by_similarity,
636 num_similarity_checks: 1,
637 ..Default::default()
638 }714 }
639 );715 _ => todo!(),
716 }
640 assert_eq!(calls, 5, "Should not have too few calls");717 assert_eq!(calls, 5, "Should not have too few calls");
641 Ok(())718 Ok(())
642}719}
@@ -658,7 +735,10 @@ fn simple_directory_rename_by_id() -> crate::Result { · 15 unmodified lines
658 assert!(track735 assert!(track
659 .try_push_change(Change::tree_deletion(tree_src_id), "d".into())736 .try_push_change(Change::tree_deletion(tree_src_id), "d".into())
660 .is_none());737 .is_none());
661 let tree_id = hex_to_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");738 let tree_id = hex_to_id(
739 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
740 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
741 );
662 assert!(742 assert!(
663 track743 track
664 .try_push_change(744 .try_push_change(
@@ -700,50 +780,101 @@ fn simple_directory_rename_by_id() -> crate::Result { · 35 unmodified lines
700 (Change::addition(), "b", "firt\nsecond\n"),780 (Change::addition(), "b", "firt\nsecond\n"),
701 ],781 ],
702 );782 );
783
703 let mut calls = 0;784 let mut calls = 0;
704 let out = util::assert_emit(&mut track, |dst, src| {785 match crate::fixture_hash_kind() {
705 match calls {786 gix_hash::Kind::Sha1 => {
706 0 => {787 let out = util::assert_emit(&mut track, |dst, src| {
707 let src = src.unwrap();788 match calls {
708 assert_eq!(src.location, "d");789 0 => {
709 assert_eq!(src.entry_mode.kind(), EntryKind::Tree);790 let src = src.unwrap();
710 assert_eq!(src.change.relation, Some(Relation::Parent(3)));791 assert_eq!(src.location, "d");
711 assert_eq!(dst.location, "d-renamed", "it found the renamed directory");792 assert_eq!(src.entry_mode.kind(), EntryKind::Tree);
712 assert_eq!(dst.change.relation, Some(Relation::Parent(1)));793 assert_eq!(src.change.relation, Some(Relation::Parent(3)));
713 assert_eq!(dst.change.mode.kind(), EntryKind::Tree);794 assert_eq!(dst.location, "d-renamed", "it found the renamed directory");
714 }795 assert_eq!(dst.change.relation, Some(Relation::Parent(1)));
715 1..=5 => {796 assert_eq!(dst.change.mode.kind(), EntryKind::Tree);
716 let src = src.unwrap();797 }
717 let (expected_src, expected_dst) = &[798 1..=5 => {
718 ("d/a", "d-renamed/a"),799 let src = src.unwrap();
719 ("d/c", "d-renamed/c"),800 let (expected_src, expected_dst) = &[
720 ("d/b", "d-renamed/b"),801 ("d/a", "d-renamed/a"),
721 ("d/subdir", "d-renamed/subdir"),802 ("d/c", "d-renamed/c"),
722 ("d/subdir/d", "d-renamed/subdir/d"),803 ("d/b", "d-renamed/b"),
723 ][calls - 1];804 ("d/subdir", "d-renamed/subdir"),
724 assert_eq!(src.location, expected_src);805 ("d/subdir/d", "d-renamed/subdir/d"),
725 assert_eq!(dst.location, expected_dst);806 ][calls - 1];
726 }807 assert_eq!(src.location, expected_src);
727 6 => {808 assert_eq!(dst.location, expected_dst);
728 assert_eq!(src, None);809 }
729 assert_eq!(dst.location, "a");810 6 => {
730 }811 assert_eq!(src, None);
731 7 => {812 assert_eq!(dst.location, "a");
732 assert_eq!(src, None);813 }
733 assert_eq!(dst.location, "b");814 7 => {
734 }815 assert_eq!(src, None);
735 _ => unreachable!("Should have expected emission call {calls}"),816 assert_eq!(dst.location, "b");
817 }
818 _ => unreachable!("Should have expected emission call {calls}"),
819 }
820 calls += 1;
821 std::ops::ControlFlow::Continue(())
822 });
823 assert_eq!(
824 out,
825 rewrites::Outcome {
826 options: renames_by_identity,
827 ..Default::default()
828 }
829 );
736 }830 }
737 calls += 1;831 gix_hash::Kind::Sha256 => {
738 std::ops::ControlFlow::Continue(())832 let out = util::assert_emit(&mut track, |dst, src| {
739 });833 match calls {
740 assert_eq!(834 0 => {
741 out,835 let src = src.unwrap();
742 rewrites::Outcome {836 assert_eq!(src.location, "d");
743 options: renames_by_identity,837 assert_eq!(src.entry_mode.kind(), EntryKind::Tree);
744 ..Default::default()838 assert_eq!(src.change.relation, Some(Relation::Parent(3)));
839 assert_eq!(dst.location, "d-renamed", "it found the renamed directory");
840 assert_eq!(dst.change.relation, Some(Relation::Parent(1)));
841 assert_eq!(dst.change.mode.kind(), EntryKind::Tree);
842 }
843 1..=5 => {
844 let src = src.unwrap();
845 let (expected_src, expected_dst) = &[
846 ("d/subdir/d", "d-renamed/subdir/d"),
847 ("d/b", "d-renamed/b"),
848 ("d/subdir", "d-renamed/subdir"),
849 ("d/c", "d-renamed/c"),
850 ("d/a", "d-renamed/a"),
851 ][calls - 1];
852 assert_eq!(src.location, expected_src);
853 assert_eq!(dst.location, expected_dst);
854 }
855 6 => {
856 assert_eq!(src, None);
857 assert_eq!(dst.location, "a");
858 }
859 7 => {
860 assert_eq!(src, None);
861 assert_eq!(dst.location, "b");
862 }
863 _ => unreachable!("Should have expected emission call {calls}"),
864 }
865 calls += 1;
866 std::ops::ControlFlow::Continue(())
867 });
868 assert_eq!(
869 out,
870 rewrites::Outcome {
871 options: renames_by_identity,
872 ..Default::default()
873 }
874 );
745 }875 }
746 );876 _ => todo!(),
877 }
747 assert_eq!(calls, 8, "Should not have too few calls");878 assert_eq!(calls, 8, "Should not have too few calls");
748 Ok(())879 Ok(())
749}880}
gix-diff/tests/diff/tree.rs+170−105
@@ -159,34 +159,37 @@ mod changes { · 158 unmodified lines
159 fn many_different_states() -> crate::Result {159 fn many_different_states() -> crate::Result {
160 let db = db(None)?;160 let db = db(None)?;
161 let all_commits = all_commits(&db);161 let all_commits = all_commits(&db);
162 assert_hash_agnostic_eq!(162 pretty_assertions::assert_eq!(
163 diff_with_previous_commit_from(&db, &all_commits["f added"])?,163 diff_with_previous_commit_from(&db, &all_commits["f added"])?,
164 vec![Addition {164 vec![Addition {
165 entry_mode: EntryKind::Blob.into(),165 entry_mode: EntryKind::Blob.into(),
166 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),166 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
167 path: "f".into(),167 path: "f".into(),
168 relation: None168 relation: None
169 }],169 }],
170 ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A f"170 ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A f"
171 );171 );
172 172
173 assert_hash_agnostic_eq!(173 pretty_assertions::assert_eq!(
174 diff_with_previous_commit_from(&db, &all_commits["f modified"])?,174 diff_with_previous_commit_from(&db, &all_commits["f modified"])?,
175 vec![Modification {175 vec![Modification {
176 previous_entry_mode: EntryKind::Blob.into(),176 previous_entry_mode: EntryKind::Blob.into(),
177 previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),177 previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
178 entry_mode: EntryKind::Blob.into(),178 entry_mode: EntryKind::Blob.into(),
179 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"),179 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"),
180 path: "f".into()180 path: "f".into()
181 }],181 }],
182 ":100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 28ce6a8b26aa170e1de65536fe8abe1832bd3242 M f"182 ":100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 28ce6a8b26aa170e1de65536fe8abe1832bd3242 M f"
183 );183 );
184 184
185 assert_hash_agnostic_eq!(185 pretty_assertions::assert_eq!(
186 diff_with_previous_commit_from(&db, &all_commits["f deleted"])?,186 diff_with_previous_commit_from(&db, &all_commits["f deleted"])?,
187 vec![Deletion {187 vec![Deletion {
188 entry_mode: EntryKind::Blob.into(),188 entry_mode: EntryKind::Blob.into(),
189 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"),189 oid: hex_to_id(
190 "28ce6a8b26aa170e1de65536fe8abe1832bd3242",
191 "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"
192 ),
190 path: "f".into(),193 path: "f".into(),
191 relation: None194 relation: None
192 }],195 }],
@@ -194,24 +197,24 @@ mod changes { · 1 unmodified line
194 "197 "
195 );198 );
196 199
197 assert_hash_agnostic_eq!(200 pretty_assertions::assert_eq!(
198 diff_with_previous_commit_from(&db, &all_commits["f mode modified to dir f/"])?,201 diff_with_previous_commit_from(&db, &all_commits["f mode modified to dir f/"])?,
199 vec![202 vec![
200 Deletion {203 Deletion {
201 entry_mode: EntryKind::Blob.into(),204 entry_mode: EntryKind::Blob.into(),
202 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"),205 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"),
203 path: "f".into(),206 path: "f".into(),
204 relation: None207 relation: None
205 },208 },
206 Addition {209 Addition {
207 entry_mode: EntryKind::Tree.into(),210 entry_mode: EntryKind::Tree.into(),
208 oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7"),211 oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7", "9e220e584599b9cff376b638fa71675280f4582a87138b6be425258dbb85f94c"),
209 path: "f".into(),212 path: "f".into(),
210 relation: Some(Relation::Parent(1)),213 relation: Some(Relation::Parent(1)),
211 },214 },
212 Addition {215 Addition {
213 entry_mode: EntryKind::Blob.into(),216 entry_mode: EntryKind::Blob.into(),
214 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"),217 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"),
215 path: "f/f".into(),218 path: "f/f".into(),
216 relation: Some(Relation::ChildOfParent(1)),219 relation: Some(Relation::ChildOfParent(1)),
217 }220 }
@@ -220,18 +223,18 @@ mod changes { · 2 unmodified lines
220 :000000 100644 0000000000000000000000000000000000000000 28ce6a8b26aa170e1de65536fe8abe1832bd3242 A f/f"223 :000000 100644 0000000000000000000000000000000000000000 28ce6a8b26aa170e1de65536fe8abe1832bd3242 A f/f"
221 );224 );
222 225
223 assert_hash_agnostic_eq!(226 pretty_assertions::assert_eq!(
224 diff_with_previous_commit_from(&db, &all_commits["a renamed to b"])?,227 diff_with_previous_commit_from(&db, &all_commits["a renamed to b"])?,
225 vec![228 vec![
226 Deletion {229 Deletion {
227 entry_mode: EntryKind::Blob.into(),230 entry_mode: EntryKind::Blob.into(),
228 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),231 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
229 path: "a".into(),232 path: "a".into(),
230 relation: None233 relation: None
231 },234 },
232 Addition {235 Addition {
233 entry_mode: EntryKind::Blob.into(),236 entry_mode: EntryKind::Blob.into(),
234 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),237 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
235 path: "b".into(),238 path: "b".into(),
236 relation: None239 relation: None
237 }240 }
@@ -242,43 +245,49 @@ mod changes { · 4 unmodified lines
242 245
243 );246 );
244 247
245 assert_hash_agnostic_eq!(248 pretty_assertions::assert_eq!(
246 diff_with_previous_commit_from(&db, &all_commits["f/f modified"])?,249 diff_with_previous_commit_from(&db, &all_commits["f/f modified"])?,
247 vec![250 vec![
248 Modification {251 Modification {
249 previous_entry_mode: EntryKind::Tree.into(),252 previous_entry_mode: EntryKind::Tree.into(),
250 previous_oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7"),253 previous_oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7", "9e220e584599b9cff376b638fa71675280f4582a87138b6be425258dbb85f94c"),
251 entry_mode: EntryKind::Tree.into(),254 entry_mode: EntryKind::Tree.into(),
252 oid: hex_to_id("ebbe0b3000afdfd1aed15000094b59a2800328eb"),255 oid: hex_to_id("ebbe0b3000afdfd1aed15000094b59a2800328eb", "ca3ee6fe1455fc077ae53f0fe7af54153feb35d52a892b1377e9c0b6828428d4"),
253 path: "f".into()256 path: "f".into()
254 },257 },
255 Modification {258 Modification {
256 previous_entry_mode: EntryKind::Blob.into(),259 previous_entry_mode: EntryKind::Blob.into(),
257 previous_oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"),260 previous_oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"),
258 entry_mode: EntryKind::Blob.into(),261 entry_mode: EntryKind::Blob.into(),
259 oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a"),262 oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a", "ab879bd65609705434bab6bc157306769fd1053c6d86d82c89e76df9bee62809"),
260 path: "f/f".into()263 path: "f/f".into()
261 },264 },
262 ],265 ],
263 ":100644 100644 28ce6a8b26aa170e1de65536fe8abe1832bd3242 13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a M f/f"266 ":100644 100644 28ce6a8b26aa170e1de65536fe8abe1832bd3242 13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a M f/f"
264 );267 );
265 268
266 let tree_with_link_id = hex_to_id("7e26dba59b6336f87d1d4ae3505a2da302b91c76");269 let tree_with_link_id = hex_to_id(
267 let link_entry_oid = hex_to_id("2e65efe2a145dda7ee51d1741299f848e5bf752e");270 "7e26dba59b6336f87d1d4ae3505a2da302b91c76",
271 "825cbacedb89cffe4fd6532846f376ab9cb8bc9e5cb399620d3592b714c2e95f",
272 );
273 let link_entry_oid = hex_to_id(
274 "2e65efe2a145dda7ee51d1741299f848e5bf752e",
275 "eb337bcee2061c5313c9a1392116b6c76039e9e30d71467ae359b36277e17dc7",
276 );
268 let link_entry_mode = EntryKind::Link;277 let link_entry_mode = EntryKind::Link;
269 assert_hash_agnostic_eq!(278 pretty_assertions::assert_eq!(
270 diff_with_previous_commit_from(&db, &all_commits["f/f mode changed to link"])?,279 diff_with_previous_commit_from(&db, &all_commits["f/f mode changed to link"])?,
271 vec![280 vec![
272 Modification {281 Modification {
273 previous_entry_mode: EntryKind::Tree.into(),282 previous_entry_mode: EntryKind::Tree.into(),
274 previous_oid: hex_to_id("849bd76db90b65ebbd2e6d3970ca70c96ee5592c"),283 previous_oid: hex_to_id("849bd76db90b65ebbd2e6d3970ca70c96ee5592c", "003781d2cca9a680f5ccfe0963614bb813dea1654968713b48a6a27490c3771e"),
275 entry_mode: EntryKind::Tree.into(),284 entry_mode: EntryKind::Tree.into(),
276 oid: tree_with_link_id,285 oid: tree_with_link_id,
277 path: "f".into()286 path: "f".into()
278 },287 },
279 Modification {288 Modification {
280 previous_entry_mode: EntryKind::Blob.into(),289 previous_entry_mode: EntryKind::Blob.into(),
281 previous_oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a"),290 previous_oid: hex_to_id("13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a", "ab879bd65609705434bab6bc157306769fd1053c6d86d82c89e76df9bee62809"),
282 entry_mode: link_entry_mode.into(),291 entry_mode: link_entry_mode.into(),
283 oid: link_entry_oid,292 oid: link_entry_oid,
284 path: "f/f".into()293 path: "f/f".into()
@@ -287,12 +296,12 @@ mod changes { · 2 unmodified lines
287 ":100644 120000 13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a 2e65efe2a145dda7ee51d1741299f848e5bf752e T f/f"296 ":100644 120000 13c2aca72ab576cb5f22dc8e7f8ba8ddab553a8a 2e65efe2a145dda7ee51d1741299f848e5bf752e T f/f"
288 );297 );
289 298
290 assert_hash_agnostic_eq!(299 pretty_assertions::assert_eq!(
291 diff_with_previous_commit_from(&db, &all_commits["f/ changed into file f"])?,300 diff_with_previous_commit_from(&db, &all_commits["f/ changed into file f"])?,
292 vec![301 vec![
293 Addition {302 Addition {
294 entry_mode: EntryKind::Blob.into(),303 entry_mode: EntryKind::Blob.into(),
295 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),304 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
296 path: "f".into(),305 path: "f".into(),
297 relation: None306 relation: None
298 },307 },
@@ -304,13 +313,13 @@ mod changes { · 5 unmodified lines
304 },313 },
305 Deletion {314 Deletion {
306 entry_mode: EntryKind::Blob.into(),315 entry_mode: EntryKind::Blob.into(),
307 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),316 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
308 path: "f/a".into(),317 path: "f/a".into(),
309 relation: Some(Relation::ChildOfParent(1))318 relation: Some(Relation::ChildOfParent(1))
310 },319 },
311 Deletion {320 Deletion {
312 entry_mode: EntryKind::Blob.into(),321 entry_mode: EntryKind::Blob.into(),
313 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),322 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
314 path: "f/b".into(),323 path: "f/b".into(),
315 relation: Some(Relation::ChildOfParent(1))324 relation: Some(Relation::ChildOfParent(1))
316 },325 },
@@ -326,42 +335,46 @@ mod changes { · 9 unmodified lines
326 :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f/b335 :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f/b
327 :120000 000000 2e65efe2a145dda7ee51d1741299f848e5bf752e 0000000000000000000000000000000000000000 D f/f"336 :120000 000000 2e65efe2a145dda7ee51d1741299f848e5bf752e 0000000000000000000000000000000000000000 D f/f"
328 );337 );
329 assert_hash_agnostic_eq!(338 pretty_assertions::assert_eq!(
330 diff_with_previous_commit_from(&db, &all_commits["delete d/"])?,339 diff_with_previous_commit_from(&db, &all_commits["delete d/"])?,
331 vec![340 vec![
332 Deletion {341 Deletion {
333 entry_mode: EntryKind::Tree.into(),342 entry_mode: EntryKind::Tree.into(),
334 oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"),343 oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df", "1f5422fc234c61cf503a86521bcafcb86cc48653c5d80d4e93a6cc677e345b40"),
335 path: "d".into(),344 path: "d".into(),
336 relation: Some(Relation::Parent(1))345 relation: Some(Relation::Parent(1))
337 },346 },
338 Deletion {347 Deletion {
339 entry_mode: EntryKind::Blob.into(),348 entry_mode: EntryKind::Blob.into(),
340 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),349 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
341 path: "d/f".into(),350 path: "d/f".into(),
342 relation: Some(Relation::ChildOfParent(1))351 relation: Some(Relation::ChildOfParent(1))
343 },352 },
344 ],353 ],
345 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D d/f"354 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D d/f"
346 );355 );
347 assert_hash_agnostic_eq!(356 let empty_blob_id = hex_to_id(
357 "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
358 "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
359 );
360 pretty_assertions::assert_eq!(
348 diff_with_previous_commit_from(&db, &all_commits["add /c /d /e"])?,361 diff_with_previous_commit_from(&db, &all_commits["add /c /d /e"])?,
349 vec![362 vec![
350 Addition {363 Addition {
351 entry_mode: EntryKind::Blob.into(),364 entry_mode: EntryKind::Blob.into(),
352 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),365 oid: empty_blob_id,
353 path: "c".into(),366 path: "c".into(),
354 relation: None,367 relation: None,
355 },368 },
356 Addition {369 Addition {
357 entry_mode: EntryKind::Blob.into(),370 entry_mode: EntryKind::Blob.into(),
358 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),371 oid: empty_blob_id,
359 path: "d".into(),372 path: "d".into(),
360 relation: None,373 relation: None,
361 },374 },
362 Addition {375 Addition {
363 entry_mode: EntryKind::Blob.into(),376 entry_mode: EntryKind::Blob.into(),
364 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),377 oid: empty_blob_id,
365 path: "e".into(),378 path: "e".into(),
366 relation: None,379 relation: None,
367 },380 },
@@ -370,42 +383,42 @@ mod changes { · 2 unmodified lines
370 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A d383 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A d
371 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A e"384 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A e"
372 );385 );
373 assert_hash_agnostic_eq!(386 pretty_assertions::assert_eq!(
374 diff_with_previous_commit_from(&db, &all_commits["add g/a"])?,387 diff_with_previous_commit_from(&db, &all_commits["add g/a"])?,
375 vec![388 vec![
376 Addition {389 Addition {
377 entry_mode: EntryKind::Tree.into(),390 entry_mode: EntryKind::Tree.into(),
378 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"),391 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba", "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"),
379 path: "g".into(),392 path: "g".into(),
380 relation: Some(Relation::Parent(1))393 relation: Some(Relation::Parent(1))
381 },394 },
382 Addition {395 Addition {
383 entry_mode: EntryKind::Blob.into(),396 entry_mode: EntryKind::Blob.into(),
384 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),397 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
385 path: "g/a".into(),398 path: "g/a".into(),
386 relation: Some(Relation::ChildOfParent(1))399 relation: Some(Relation::ChildOfParent(1))
387 },400 },
388 ],401 ],
389 ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A g/a"402 ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A g/a"
390 );403 );
391 assert_hash_agnostic_eq!(404 pretty_assertions::assert_eq!(
392 diff_with_previous_commit_from(&db, &all_commits["remove /c /d /e"])?,405 diff_with_previous_commit_from(&db, &all_commits["remove /c /d /e"])?,
393 vec![406 vec![
394 Deletion {407 Deletion {
395 entry_mode: EntryKind::Blob.into(),408 entry_mode: EntryKind::Blob.into(),
396 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),409 oid: empty_blob_id,
397 path: "c".into(),410 path: "c".into(),
398 relation: None411 relation: None
399 },412 },
400 Deletion {413 Deletion {
401 entry_mode: EntryKind::Blob.into(),414 entry_mode: EntryKind::Blob.into(),
402 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),415 oid: empty_blob_id,
403 path: "d".into(),416 path: "d".into(),
404 relation: None417 relation: None
405 },418 },
406 Deletion {419 Deletion {
407 entry_mode: EntryKind::Blob.into(),420 entry_mode: EntryKind::Blob.into(),
408 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),421 oid: empty_blob_id,
409 path: "e".into(),422 path: "e".into(),
410 relation: None423 relation: None
411 },424 },
@@ -414,18 +427,18 @@ mod changes { · 2 unmodified lines
414 :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D d427 :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D d
415 :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D e"428 :100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D e"
416 );429 );
417 assert_hash_agnostic_eq!(430 pretty_assertions::assert_eq!(
418 diff_with_previous_commit_from(&db, &all_commits["rm /f, add /ff"])?,431 diff_with_previous_commit_from(&db, &all_commits["rm /f, add /ff"])?,
419 vec![432 vec![
420 Deletion {433 Deletion {
421 entry_mode: EntryKind::Blob.into(),434 entry_mode: EntryKind::Blob.into(),
422 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),435 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
423 path: "f".into(),436 path: "f".into(),
424 relation: None437 relation: None
425 },438 },
426 Addition {439 Addition {
427 entry_mode: EntryKind::Blob.into(),440 entry_mode: EntryKind::Blob.into(),
428 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),441 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
429 path: "ff".into(),442 path: "ff".into(),
430 relation: None443 relation: None
431 },444 },
@@ -433,25 +446,25 @@ mod changes { · 1 unmodified line
433 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f446 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f
434 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A ff"447 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A ff"
435 );448 );
436 assert_hash_agnostic_eq!(449 pretty_assertions::assert_eq!(
437 diff_with_previous_commit_from(&db, &all_commits["rm g/a, add g/aa"])?,450 diff_with_previous_commit_from(&db, &all_commits["rm g/a, add g/aa"])?,
438 vec![451 vec![
439 Modification {452 Modification {
440 previous_entry_mode: EntryKind::Tree.into(),453 previous_entry_mode: EntryKind::Tree.into(),
441 previous_oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"),454 previous_oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba", "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"),
442 entry_mode: EntryKind::Tree.into(),455 entry_mode: EntryKind::Tree.into(),
443 oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678"),456 oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678", "c56aa83b78552302a7ab7c6377d8a54573a3845e10242df3eae849394ab91b53"),
444 path: "g".into()457 path: "g".into()
445 },458 },
446 Deletion {459 Deletion {
447 entry_mode: EntryKind::Blob.into(),460 entry_mode: EntryKind::Blob.into(),
448 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),461 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
449 path: "g/a".into(),462 path: "g/a".into(),
450 relation: None463 relation: None
451 },464 },
452 Addition {465 Addition {
453 entry_mode: EntryKind::Blob.into(),466 entry_mode: EntryKind::Blob.into(),
454 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),467 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
455 path: "g/aa".into(),468 path: "g/aa".into(),
456 relation: None469 relation: None
457 },470 },
@@ -459,18 +472,18 @@ mod changes { · 1 unmodified line
459 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D g/a472 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D g/a
460 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A g/aa"473 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A g/aa"
461 );474 );
462 assert_hash_agnostic_eq!(475 pretty_assertions::assert_eq!(
463 diff_with_previous_commit_from(&db, &all_commits["rm /ff, add /f"])?,476 diff_with_previous_commit_from(&db, &all_commits["rm /ff, add /f"])?,
464 vec![477 vec![
465 Addition {478 Addition {
466 entry_mode: EntryKind::Blob.into(),479 entry_mode: EntryKind::Blob.into(),
467 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),480 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
468 path: "f".into(),481 path: "f".into(),
469 relation: None,482 relation: None,
470 },483 },
471 Deletion {484 Deletion {
472 entry_mode: EntryKind::Blob.into(),485 entry_mode: EntryKind::Blob.into(),
473 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),486 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
474 path: "ff".into(),487 path: "ff".into(),
475 relation: None,488 relation: None,
476 },489 },
@@ -478,25 +491,25 @@ mod changes { · 1 unmodified line
478 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f491 ":100644 000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 D f
479 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A ff"492 :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A ff"
480 );493 );
481 assert_hash_agnostic_eq!(494 pretty_assertions::assert_eq!(
482 diff_with_previous_commit_from(&db, &all_commits["rm g/aa, add g/a"])?,495 diff_with_previous_commit_from(&db, &all_commits["rm g/aa, add g/a"])?,
483 vec![496 vec![
484 Modification {497 Modification {
485 previous_entry_mode: EntryKind::Tree.into(),498 previous_entry_mode: EntryKind::Tree.into(),
486 previous_oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678"),499 previous_oid: hex_to_id("6e5931346904b020301f74f581142826eacc4678", "c56aa83b78552302a7ab7c6377d8a54573a3845e10242df3eae849394ab91b53"),
487 entry_mode: EntryKind::Tree.into(),500 entry_mode: EntryKind::Tree.into(),
488 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"),501 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba", "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"),
489 path: "g".into()502 path: "g".into()
490 },503 },
491 Addition {504 Addition {
492 entry_mode: EntryKind::Blob.into(),505 entry_mode: EntryKind::Blob.into(),
493 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),506 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
494 path: "g/a".into(),507 path: "g/a".into(),
495 relation: None,508 relation: None,
496 },509 },
497 Deletion {510 Deletion {
498 entry_mode: EntryKind::Blob.into(),511 entry_mode: EntryKind::Blob.into(),
499 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),512 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
500 path: "g/aa".into(),513 path: "g/aa".into(),
501 relation: None,514 relation: None,
502 },515 },
@@ -512,39 +525,39 @@ mod changes { · 9 unmodified lines
512 let db = db(["a"].iter().copied())?;525 let db = db(["a"].iter().copied())?;
513 let all_commits = all_commits(&db);526 let all_commits = all_commits(&db);
514 527
515 assert_hash_agnostic_eq!(528 pretty_assertions::assert_eq!(
516 diff_with_previous_commit_from(&db, &all_commits["f added"])?,529 diff_with_previous_commit_from(&db, &all_commits["f added"])?,
517 vec![530 vec![
518 Addition {531 Addition {
519 entry_mode: EntryKind::Tree.into(),532 entry_mode: EntryKind::Tree.into(),
520 oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"),533 oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df", "1f5422fc234c61cf503a86521bcafcb86cc48653c5d80d4e93a6cc677e345b40"),
521 path: "a".into(),534 path: "a".into(),
522 relation: Some(Relation::Parent(1)),535 relation: Some(Relation::Parent(1)),
523 },536 },
524 Addition {537 Addition {
525 entry_mode: EntryKind::Blob.into(),538 entry_mode: EntryKind::Blob.into(),
526 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),539 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
527 path: "a/f".into(),540 path: "a/f".into(),
528 relation: Some(Relation::ChildOfParent(1)),541 relation: Some(Relation::ChildOfParent(1)),
529 }542 }
530 ],543 ],
531 ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A a/f"544 ":000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A a/f"
532 );545 );
533 assert_hash_agnostic_eq!(546 pretty_assertions::assert_eq!(
534 diff_with_previous_commit_from(&db, &all_commits["f modified"])?,547 diff_with_previous_commit_from(&db, &all_commits["f modified"])?,
535 vec![548 vec![
536 Modification {549 Modification {
537 previous_entry_mode: EntryKind::Tree.into(),550 previous_entry_mode: EntryKind::Tree.into(),
538 previous_oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df"),551 previous_oid: hex_to_id("3d5a503f4062d198b443db5065ca727f8354e7df", "1f5422fc234c61cf503a86521bcafcb86cc48653c5d80d4e93a6cc677e345b40"),
539 entry_mode: EntryKind::Tree.into(),552 entry_mode: EntryKind::Tree.into(),
540 oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7"),553 oid: hex_to_id("10f2f4b82222d2b5c31985130979a91fd87410f7", "9e220e584599b9cff376b638fa71675280f4582a87138b6be425258dbb85f94c"),
541 path: "a".into()554 path: "a".into()
542 },555 },
543 Modification {556 Modification {
544 previous_entry_mode: EntryKind::Blob.into(),557 previous_entry_mode: EntryKind::Blob.into(),
545 previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),558 previous_oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813"),
546 entry_mode: EntryKind::Blob.into(),559 entry_mode: EntryKind::Blob.into(),
547 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242"),560 oid: hex_to_id("28ce6a8b26aa170e1de65536fe8abe1832bd3242", "6ca8d4e3bc5df874055e542d18505b5a5efa0fb7d65776efedc13781073ed0f1"),
548 path: "a/f".into()561 path: "a/f".into()
549 }562 }
550 ],563 ],
@@ -567,47 +580,57 @@ mod changes { · 16 unmodified lines
567 580
568 let last_commit = all_commits["rm g/aa, add g/a"];581 let last_commit = all_commits["rm g/aa, add g/a"];
569 let first_commit = all_commits["f added"];582 let first_commit = all_commits["f added"];
570 assert_hash_agnostic_eq!(583 let empty_blob_id = hex_to_id(
584 "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
585 "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
586 );
587 pretty_assertions::assert_eq!(
571 diff_commits(&db, first_commit.to_owned(), &last_commit, None)?,588 diff_commits(&db, first_commit.to_owned(), &last_commit, None)?,
572 vec![589 vec![
573 Addition {590 Addition {
574 entry_mode: EntryKind::Blob.into(),591 entry_mode: EntryKind::Blob.into(),
575 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),592 oid: empty_blob_id,
576 path: "".into(),593 path: "".into(),
577 relation: None594 relation: None
578 },595 },
579 Addition {596 Addition {
580 entry_mode: EntryKind::Tree.into(),597 entry_mode: EntryKind::Tree.into(),
581 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"),598 oid: hex_to_id(
599 "496d6428b9cf92981dc9495211e6e1120fb6f2ba",
600 "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"
601 ),
582 path: "".into(),602 path: "".into(),
583 relation: Some(Relation::Parent(1))603 relation: Some(Relation::Parent(1))
584 },604 },
585 Addition {605 Addition {
586 entry_mode: EntryKind::Blob.into(),606 entry_mode: EntryKind::Blob.into(),
587 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),607 oid: empty_blob_id,
588 path: "".into(),608 path: "".into(),
589 relation: Some(Relation::ChildOfParent(1))609 relation: Some(Relation::ChildOfParent(1))
590 }610 }
591 ]611 ]
592 );612 );
593 assert_hash_agnostic_eq!(613 pretty_assertions::assert_eq!(
594 diff_commits(&db, last_commit.to_owned(), &first_commit, Location::FileName.into())?,614 diff_commits(&db, last_commit.to_owned(), &first_commit, Location::FileName.into())?,
595 vec![615 vec![
596 Deletion {616 Deletion {
597 entry_mode: EntryKind::Blob.into(),617 entry_mode: EntryKind::Blob.into(),
598 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),618 oid: empty_blob_id,
599 path: "b".into(),619 path: "b".into(),
600 relation: None620 relation: None
601 },621 },
602 Deletion {622 Deletion {
603 entry_mode: EntryKind::Tree.into(),623 entry_mode: EntryKind::Tree.into(),
604 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"),624 oid: hex_to_id(
625 "496d6428b9cf92981dc9495211e6e1120fb6f2ba",
626 "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"
627 ),
605 path: "g".into(),628 path: "g".into(),
606 relation: Some(Relation::Parent(1))629 relation: Some(Relation::Parent(1))
607 },630 },
608 Deletion {631 Deletion {
609 entry_mode: EntryKind::Blob.into(),632 entry_mode: EntryKind::Blob.into(),
610 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),633 oid: empty_blob_id,
611 path: "a".into(),634 path: "a".into(),
612 relation: Some(Relation::ChildOfParent(1))635 relation: Some(Relation::ChildOfParent(1))
613 }636 }
@@ -620,55 +643,65 @@ mod changes { · 6 unmodified lines
620 fn maximal_difference_nested() -> crate::Result {643 fn maximal_difference_nested() -> crate::Result {
621 let db = db(["a"].iter().copied())?;644 let db = db(["a"].iter().copied())?;
622 let all_commits = all_commits(&db);645 let all_commits = all_commits(&db);
646 let empty_blob_id = hex_to_id(
647 "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
648 "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
649 );
623 650
624 assert_hash_agnostic_eq!(651 pretty_assertions::assert_eq!(
625 diff_commits(&db, None::<ObjectId>, &all_commits["add g/a"], Some(Location::Path))?,652 diff_commits(&db, None::<ObjectId>, &all_commits["add g/a"], Some(Location::Path))?,
626 vec![653 vec![
627 Addition {654 Addition {
628 entry_mode: EntryKind::Tree.into(),655 entry_mode: EntryKind::Tree.into(),
629 oid: hex_to_id("0df4d0ed769eacd0a231e7512fca25d3cabdeca4"),656 oid: hex_to_id(
657 "0df4d0ed769eacd0a231e7512fca25d3cabdeca4",
658 "dac24a12e6d43c6ad271e7ea4f021093dac44f15f99317b2e0d54753b4f09099"
659 ),
630 path: "a".into(),660 path: "a".into(),
631 relation: Some(Relation::Parent(1)),661 relation: Some(Relation::Parent(1)),
632 },662 },
633 Addition {663 Addition {
634 entry_mode: EntryKind::Blob.into(),664 entry_mode: EntryKind::Blob.into(),
635 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),665 oid: empty_blob_id,
636 path: "a/b".into(),666 path: "a/b".into(),
637 relation: Some(Relation::ChildOfParent(1)),667 relation: Some(Relation::ChildOfParent(1)),
638 },668 },
639 Addition {669 Addition {
640 entry_mode: EntryKind::Blob.into(),670 entry_mode: EntryKind::Blob.into(),
641 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),671 oid: empty_blob_id,
642 path: "a/c".into(),672 path: "a/c".into(),
643 relation: Some(Relation::ChildOfParent(1)),673 relation: Some(Relation::ChildOfParent(1)),
644 },674 },
645 Addition {675 Addition {
646 entry_mode: EntryKind::Blob.into(),676 entry_mode: EntryKind::Blob.into(),
647 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),677 oid: empty_blob_id,
648 path: "a/d".into(),678 path: "a/d".into(),
649 relation: Some(Relation::ChildOfParent(1)),679 relation: Some(Relation::ChildOfParent(1)),
650 },680 },
651 Addition {681 Addition {
652 entry_mode: EntryKind::Blob.into(),682 entry_mode: EntryKind::Blob.into(),
653 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),683 oid: empty_blob_id,
654 path: "a/e".into(),684 path: "a/e".into(),
655 relation: Some(Relation::ChildOfParent(1)),685 relation: Some(Relation::ChildOfParent(1)),
656 },686 },
657 Addition {687 Addition {
658 entry_mode: EntryKind::Blob.into(),688 entry_mode: EntryKind::Blob.into(),
659 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),689 oid: empty_blob_id,
660 path: "a/f".into(),690 path: "a/f".into(),
661 relation: Some(Relation::ChildOfParent(1)),691 relation: Some(Relation::ChildOfParent(1)),
662 },692 },
663 Addition {693 Addition {
664 entry_mode: EntryKind::Tree.into(),694 entry_mode: EntryKind::Tree.into(),
665 oid: hex_to_id("496d6428b9cf92981dc9495211e6e1120fb6f2ba"),695 oid: hex_to_id(
696 "496d6428b9cf92981dc9495211e6e1120fb6f2ba",
697 "5f6f307bcc469c02acba4f7da42d8d4defdda8209777fe732956f1e2fa0db3ff"
698 ),
666 path: "a/g".into(),699 path: "a/g".into(),
667 relation: Some(Relation::ChildOfParent(1)),700 relation: Some(Relation::ChildOfParent(1)),
668 },701 },
669 Addition {702 Addition {
670 entry_mode: EntryKind::Blob.into(),703 entry_mode: EntryKind::Blob.into(),
671 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),704 oid: empty_blob_id,
672 path: "a/g/a".into(),705 path: "a/g/a".into(),
673 relation: Some(Relation::ChildOfParent(1)),706 relation: Some(Relation::ChildOfParent(1)),
674 }707 }
@@ -681,67 +714,83 @@ mod changes { · 6 unmodified lines
681 fn directory_rename() -> crate::Result {714 fn directory_rename() -> crate::Result {
682 let db = db(None)?;715 let db = db(None)?;
683 let all_commits = all_commits(&db);716 let all_commits = all_commits(&db);
717 let empty_blob_id = hex_to_id(
718 "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
719 "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
720 );
684 721
685 assert_hash_agnostic_eq!(722 pretty_assertions::assert_eq!(
686 diff_with_previous_commit_from(&db, &all_commits["rename git-sec to gix-sec"])?,723 diff_with_previous_commit_from(&db, &all_commits["rename git-sec to gix-sec"])?,
687 vec![724 vec![
688 Deletion {725 Deletion {
689 entry_mode: EntryKind::Tree.into(),726 entry_mode: EntryKind::Tree.into(),
690 oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"),727 oid: hex_to_id(
728 "d8c30fb72173778ed57fac5813c5e37038a8746c",
729 "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad"
730 ),
691 path: "git-sec".into(),731 path: "git-sec".into(),
692 relation: Some(Relation::Parent(1)),732 relation: Some(Relation::Parent(1)),
693 },733 },
694 Addition {734 Addition {
695 entry_mode: EntryKind::Tree.into(),735 entry_mode: EntryKind::Tree.into(),
696 oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"),736 oid: hex_to_id(
737 "d8c30fb72173778ed57fac5813c5e37038a8746c",
738 "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad"
739 ),
697 path: "gix-sec".into(),740 path: "gix-sec".into(),
698 relation: Some(Relation::Parent(2)),741 relation: Some(Relation::Parent(2)),
699 },742 },
700 Deletion {743 Deletion {
701 entry_mode: EntryKind::Blob.into(),744 entry_mode: EntryKind::Blob.into(),
702 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),745 oid: empty_blob_id,
703 path: "git-sec/2".into(),746 path: "git-sec/2".into(),
704 relation: Some(Relation::ChildOfParent(1)),747 relation: Some(Relation::ChildOfParent(1)),
705 },748 },
706 Deletion {749 Deletion {
707 entry_mode: EntryKind::Blob.into(),750 entry_mode: EntryKind::Blob.into(),
708 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),751 oid: empty_blob_id,
709 path: "git-sec/7".into(),752 path: "git-sec/7".into(),
710 relation: Some(Relation::ChildOfParent(1)),753 relation: Some(Relation::ChildOfParent(1)),
711 },754 },
712 Deletion {755 Deletion {
713 entry_mode: EntryKind::Tree.into(),756 entry_mode: EntryKind::Tree.into(),
714 oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"),757 oid: hex_to_id(
758 "fd7938a0c18f993c89eda3f40a6d06fa6785833c",
759 "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae"
760 ),
715 path: "git-sec/subdir".into(),761 path: "git-sec/subdir".into(),
716 relation: Some(Relation::ChildOfParent(1)),762 relation: Some(Relation::ChildOfParent(1)),
717 },763 },
718 Addition {764 Addition {
719 entry_mode: EntryKind::Blob.into(),765 entry_mode: EntryKind::Blob.into(),
720 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),766 oid: empty_blob_id,
721 path: "gix-sec/2".into(),767 path: "gix-sec/2".into(),
722 relation: Some(Relation::ChildOfParent(2)),768 relation: Some(Relation::ChildOfParent(2)),
723 },769 },
724 Addition {770 Addition {
725 entry_mode: EntryKind::Blob.into(),771 entry_mode: EntryKind::Blob.into(),
726 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),772 oid: empty_blob_id,
727 path: "gix-sec/7".into(),773 path: "gix-sec/7".into(),
728 relation: Some(Relation::ChildOfParent(2)),774 relation: Some(Relation::ChildOfParent(2)),
729 },775 },
730 Addition {776 Addition {
731 entry_mode: EntryKind::Tree.into(),777 entry_mode: EntryKind::Tree.into(),
732 oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"),778 oid: hex_to_id(
779 "fd7938a0c18f993c89eda3f40a6d06fa6785833c",
780 "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae"
781 ),
733 path: "gix-sec/subdir".into(),782 path: "gix-sec/subdir".into(),
734 relation: Some(Relation::ChildOfParent(2)),783 relation: Some(Relation::ChildOfParent(2)),
735 },784 },
736 Deletion {785 Deletion {
737 entry_mode: EntryKind::Blob.into(),786 entry_mode: EntryKind::Blob.into(),
738 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),787 oid: empty_blob_id,
739 path: "git-sec/subdir/6".into(),788 path: "git-sec/subdir/6".into(),
740 relation: Some(Relation::ChildOfParent(1)),789 relation: Some(Relation::ChildOfParent(1)),
741 },790 },
742 Addition {791 Addition {
743 entry_mode: EntryKind::Blob.into(),792 entry_mode: EntryKind::Blob.into(),
744 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),793 oid: empty_blob_id,
745 path: "gix-sec/subdir/6".into(),794 path: "gix-sec/subdir/6".into(),
746 relation: Some(Relation::ChildOfParent(2)),795 relation: Some(Relation::ChildOfParent(2)),
747 }796 }
@@ -754,67 +803,83 @@ mod changes { · 6 unmodified lines
754 fn reverse_directory_rename() -> crate::Result {803 fn reverse_directory_rename() -> crate::Result {
755 let db = db(None)?;804 let db = db(None)?;
756 let all_commits = all_commits(&db);805 let all_commits = all_commits(&db);
806 let empty_blob_id = hex_to_id(
807 "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
808 "473a0f4c3be8a93681a267e3b1e9a7dcda1185436fe141f7749120a303721813",
809 );
757 810
758 assert_hash_agnostic_eq!(811 pretty_assertions::assert_eq!(
759 diff_with_previous_commit_from(&db, &all_commits["rename gix-sec to git-sec"])?,812 diff_with_previous_commit_from(&db, &all_commits["rename gix-sec to git-sec"])?,
760 vec![813 vec![
761 Addition {814 Addition {
762 entry_mode: EntryKind::Tree.into(),815 entry_mode: EntryKind::Tree.into(),
763 oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"),816 oid: hex_to_id(
817 "d8c30fb72173778ed57fac5813c5e37038a8746c",
818 "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad"
819 ),
764 path: "git-sec".into(),820 path: "git-sec".into(),
765 relation: Some(Relation::Parent(1)),821 relation: Some(Relation::Parent(1)),
766 },822 },
767 Deletion {823 Deletion {
768 entry_mode: EntryKind::Tree.into(),824 entry_mode: EntryKind::Tree.into(),
769 oid: hex_to_id("d8c30fb72173778ed57fac5813c5e37038a8746c"),825 oid: hex_to_id(
826 "d8c30fb72173778ed57fac5813c5e37038a8746c",
827 "52a70042eff6fbeed1d6c8c0ed2f9cc775a19cc51b395429c4210bc5091520ad"
828 ),
770 path: "gix-sec".into(),829 path: "gix-sec".into(),
771 relation: Some(Relation::Parent(2)),830 relation: Some(Relation::Parent(2)),
772 },831 },
773 Addition {832 Addition {
774 entry_mode: EntryKind::Blob.into(),833 entry_mode: EntryKind::Blob.into(),
775 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),834 oid: empty_blob_id,
776 path: "git-sec/2".into(),835 path: "git-sec/2".into(),
777 relation: Some(Relation::ChildOfParent(1)),836 relation: Some(Relation::ChildOfParent(1)),
778 },837 },
779 Addition {838 Addition {
780 entry_mode: EntryKind::Blob.into(),839 entry_mode: EntryKind::Blob.into(),
781 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),840 oid: empty_blob_id,
782 path: "git-sec/7".into(),841 path: "git-sec/7".into(),
783 relation: Some(Relation::ChildOfParent(1)),842 relation: Some(Relation::ChildOfParent(1)),
784 },843 },
785 Addition {844 Addition {
786 entry_mode: EntryKind::Tree.into(),845 entry_mode: EntryKind::Tree.into(),
787 oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"),846 oid: hex_to_id(
847 "fd7938a0c18f993c89eda3f40a6d06fa6785833c",
848 "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae"
849 ),
788 path: "git-sec/subdir".into(),850 path: "git-sec/subdir".into(),
789 relation: Some(Relation::ChildOfParent(1)),851 relation: Some(Relation::ChildOfParent(1)),
790 },852 },
791 Deletion {853 Deletion {
792 entry_mode: EntryKind::Blob.into(),854 entry_mode: EntryKind::Blob.into(),
793 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),855 oid: empty_blob_id,
794 path: "gix-sec/2".into(),856 path: "gix-sec/2".into(),
795 relation: Some(Relation::ChildOfParent(2)),857 relation: Some(Relation::ChildOfParent(2)),
796 },858 },
797 Deletion {859 Deletion {
798 entry_mode: EntryKind::Blob.into(),860 entry_mode: EntryKind::Blob.into(),
799 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),861 oid: empty_blob_id,
800 path: "gix-sec/7".into(),862 path: "gix-sec/7".into(),
801 relation: Some(Relation::ChildOfParent(2)),863 relation: Some(Relation::ChildOfParent(2)),
802 },864 },
803 Deletion {865 Deletion {
804 entry_mode: EntryKind::Tree.into(),866 entry_mode: EntryKind::Tree.into(),
805 oid: hex_to_id("fd7938a0c18f993c89eda3f40a6d06fa6785833c"),867 oid: hex_to_id(
868 "fd7938a0c18f993c89eda3f40a6d06fa6785833c",
869 "5b2e08d098c63c2f31c8937c810f77ff005c48833701e0854f690188f1887aae"
870 ),
806 path: "gix-sec/subdir".into(),871 path: "gix-sec/subdir".into(),
807 relation: Some(Relation::ChildOfParent(2)),872 relation: Some(Relation::ChildOfParent(2)),
808 },873 },
809 Addition {874 Addition {
810 entry_mode: EntryKind::Blob.into(),875 entry_mode: EntryKind::Blob.into(),
811 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),876 oid: empty_blob_id,
812 path: "git-sec/subdir/6".into(),877 path: "git-sec/subdir/6".into(),
813 relation: Some(Relation::ChildOfParent(1)),878 relation: Some(Relation::ChildOfParent(1)),
814 },879 },
815 Deletion {880 Deletion {
816 entry_mode: EntryKind::Blob.into(),881 entry_mode: EntryKind::Blob.into(),
817 oid: hex_to_id("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"),882 oid: empty_blob_id,
818 path: "gix-sec/subdir/6".into(),883 path: "gix-sec/subdir/6".into(),
819 relation: Some(Relation::ChildOfParent(2)),884 relation: Some(Relation::ChildOfParent(2)),
820 }885 }
gix-imara-diff/Cargo.toml+0−3
@@ -31,9 +31,6 @@ gix-object = { version = "^0.60.0", path = "../gix-object", features = ["sha1"] · 30 unmodified lines
31cov-mark = "2.1.0"31cov-mark = "2.1.0"
32expect-test = "1.4.0"32expect-test = "1.4.0"
33 33
34[profile.release]
35debug = true
36
37# [[bench]]34# [[bench]]
38# name = "git_repo"35# name = "git_repo"
39# harness = false36# harness = false
justfile+3−0
@@ -201,6 +201,8 @@ unit-tests: · 200 unmodified lines
201 cargo nextest run -p gix-archive --no-default-features --features tar --no-fail-fast201 cargo nextest run -p gix-archive --no-default-features --features tar --no-fail-fast
202 cargo nextest run -p gix-archive --no-default-features --features tar_gz --no-fail-fast202 cargo nextest run -p gix-archive --no-default-features --features tar_gz --no-fail-fast
203 cargo nextest run -p gix-archive --no-default-features --features zip --no-fail-fast203 cargo nextest run -p gix-archive --no-default-features --features zip --no-fail-fast
204 env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-diff --no-fail-fast
205 env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-diff --no-fail-fast
204 cargo nextest run -p gix-status-tests --features gix-features-parallel --no-fail-fast206 cargo nextest run -p gix-status-tests --features gix-features-parallel --no-fail-fast
205 cargo nextest run -p gix-worktree-state-tests --features gix-features-parallel --no-fail-fast207 cargo nextest run -p gix-worktree-state-tests --features gix-features-parallel --no-fail-fast
206 cargo nextest run -p gix-worktree-tests --features gix-features-parallel --no-fail-fast208 cargo nextest run -p gix-worktree-tests --features gix-features-parallel --no-fail-fast
@@ -225,6 +227,7 @@ unit-tests: · 18 unmodified lines
225 cargo nextest run -p gix-odb-tests --features gix-features-parallel --no-fail-fast227 cargo nextest run -p gix-odb-tests --features gix-features-parallel --no-fail-fast
226 env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-pack --all-features --no-fail-fast228 env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-pack --all-features --no-fail-fast
227 env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-pack --all-features --no-fail-fast229 env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-pack --all-features --no-fail-fast
230 env GIX_TEST_FIXTURE_HASH=sha1 cargo nextest run -p gix-diff-tests --no-fail-fast
228 env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-diff-tests --no-fail-fast231 env GIX_TEST_FIXTURE_HASH=sha256 cargo nextest run -p gix-diff-tests --no-fail-fast
229 cargo nextest run -p gix-pack-tests --features all-features --no-fail-fast232 cargo nextest run -p gix-pack-tests --features all-features --no-fail-fast
230 cargo nextest run -p gix-pack-tests --features gix-features-parallel --no-fail-fast233 cargo nextest run -p gix-pack-tests --features gix-features-parallel --no-fail-fast