8000 Enforce repo.RetrieveStatus() test coverage · thatfrankdev/libgit2sharp@ef3c6b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef3c6b4

Browse files
committed
Enforce repo.RetrieveStatus() test coverage
1 parent 7cbd0c6 commit ef3c6b4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.IO;
34
using System.Linq;
45
using System.Text;
@@ -592,5 +593,52 @@ public void RetrievingTheStatusHonorsAssumedUnchangedMarkedIndexEntries()
592593
Assert.Equal("hello.txt", status.Modified.Single().FilePath);
593594
}
594595
}
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+
}
595643
}
596644
}

0 commit comments

Comments
 (0)
0