@@ -190,15 +190,21 @@ int IEqualityComparer<CompletedRebaseStepInfo>.GetHashCode(CompletedRebaseStepIn
190190 /// <summary>
191191 /// Verify a single rebase, but in more detail.
192192 /// </summary>
193- [ Fact ]
194- public void VerifyRebaseDetailed ( )
193+ [ Theory ]
194+ [ InlineData ( "* text=auto" , "\r \n " , new [ ] { "2cad6e96a0028f1764dcbde6292a9a1471acb114" , "18fd3deebe6124b5dacc8426d589d617a968e8d1" , "048977d8cb90d530e83cc615a17a49f3068f68c1" } ) ]
195+ [ InlineData ( "* text=auto" , "\n " , new [ ] { "2cad6e96a0028f1764dcbde6292a9a1471acb114" , "18fd3deebe6124b5dacc8426d589d617a968e8d1" , "048977d8cb90d530e83cc615a17a49f3068f68c1" } ) ]
196+ [ InlineData ( "* text=auto\n *.txt eol=lf" , "\n " , new [ ] { "577d176b00a55e88e9b34da87e4357dfc9a486fd" , "ea0ad4d8b500394a61874ebfda5904376e2b1098" , "521b8383ca3fde9e369587492e7a3945677f1b2c" } ) ]
197+ [ InlineData ( "* text=auto\r \n *.txt eol=crlf" , "\r \n " , new [ ] { "67d29fdf654ac4773c9405ab4b54aa7ff092f339" , "7b70c02e175d378b44ea28aeeece775cd972047a" , "81f203dbfe00a5c1ecd9c0e6b03705e6cffda5c0" } ) ]
198+ [ InlineData ( "* binary" , "\r \n " , new [ ] { "f5a5ded935597108709224170accddc5aeb5c287" , "518adb8bb1ea1058d1825d3fe08d27f80c0e829b" , "d2db503ab553c970d34e1b5e3ff68768adef05bc" } ) ]
199+ [ InlineData ( "* binary" , "\n " , new [ ] { "93a0e9680246d1f1e43fbd5308f7936424d9e81a" , "5fd40bffbdd884632c330a254a2bd1dfaaaad3c1" , "4df5c91b2d8318781b07d04f6bfa77304c372f1e" } ) ]
200+ public void VerifyRebaseDetailed ( string attributes , string lineEnding , string [ ] expectedIds )
195201 {
196202 SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
197203 var path = Repository . Init ( scd . DirectoryPath ) ;
198204
199205 using ( Repository repo = new Repository ( path ) )
200206 {
201- ConstructRebaseTestRepository ( repo ) ;
207+ ConstructRebaseTestRepository ( repo , attributes , lineEnding ) ;
202208
203209 Branch initialBranch = repo . Branches [ topicBranch1Name ] ;
204210 Branch upstreamBranch = repo . Branches [ masterBranch2Name ] ;
@@ -262,9 +268,9 @@ public void VerifyRebaseDetailed()
262268
263269 List < ObjectId > expectedTreeIds = new List < ObjectId > ( )
264270 {
265- new ObjectId ( "447bad85bcc1882037848370620a6f88e8ee264e" ) ,
266- new ObjectId ( "3b0fc846952496a64b6149064cde21215daca8f8" ) ,
267- new ObjectId ( "a2d114246012daf3ef8e7ccbfbe91889a24e1e60" ) ,
271+ new ObjectId ( expectedIds [ 0 ] ) ,
272+ new ObjectId ( expectedIds [ 1 ] ) ,
273+ new ObjectId ( expectedIds [ 2 ] ) ,
268274 } ;
269275
270276 List < Commit > rebasedCommits = repo . Commits . QueryBy ( commitFilter ) . ToList ( ) ;
@@ -591,18 +597,24 @@ public void CurrentStepInfoIsNullWhenNotRebasing()
591597 }
592598 }
593599
594- [ Fact ]
595- public void CanRebaseHandlePatchAlreadyApplied ( )
600+ [ Theory ]
601+ [ InlineData ( "* text=auto" , "\r \n " , "379e80ed7824be7672e1e30ddd8f44aa081d57d4" ) ]
602+ [ InlineData ( "* text=auto" , "\n " , "379e80ed7824be7672e1e30ddd8f44aa081d57d4" ) ]
603+ [ InlineData ( "* text=auto\n *.txt eol=lf" , "\n " , "94121eeebf7cfe0acf22425eab36fcdc737132b6" ) ]
604+ [ InlineData ( "* text=auto\r \n *.txt eol=crlf" , "\r \n " , "dad06142cc632aea81cbc8486583011c4d622580" ) ]
605+ [ InlineData ( "* binary" , "\r \n " , "44492d98b725189cfc0203d4192dfbb1fd34bf02" ) ]
606+ [ InlineData ( "* binary" , "\n " , "f4b5b95de77f4cd97b4728617bae2dd8ba9af914" ) ]
607+ public void CanRebaseHandlePatchAlreadyApplied ( string attributes , string lineEnding , string expectedShaText )
596608 {
597609 SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
598610 var path = Repository . Init ( scd . DirectoryPath ) ;
599611 using ( Repository repo = new Repository ( path ) )
600612 {
601- ConstructRebaseTestRepository ( repo ) ;
613+ ConstructRebaseTestRepository ( repo , attributes , lineEnding ) ;
602614
603615 repo . Checkout ( topicBranch1Name ) ;
604616
605- Branch topicBranch1Prime = repo . CreateBranch ( topicBranch1PrimeName , masterBranch1Name ) ;
617+ Branch topicBranch1Prime = repo . CreateBranch ( topicBranch1PrimeName , masterBranch1Name ) ;
606618
607619 string newFileRelativePath = "new_file.txt" ;
608620 Touch ( repo . Info . WorkingDirectory , newFileRelativePath , "New Content" ) ;
@@ -631,7 +643,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
631643 } ;
632644
633645 repo . Rebase . Start ( null , upstreamBranch , null , Constants . Identity2 , options ) ;
634- ObjectId secondCommitExpectedTreeId = new ObjectId ( "ac04bf04980c9be72f64ba77fd0d9088a40ed681" ) ;
646+ ObjectId secondCommitExpectedTreeId = new ObjectId ( expectedShaText ) ;
635647 Signature secondCommitAuthorSignature = Constants . Signature ;
636648 Identity secondCommitCommiterIdentity = Constants . Identity2 ;
637649
@@ -642,7 +654,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
642654 Assert . NotNull ( rebaseResults [ 1 ] . Commit ) ;
643655
644656 // This is the expected tree ID of the new commit.
645- Assert . True ( ObjectId . Equals ( secondCommitExpectedTreeId , rebaseResults [ 1 ] . Commit . Tree . Id ) ) ;
657+ Assert . Equal ( secondCommitExpectedTreeId , rebaseResults [ 1 ] . Commit . Tree . Id ) ;
646658 Assert . True ( Signature . Equals ( secondCommitAuthorSignature , rebaseResults [ 1 ] . Commit . Author ) ) ;
647659 Assert . Equal < string > ( secondCommitCommiterIdentity . Name , rebaseResults [ 1 ] . Commit . Committer . Name , StringComparer . Ordinal ) ;
648660 Assert . Equal < string > ( secondCommitCommiterIdentity . Email , rebaseResults [ 1 ] . Commit . Committer . Email , StringComparer . Ordinal ) ;
@@ -664,7 +676,7 @@ public void RebasingInBareRepositoryThrows()
664676 }
665677 }
666678
667- private void ConstructRebaseTestRepository ( Repository repo )
679+ private void ConstructRebaseTestRepository ( Repository repo , string attributes = "* text=auto" , string lineEnding = " \r \n " )
668680 {
669681 // Constructs a graph that looks like:
670682 // * -- * -- * (modifications to c.txt)
@@ -700,6 +712,11 @@ private void ConstructRebaseTestRepository(Repository repo)
700712 string workdir = repo . Info . WorkingDirectory ;
701713 Commit commit = null ;
702714
715+ CreateAttributesFile ( repo , attributes ) ;
716+
717+ repo . Stage ( ".gitattributes" ) ;
718+ commit = repo . Commit ( "setup" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
719+
703720 Touch ( workdir , filePathA , fileContentA1 ) ;
704721 repo . Stage ( filePathA ) ;
705722 commit = repo . Commit ( "commit 1" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
@@ -714,29 +731,29 @@ private void ConstructRebaseTestRepository(Repository repo)
714731
715732 Branch masterBranch1 = repo . CreateBranch ( masterBranch1Name , commit ) ;
716733
717- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 ) ) ;
734+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 ) ) ;
718735 repo . Stage ( filePathB ) ;
719736 commit = repo . Commit ( "commit 4" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
720737
721- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 , fileContentB3 ) ) ;
738+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 , fileContentB3 ) ) ;
722739 repo . Stage ( filePathB ) ;
723740 commit = repo . Commit ( "commit 5" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
724741
725- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 , fileContentB3 , fileContentB4 ) ) ;
742+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 , fileContentB3 , fileContentB4 ) ) ;
726743 repo . Stage ( filePathB ) ;
727744 commit = repo . Commit ( "commit 6" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
728745
729746 repo . CreateBranch ( topicBranch1Name , commit ) ;
730747
731- Touch ( workdir , filePathC , string . Join ( Environment . NewLine , fileContentC1 , fileContentC2 ) ) ;
748+ Touch ( workdir , filePathC , string . Join ( lineEnding , fileContentC1 , fileContentC2 ) ) ;
732749 repo . Stage ( filePathC ) ;
733750 commit = repo . Commit ( "commit 7" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
734751
735- Touch ( workdir , filePathC , string . Join ( Environment . NewLine , fileContentC1 , fileContentC2 , fileContentC3 ) ) ;
752+ Touch ( workdir , filePathC , string . Join ( lineEnding , fileContentC1 , fileContentC2 , fileContentC3 ) ) ;
736753 repo . Stage ( filePathC ) ;
737754 commit = repo . Commit ( "commit 8" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
738755
739- Touch ( workdir , filePathC , string . Join ( Environment . NewLine , fileContentC1 , fileContentC2 , fileContentC3 , fileContentC4 ) ) ;
756+ Touch ( workdir , filePathC , string . Join ( lineEnding , fileContentC1 , fileContentC2 , fileContentC3 , fileContentC4 ) ) ;
740757 repo . Stage ( filePathC ) ;
741758 commit = repo . Commit ( "commit 9" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
742759
@@ -747,18 +764,18 @@ private void ConstructRebaseTestRepository(Repository repo)
747764 repo . Stage ( filePathD ) ;
748765 commit = repo . Commit ( "commit 10" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
749766
750- Touch ( workdir , filePathD , string . Join ( Environment . NewLine , fileContentD1 , fileContentD2 ) ) ;
767+ Touch ( workdir , filePathD , string . Join ( lineEnding , fileContentD1 , fileContentD2 ) ) ;
751768 repo . Stage ( filePathD ) ;
752769 commit = repo . Commit ( "commit 11" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
753770
754- Touch ( workdir , filePathD , string . Join ( Environment . NewLine , fileContentD1 , fileContentD2 , fileContentD3 ) ) ;
771+ Touch ( workdir , filePathD , string . Join ( lineEnding , fileContentD1 , fileContentD2 , fileContentD3 ) ) ;
755772 repo . Stage ( filePathD ) ;
756773 commit = repo . Commit ( "commit 12" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
757774
758775 repo . CreateBranch ( masterBranch2Name , commit ) ;
759776
760777 // Create commit / branch that conflicts with T1 and T2
761- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 + fileContentB3 + fileContentB4 ) ) ;
778+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 + fileContentB3 + fileContentB4 ) ) ;
762779 repo . Stage ( filePathB ) ;
763780 commit = repo . Commit ( "commit 13" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
764781 repo . CreateBranch ( conflictBranch1Name , commit ) ;
0 commit comments