8000 Ensure Diff.Compare() cannot apply on a bare repository · Saaman/libgit2sharp@b447d67 · GitHub
[go: up one dir, main page]

Skip to content

Commit b447d67

Browse files
committed
Ensure Diff.Compare() cannot apply on a bare repository
1 parent dc5b672 commit b447d67

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

LibGit2Sharp.Tests/DiffTreeToTargetFixture.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,19 @@ public void CanCopeWithEndOfFileNewlineChanges()
321321
Assert.Equal(expected.ToString(), changes.Patch);
322322
}
323323
}
324+
325+
[Fact]
326+
public void CompareATreeInABareRepositoryShouldRaiseException()
327+
{
328+
using (var repo = new Repository(BareTestRepoPath))
329+
{
330+
Assert.Throws<BareRepositoryException>(
331+
() => repo.Diff.Compare(repo.Head.Tip.Tree, DiffTargets.WorkingDirectory));
332+
Assert.Throws<BareRepositoryException>(
333+
() => repo.Diff.Compare(repo.Head.Tip.Tree, DiffTargets.Index));
334+
Assert.Throws<BareRepositoryException>(
335+
() => repo.Diff.Compare(repo.Head.Tip.Tree, DiffTargets.WorkingDirectory|DiffTargets.Index));
336+
}
337+
}
324338
}
325339
}

0 commit comments

Comments
 (0)
0