@@ -190,15 +190,21 @@ int IEqualityComparer<CompletedRebaseStepInfo>.GetHashCode(CompletedRebaseStepIn
190
190
/// <summary>
191
191
/// Verify a single rebase, but in more detail.
192
192
/// </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 )
195
201
{
196
202
SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
197
203
var path = Repository . Init ( scd . DirectoryPath ) ;
198
204
199
205
using ( Repository repo = new Repository ( path ) )
200
206
{
201
- ConstructRebaseTestRepository ( repo ) ;
207
+ ConstructRebaseTestRepository ( repo , attributes , lineEnding ) ;
202
208
203
209
Branch initialBranch = repo . Branches [ topicBranch1Name ] ;
204
210
Branch upstreamBranch = repo . Branches [ masterBranch2Name ] ;
@@ -262,9 +268,9 @@ public void VerifyRebaseDetailed()
262
268
263
269
List < ObjectId > expectedTreeIds = new List < ObjectId > ( )
264
270
{
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 ] ) ,
268
274
} ;
269
275
270
276
List < Commit > rebasedCommits = repo . Commits . QueryBy ( commitFilter ) . ToList ( ) ;
@@ -591,18 +597,24 @@ public void CurrentStepInfoIsNullWhenNotRebasing()
591
597
}
592
598
}
593
599
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 )
596
608
{
597
609
SelfCleaningDirectory scd = BuildSelfCleaningDirectory ( ) ;
598
610
var path = Repository . Init ( scd . DirectoryPath ) ;
599
611
using ( Repository repo = new Repository ( path ) )
600
612
{
601
- ConstructRebaseTestRepository ( repo ) ;
613
+ ConstructRebaseTestRepository ( repo , attributes , lineEnding ) ;
602
614
603
615
repo . Checkout ( topicBranch1Name ) ;
604
616
605
- Branch topicBranch1Prime = repo . CreateBranch ( topicBranch1PrimeName , masterBranch1Name ) ;
617
+ Branch topicBranch1Prime = repo . CreateBranch ( topicBranch1PrimeName , masterBranch1Name ) ;
606
618
607
619
string newFileRelativePath = "new_file.txt" ;
608
620
Touch ( repo . Info . WorkingDirectory , newFileRelativePath , "New Content" ) ;
@@ -631,7 +643,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
631
643
} ;
632
644
633
645
repo . Rebase . Start ( null , upstreamBranch , null , Constants . Identity2 , options ) ;
634
- ObjectId secondCommitExpectedTreeId = new ObjectId ( "ac04bf04980c9be72f64ba77fd0d9088a40ed681" ) ;
646
+ ObjectId secondCommitExpectedTreeId = new ObjectId ( expectedShaText ) ;
635
647
Signature secondCommitAuthorSignature = Constants . Signature ;
636
648
Identity secondCommitCommiterIdentity = Constants . Identity2 ;
637
649
@@ -642,7 +654,7 @@ public void CanRebaseHandlePatchAlreadyApplied()
642
654
Assert . NotNull ( rebaseResults [ 1 ] . Commit ) ;
643
655
644
656
// 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 ) ;
646
658
Assert . True ( Signature . Equals ( secondCommitAuthorSignature , rebaseResults [ 1 ] . Commit . Author ) ) ;
647
659
Assert . Equal < string > ( secondCommitCommiterIdentity . Name , rebaseResults [ 1 ] . Commit . Committer . Name , StringComparer . Ordinal ) ;
648
660
Assert . Equal < string > ( secondCommitCommiterIdentity . Email , rebaseResults [ 1 ] . Commit . Committer . Email , StringComparer . Ordinal ) ;
@@ -664,7 +676,7 @@ public void RebasingInBareRepositoryThrows()
664
676
}
665
677
}
666
678
667
- private void ConstructRebaseTestRepository ( Repository repo )
679
+ private void ConstructRebaseTestRepository ( Repository repo , string attributes = "* text=auto" , string lineEnding = " \r \n " )
668
680
{
669
681
// Constructs a graph that looks like:
670
682
// * -- * -- * (modifications to c.txt)
@@ -700,6 +712,11 @@ private void ConstructRebaseTestRepository(Repository repo)
700
712
string workdir = repo . Info . WorkingDirectory ;
701
713
Commit commit = null ;
702
714
715
+ CreateAttributesFile ( repo , attributes ) ;
716
+
717
+ repo . Stage ( ".gitattributes" ) ;
718
+ commit = repo . Commit ( "setup" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
719
+
703
720
Touch ( workdir , filePathA , fileContentA1 ) ;
704
721
repo . Stage ( filePathA ) ;
705
722
commit = repo . Commit ( "commit 1" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
@@ -714,29 +731,29 @@ private void ConstructRebaseTestRepository(Repository repo)
714
731
715
732
Branch masterBranch1 = repo . CreateBranch ( masterBranch1Name , commit ) ;
716
733
717
- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 ) ) ;
734
+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 ) ) ;
718
735
repo . Stage ( filePathB ) ;
719
736
commit = repo . Commit ( "commit 4" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
720
737
721
- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 , fileContentB3 ) ) ;
738
+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 , fileContentB3 ) ) ;
722
739
repo . Stage ( filePathB ) ;
723
740
commit = repo . Commit ( "commit 5" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
724
741
725
- Touch ( workdir , filePathB , string . Join ( Environment . NewLine , fileContentB1 , fileContentB2 , fileContentB3 , fileContentB4 ) ) ;
742
+ Touch ( workdir , filePathB , string . Join ( lineEnding , fileContentB1 , fileContentB2 , fileContentB3 , fileContentB4 ) ) ;
726
743
repo . Stage ( filePathB ) ;
727
744
commit = repo . Commit ( "commit 6" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
728
745
729
746
repo . CreateBranch ( topicBranch1Name , commit ) ;
730
747
731
- Touch ( workdir , filePathC , string . Join ( Environment . NewLine , fileContentC1 , fileContentC2 ) ) ;
748
+ Touch ( workdir , filePathC , string . Join ( lineEnding , fileContentC1 , fileContentC2 ) ) ;
732
749
repo . Stage ( filePathC ) ;
733
750
commit = repo . Commit ( "commit 7" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
734
751
735
- Touch ( workdir , filePathC , string . Join ( Environment . NewLine , fileContentC1 , fileContentC2 , fileContentC3 ) ) ;
752
+ Touch ( workdir , filePathC , string . Join ( lineEnding , fileContentC1 , fileContentC2 , fileContentC3 ) ) ;
736
753
repo . Stage ( filePathC ) ;
737
754
commit = repo . Commit ( "commit 8" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
738
755
739
- Touch ( workdir , filePathC , string . Join ( Environment . NewLine , fileContentC1 , fileContentC2 , fileContentC3 , fileContentC4 ) ) ;
756
+ Touch ( workdir , filePathC , string . Join ( lineEnding , fileContentC1 , fileContentC2 , fileContentC3 , fileContentC4 ) ) ;
740
757
repo . Stage ( filePathC ) ;
741
758
commit = repo . Commit ( "commit 9" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
742
759
@@ -747,18 +764,18 @@ private void ConstructRebaseTestRepository(Repository repo)
747
764
repo . Stage ( filePathD ) ;
748
765
commit = repo . Commit ( "commit 10" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
749
766
750
- Touch ( workdir , filePathD , string . Join ( Environment . NewLine , fileContentD1 , fileContentD2 ) ) ;
767
+ Touch ( workdir , filePathD , string . Join ( lineEnding , fileContentD1 , fileContentD2 ) ) ;
751
768
repo . Stage ( filePathD ) ;
752
769
commit = repo . Commit ( "commit 11" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
753
770
754
- Touch ( workdir , filePathD , string . Join ( Environment . NewLine , fileContentD1 , fileContentD2 , fileContentD3 ) ) ;
771
+ Touch ( workdir , filePathD , string . Join ( lineEnding , fileContentD1 , fileContentD2 , fileContentD3 ) ) ;
755
772
repo . Stage ( filePathD ) ;
756
773
commit = repo . Commit ( "commit 12" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
757
774
758
775
repo . CreateBranch ( masterBranch2Name , commit ) ;
759
776
760
777
// 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 ) ) ;
762
779
repo . Stage ( filePathB ) ;
763
780
commit = repo . Commit ( "commit 13" , Constants . Signature , Constants . Signature , new CommitOptions ( ) ) ;
764
781
repo . CreateBranch ( conflictBranch1Name , commit ) ;
0 commit comments