|
1 | 1 | using System;
|
| 2 | +using System.Diagnostics; |
2 | 3 | using System.IO;
|
3 | 4 | using System.Linq;
|
4 | 5 | using System.Text;
|
@@ -592,5 +593,52 @@ public void RetrievingTheStatusHonorsAssumedUnchangedMarkedIndexEntries()
|
592 | 593 | Assert.Equal("hello.txt", status.Modified.Single().FilePath);
|
593 | 594 | }
|
594 | 595 | }
|
| 596 | + |
| 597 | + [Fact] |
| 598 | + public void CanHandleTwoStatusEntryChangesWithTheSamePath() |
| 599 | + { |
| 600 | + var path = InitNewRepository(); |
| 601 | + |
| 602 | + using (Repository repo = new Repository(path)) |
| 603 | + { |
| 604 | + Blob mainContent = OdbHelper.CreateBlob(repo, "awesome content\n"); |
| 605 | + Blob linkContent = OdbHelper.CreateBlob(repo, "../../objc/Nu.h"); |
| 606 | + |
| 607 | + const string filePath = "include/Nu/Nu.h"; |
| 608 | + |
| 609 | + var tdOld = new TreeDefinition() |
| 610 | + .Add(filePath, linkContent, Mode.SymbolicLink) |
| 611 | + .Add("objc/Nu.h", mainContent, Mode.NonExecutableFile); |
| 612 | + |
| 613 | + Tree tree = repo.ObjectDatabase.CreateTree(tdOld); |
| 614 | + |
| 615 | + Commit commit = repo.ObjectDatabase.CreateCommit(Constants.Signature, Constants.Signature, "A symlink", tree, Enumerable.Empty<Commit>(), false); |
| 616 | + repo.Refs.UpdateTarget("HEAD", commit.Id.Sha); |
| 617 | + repo.Reset(ResetMode.Mixed); |
| 618 | + |
| 619 | + string parentPath = Path.Combine(repo.Info.WorkingDirectory, "include/Nu"); |
| 620 | + |
| 621 | + Touch(parentPath, "Nu.h", "awesome content\n"); |
| 622 | + |
| 623 | + RepositoryStatus status = repo.RetrieveStatus( |
| 624 | + new StatusOptions{ DetectRenamesInIndex = true, DetectRenamesInWorkDir = true }); |
| 625 | + |
| 626 | + Assert.Equal(2, status.Count()); |
| 627 | + |
| 628 | + var expected = Path.Combine("include", "Nu", "Nu.h"); |
| 629 | + |
| 630 | + if (IsRunningOnUnix()) |
| 631 | + { |
| 632 | + Assert.Equal(expected, status.RenamedInWorkDir.Single().FilePath); |
| 633 | + Assert.Equal(expected, status.Missing.Single().FilePath); |
| 634 | + } |
| 635 | + else |
| 636 | + { |
| 637 | + Assert.Equal(expected, status.Modified.Single().FilePath); |
| 638 | + Assert.Equal(Path.Combine("objc", "Nu.h"), status.Missing.Single().FilePath); |
| 639 | + } |
| 640 | + |
| 641 | + } |
| 642 | + } |
595 | 643 | }
|
596 | 644 | }
|
0 commit comments