Skip to content

Commit ddc99b5

Browse files
committedOct 15, 2024
reproduce ordering issue when finding parents
In order to fix this, we need another pass in original order.
1 parent f186c23 commit ddc99b5

File tree

2 files changed

+561
-2
lines changed

2 files changed

+561
-2
lines changed
 

‎gix/tests/fixtures/make_diff_repos.sh

+6
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ git init jj-trackcopy-1
1414
rm -f "$index"
1515
git update-index --index-info < "$ROOT/assets/jj-trackcopy-1/47bd6f4aa4a7eeef8b01ce168c6c771bdfffcbd3.tree"
1616
git commit --allow-empty -F "$ROOT/assets/jj-trackcopy-1/47bd6f4aa4a7eeef8b01ce168c6c771bdfffcbd3.msg"
17+
18+
git checkout -f HEAD
19+
git mv cli c
20+
git commit -m "renamed cli to c"
21+
22+
rm -Rf c/
1723
)

‎gix/tests/gix/object/tree/diff.rs

+555-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ mod track_rewrites {
168168
("cli/tests/test_cat_command.rs".into(), 77),
169169
);
170170

171-
let from = tree_named(&repo, "@~1");
172-
let to = tree_named(&repo, "@");
171+
let from = tree_named(&repo, "@~2");
172+
let to = tree_named(&repo, "@~1");
173173
let rewrites = Rewrites {
174174
copies: Some(Copies {
175175
source: CopySource::FromSetOfModifiedFiles,
@@ -489,6 +489,559 @@ mod track_rewrites {
489489

490490
Ok(())
491491
}
492+
493+
#[test]
494+
#[cfg_attr(
495+
windows,
496+
ignore = "Fails on some Window systems, like the fixture doesn't get set up correctly."
497+
)]
498+
fn jj_realistic_directory_rename() -> crate::Result {
499+
let repo = named_subrepo_opts("make_diff_repos.sh", "jj-trackcopy-1", gix::open::Options::isolated())?;
500+
501+
let from = tree_named(&repo, "@~1");
502+
let to = tree_named(&repo, "@");
503+
let actual: Vec<_> = repo
504+
.diff_tree_to_tree(
505+
&from,
506+
&to,
507+
Some(gix::diff::Options::default().with_rewrites(Some(Rewrites::default()))),
508+
)?
509+
.into_iter()
510+
.collect();
511+
insta::assert_debug_snapshot!(actual, @r#"
512+
[
513+
Addition {
514+
location: "c/src",
515+
relation: Some(
516+
ChildOfParent(
517+
1,
518+
),
519+
),
520+
entry_mode: EntryMode(
521+
16384,
522+
),
523+
id: Sha1(80e5b08f25f75c2050afbcb794e8434f4cf082f1),
524+
},
525+
Addition {
526+
location: "c/tests",
527+
relation: Some(
528+
ChildOfParent(
529+
1,
530+
),
531+
),
532+
entry_mode: EntryMode(
533+
16384,
534+
),
535+
id: Sha1(17be3b367831653883a36a2f2a8dea418b8d96b7),
536+
},
537+
Deletion {
538+
location: "cli/src",
539+
relation: Some(
540+
ChildOfParent(
541+
2,
542+
),
543+
),
544+
entry_mode: EntryMode(
545+
16384,
546+
),
547+
id: Sha1(80e5b08f25f75c2050afbcb794e8434f4cf082f1),
548+
},
549+
Deletion {
550+
location: "cli/tests",
551+
relation: Some(
552+
ChildOfParent(
553+
2,
554+
),
555+
),
556+
entry_mode: EntryMode(
557+
16384,
558+
),
559+
id: Sha1(17be3b367831653883a36a2f2a8dea418b8d96b7),
560+
},
561+
Addition {
562+
location: "c/src/commands",
563+
relation: Some(
564+
ChildOfParent(
565+
1,
566+
),
567+
),
568+
entry_mode: EntryMode(
569+
16384,
570+
),
571+
id: Sha1(f414de88468352d59c129d0e7686fb1e1f387929),
572+
},
573+
Deletion {
574+
location: "cli/src/commands",
575+
relation: Some(
576+
ChildOfParent(
577+
2,
578+
),
579+
),
580+
entry_mode: EntryMode(
581+
16384,
582+
),
583+
id: Sha1(f414de88468352d59c129d0e7686fb1e1f387929),
584+
},
585+
Addition {
586+
location: "c/src/commands/file",
587+
relation: Some(
588+
ChildOfParent(
589+
1,
590+
),
591+
),
592+
entry_mode: EntryMode(
593+
16384,
594+
),
595+
id: Sha1(0f3bc154b577b84fb5ce31383e25acc99c2f24a5),
596+
},
597+
Deletion {
598+
location: "cli/src/commands/file",
599+
relation: Some(
600+
ChildOfParent(
601+
2,
602+
),
603+
),
604+
entry_mode: EntryMode(
605+
16384,
606+
),
607+
id: Sha1(0f3bc154b577b84fb5ce31383e25acc99c2f24a5),
608+
},
609+
Rewrite {
610+
source_location: "cli/src/commands/file/print.rs",
611+
source_entry_mode: EntryMode(
612+
33188,
613+
),
614+
source_relation: Some(
615+
ChildOfParent(
616+
2,
617+
),
618+
),
619+
source_id: Sha1(081093be2ba0d2be62d14363f43859355bee2aa2),
620+
diff: None,
621+
entry_mode: EntryMode(
622+
33188,
623+
),
624+
id: Sha1(081093be2ba0d2be62d14363f43859355bee2aa2),
625+
location: "c/src/commands/file/print.rs",
626+
relation: Some(
627+
ChildOfParent(
628+
1,
629+
),
630+
),
631+
copy: false,
632+
},
633+
Rewrite {
634+
source_location: "cli/tests/test_immutable_commits.rs",
635+
source_entry_mode: EntryMode(
636+
33188,
637+
),
638+
source_relation: Some(
639+
ChildOfParent(
640+
2,
641+
),
642+
),
643+
source_id: Sha1(3d7598b4e4c570eef701f40853ef3e3b0fb224f7),
644+
diff: None,
645+
entry_mode: EntryMode(
646+
33188,
647+
),
648+
id: Sha1(3d7598b4e4c570eef701f40853ef3e3b0fb224f7),
649+
location: "c/tests/test_immutable_commits.rs",
650+
relation: Some(
651+
ChildOfParent(
652+
1,
653+
),
654+
),
655+
copy: false,
656+
},
657+
Rewrite {
658+
source_location: "cli/tests/test_file_print_command.rs",
659+
source_entry_mode: EntryMode(
660+
33188,
661+
),
662+
source_relation: Some(
663+
ChildOfParent(
664+
2,
665+
),
666+
),
667+
source_id: Sha1(45bb2cf6b7fa96a39c95301f619ca3e4cc3eb0f3),
668+
diff: None,
669+
entry_mode: EntryMode(
670+
33188,
671+
),
672+
id: Sha1(45bb2cf6b7fa96a39c95301f619ca3e4cc3eb0f3),
673+
location: "c/tests/test_file_print_command.rs",
674+
relation: Some(
675+
ChildOfParent(
676+
1,
677+
),
678+
),
679+
copy: false,
680+
},
681+
Rewrite {
682+
source_location: "cli/tests/runner.rs",
683+
source_entry_mode: EntryMode(
684+
33188,
685+
),
686+
source_relation: Some(
687+
ChildOfParent(
688+
2,
689+
),
690+
),
691+
source_id: Sha1(5253f0ff160e8b7001a7bd271ca4a07968ff81a3),
692+
diff: None,
693+
entry_mode: EntryMode(
694+
33188,
695+
),
696+
id: Sha1(5253f0ff160e8b7001a7bd271ca4a07968ff81a3),
697+
location: "c/tests/runner.rs",
698+
relation: Some(
699+
ChildOfParent(
700+
1,
701+
),
702+
),
703+
copy: false,
704+
},
705+
Rewrite {
706+
source_location: "cli/tests/test_file_chmod_command.rs",
707+
source_entry_mode: EntryMode(
708+
33188,
709+
),
710+
source_relation: Some(
711+
ChildOfParent(
712+
2,
713+
),
714+
),
715+
source_id: Sha1(8defe631bc82bf35a53cd25083f85664516f412f),
716+
diff: None,
717+
entry_mode: EntryMode(
718+
33188,
719+
),
720+
id: Sha1(8defe631bc82bf35a53cd25083f85664516f412f),
721+
location: "c/tests/test_file_chmod_command.rs",
722+
relation: Some(
723+
ChildOfParent(
724+
1,
725+
),
726+
),
727+
copy: false,
728+
},
729+
Rewrite {
730+
source_location: "cli/tests/cli-reference@.md.snap",
731+
source_entry_mode: EntryMode(
732+
33188,
733+
),
734+
source_relation: Some(
735+
ChildOfParent(
736+
2,
737+
),
738+
),
739+
source_id: Sha1(92853cde19b20cadd74113ea3566c87d4def591b),
740+
diff: None,
741+
entry_mode: EntryMode(
742+
33188,
743+
),
744+
id: Sha1(92853cde19b20cadd74113ea3566c87d4def591b),
745+
location: "c/tests/cli-reference@.md.snap",
746+
relation: Some(
747+
ChildOfParent(
748+
1,
749+
),
750+
),
751+
copy: false,
752+
},
753+
Rewrite {
754+
source_location: "cli/src/commands/file/chmod.rs",
755+
source_entry_mode: EntryMode(
756+
33188,
757+
),
758+
source_relation: Some(
759+
ChildOfParent(
760+
2,
761+
),
762+
),
763+
source_id: Sha1(94f78deb408d181ccea9da574d0e45ac32a98092),
764+
diff: None,
765+
entry_mode: EntryMode(
766+
33188,
767+
),
768+
id: Sha1(94f78deb408d181ccea9da574d0e45ac32a98092),
769+
location: "c/src/commands/file/chmod.rs",
770+
relation: Some(
771+
ChildOfParent(
772+
1,
773+
),
774+
),
775+
copy: false,
776+
},
777+
Rewrite {
778+
source_location: "cli/tests/test_new_command.rs",
779+
source_entry_mode: EntryMode(
780+
33188,
781+
),
782+
source_relation: Some(
783+
ChildOfParent(
784+
2,
785+
),
786+
),
787+
source_id: Sha1(a03b50a8a9c23c68d641b51b7c887ea088cd0d2b),
788+
diff: None,
789+
entry_mode: EntryMode(
790+
33188,
791+
),
792+
id: Sha1(a03b50a8a9c23c68d641b51b7c887ea088cd0d2b),
793+
location: "c/tests/test_new_command.rs",
794+
relation: Some(
795+
ChildOfParent(
796+
1,
797+
),
798+
),
799+
copy: false,
800+
},
801+
Rewrite {
802+
source_location: "cli/tests/test_global_opts.rs",
803+
source_entry_mode: EntryMode(
804+
33188,
805+
),
806+
source_relation: Some(
807+
ChildOfParent(
808+
2,
809+
),
810+
),
811+
source_id: Sha1(a0c0340e495fa759c0b705dd46cee322aa0d80c8),
812+
diff: None,
813+
entry_mode: EntryMode(
814+
33188,
815+
),
816+
id: Sha1(a0c0340e495fa759c0b705dd46cee322aa0d80c8),
817+
location: "c/tests/test_global_opts.rs",
818+
relation: Some(
819+
ChildOfParent(
820+
1,
821+
),
822+
),
823+
copy: false,
824+
},
825+
Rewrite {
826+
source_location: "cli/tests/test_move_command.rs",
827+
source_entry_mode: EntryMode(
828+
33188,
829+
),
830+
source_relation: Some(
831+
ChildOfParent(
832+
2,
833+
),
834+
),
835+
source_id: Sha1(ac9ad5761637cd731abe1bf4a075fedda7bfc61f),
836+
diff: None,
837+
entry_mode: EntryMode(
838+
33188,
839+
),
840+
id: Sha1(ac9ad5761637cd731abe1bf4a075fedda7bfc61f),
841+
location: "c/tests/test_move_command.rs",
842+
relation: Some(
843+
ChildOfParent(
844+
1,
845+
),
846+
),
847+
copy: false,
848+
},
849+
Rewrite {
850+
source_location: "cli/tests/test_unsquash_command.rs",
851+
source_entry_mode: EntryMode(
852+
33188,
853+
),
854+
source_relation: Some(
855+
ChildOfParent(
856+
2,
857+
),
858+
),
859+
source_id: Sha1(b8b29cc0ca0176fafaa97c7421a10ed116bcba8a),
860+
diff: None,
861+
entry_mode: EntryMode(
862+
33188,
863+
),
864+
id: Sha1(b8b29cc0ca0176fafaa97c7421a10ed116bcba8a),
865+
location: "c/tests/test_unsquash_command.rs",
866+
relation: Some(
867+
ChildOfParent(
868+
1,
869+
),
870+
),
871+
copy: false,
872+
},
873+
Rewrite {
874+
source_location: "cli/src/commands/file/mod.rs",
875+
source_entry_mode: EntryMode(
876+
33188,
877+
),
878+
source_relation: Some(
879+
ChildOfParent(
880+
2,
881+
),
882+
),
883+
source_id: Sha1(d67f782327ea286136b8532eaf9a509806a87e83),
884+
diff: None,
885+
entry_mode: EntryMode(
886+
33188,
887+
),
888+
id: Sha1(d67f782327ea286136b8532eaf9a509806a87e83),
889+
location: "c/src/commands/file/mod.rs",
890+
relation: Some(
891+
ChildOfParent(
892+
1,
893+
),
894+
),
895+
copy: false,
896+
},
897+
Rewrite {
898+
source_location: "cli/tests/test_fix_command.rs",
899+
source_entry_mode: EntryMode(
900+
33188,
901+
),
902+
source_relation: Some(
903+
ChildOfParent(
904+
2,
905+
),
906+
),
907+
source_id: Sha1(e0baefc79038fed0bcf56f2d8c3588a26d5bf985),
908+
diff: None,
909+
entry_mode: EntryMode(
910+
33188,
911+
),
912+
id: Sha1(e0baefc79038fed0bcf56f2d8c3588a26d5bf985),
913+
location: "c/tests/test_fix_command.rs",
914+
relation: Some(
915+
ChildOfParent(
916+
1,
917+
),
918+
),
919+
copy: false,
920+
},
921+
Rewrite {
922+
source_location: "cli/src/commands/mod.rs",
923+
source_entry_mode: EntryMode(
924+
33188,
925+
),
926+
source_relation: Some(
927+
ChildOfParent(
928+
2,
929+
),
930+
),
931+
source_id: Sha1(e3a9ec4524d27aa7035a38fd7c5db414809623c4),
932+
diff: None,
933+
entry_mode: EntryMode(
934+
33188,
935+
),
936+
id: Sha1(e3a9ec4524d27aa7035a38fd7c5db414809623c4),
937+
location: "c/src/commands/mod.rs",
938+
relation: Some(
939+
ChildOfParent(
940+
1,
941+
),
942+
),
943+
copy: false,
944+
},
945+
Rewrite {
946+
source_location: "cli",
947+
source_entry_mode: EntryMode(
948+
16384,
949+
),
950+
source_relation: Some(
951+
Parent(
952+
2,
953+
),
954+
),
955+
source_id: Sha1(f203064a6a81df47498fb415a2064a8ec568ed67),
956+
diff: None,
957+
entry_mode: EntryMode(
958+
16384,
959+
),
960+
id: Sha1(f203064a6a81df47498fb415a2064a8ec568ed67),
961+
location: "c",
962+
relation: Some(
963+
Parent(
964+
1,
965+
),
966+
),
967+
copy: false,
968+
},
969+
Rewrite {
970+
source_location: "cli/tests/test_acls.rs",
971+
source_entry_mode: EntryMode(
972+
33188,
973+
),
974+
source_relation: Some(
975+
ChildOfParent(
976+
2,
977+
),
978+
),
979+
source_id: Sha1(f644e4c8dd0be6fbe5493b172ce10839bcd9e25c),
980+
diff: None,
981+
entry_mode: EntryMode(
982+
33188,
983+
),
984+
id: Sha1(f644e4c8dd0be6fbe5493b172ce10839bcd9e25c),
985+
location: "c/tests/test_acls.rs",
986+
relation: Some(
987+
ChildOfParent(
988+
1,
989+
),
990+
),
991+
copy: false,
992+
},
993+
Rewrite {
994+
source_location: "cli/tests/test_diffedit_command.rs",
995+
source_entry_mode: EntryMode(
996+
33188,
997+
),
998+
source_relation: Some(
999+
ChildOfParent(
1000+
2,
1001+
),
1002+
),
1003+
source_id: Sha1(fd57f61e92d4d49b4920c08c3522c066cb03ecd2),
1004+
diff: None,
1005+
entry_mode: EntryMode(
1006+
33188,
1007+
),
1008+
id: Sha1(fd57f61e92d4d49b4920c08c3522c066cb03ecd2),
1009+
location: "c/tests/test_diffedit_command.rs",
1010+
relation: Some(
1011+
ChildOfParent(
1012+
1,
1013+
),
1014+
),
1015+
copy: false,
1016+
},
1017+
Rewrite {
1018+
source_location: "cli/tests/test_squash_command.rs",
1019+
source_entry_mode: EntryMode(
1020+
33188,
1021+
),
1022+
source_relation: Some(
1023+
ChildOfParent(
1024+
2,
1025+
),
1026+
),
1027+
source_id: Sha1(ff1c247d4312adb5b372c6d9ff93fa71846ca527),
1028+
diff: None,
1029+
entry_mode: EntryMode(
1030+
33188,
1031+
),
1032+
id: Sha1(ff1c247d4312adb5b372c6d9ff93fa71846ca527),
1033+
location: "c/tests/test_squash_command.rs",
1034+
relation: Some(
1035+
ChildOfParent(
1036+
1,
1037+
),
1038+
),
1039+
copy: false,
1040+
},
1041+
]
1042+
"#);
1043+
Ok(())
1044+
}
4921045
}
4931046

4941047
fn tree_named(repo: &gix::Repository, rev_spec: impl AsRef<str>) -> gix::Tree {

0 commit comments

Comments
 (0)
Please sign in to comment.