Skip to content

Commit df12a77

Browse files
committed
Enforce repo.RetrieveStatus() test coverage
1 parent d8a04a4 commit df12a77

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,5 +592,40 @@ public void RetrievingTheStatusHonorsAssumedUnchangedMarkedIndexEntries()
592592
Assert.Equal("hello.txt", status.Modified.Single().FilePath);
593593
}
594594
}
595+
596+
[Fact]
597+
public void CanHandleTwoStatusEntryChangesWithTheSamePath()
598+
{
599+
var path = InitNewRepository();
600+
601+
using (Repository repo = new Repository(path))
602+
{
603+
Blob mainContent = OdbHelper.CreateBlob(repo, "awesome content\n");
604+
Blob linkContent = OdbHelper.CreateBlob(repo, "../../objc/Nu.h");
605+
606+
const string filePath = "include/Nu/Nu.h";
607+
608+
var tdOld = new TreeDefinition()
609+
.Add(filePath, linkContent, Mode.SymbolicLink)
610+
.Add("objc/Nu.h", mainContent, Mode.NonExecutableFile);
611+
612+
Tree tree = repo.ObjectDatabase.CreateTree(tdOld);
613+
614+
Commit commit = repo.ObjectDatabase.CreateCommit(Constants.Signature, Constants.Signature, "A symlink", tree, Enumerable.Empty<Commit>(), false);
615+
repo.Refs.UpdateTarget("HEAD", commit.Id.Sha);
616+
repo.Reset(ResetMode.Mixed);
617+
618+
string parentPath = Path.Combine(repo.Info.WorkingDirectory, "include/Nu");
619+
620+
Touch(parentPath, "Nu.h", "awesome content\n");
621+
622+
RepositoryStatus status = repo.RetrieveStatus(
623+
new StatusOptions{ DetectRenamesInIndex = true, DetectRenamesInWorkDir = true });
624+
625+
Assert.Equal(2, status.Count());
626+
Assert.Equal(Path.Combine("include", "Nu", "Nu.h"), status.Modified.Single().FilePath);
627+
Assert.Equal(Path.Combine("objc", "Nu.h"), status.Missing.Single().FilePath);
628+
}
629+
}
595630
}
596631
}

0 commit comments

Comments
 (0)