Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LibGit2Sharp.Tests/RepositoryFixture.cs9
-rw-r--r--LibGit2Sharp/Repository.cs10
2 files changed, 18 insertions, 1 deletions
diff --git a/LibGit2Sharp.Tests/RepositoryFixture.cs b/LibGit2Sharp.Tests/RepositoryFixture.cs
index 077562ff..2b85ae84 100644
--- a/LibGit2Sharp.Tests/RepositoryFixture.cs
+++ b/LibGit2Sharp.Tests/RepositoryFixture.cs
@@ -30,6 +30,15 @@ namespace LibGit2Sharp.Tests
}
[Fact]
+ public void AccessingTheIndexInABareRepoThrows()
+ {
+ using (var repo = new Repository(BareTestRepoPath))
+ {
+ Assert.Throws<LibGit2Exception>(() => repo.Index);
+ }
+ }
+
+ [Fact]
public void CanCreateStandardRepo()
{
SelfCleaningDirectory scd = BuildSelfCleaningDirectory();
diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs
index 2593bcb3..680d9670 100644
--- a/LibGit2Sharp/Repository.cs
+++ b/LibGit2Sharp/Repository.cs
@@ -101,7 +101,15 @@ namespace LibGit2Sharp
/// </summary>
public Index Index
{
- get { return index; }
+ get
+ {
+ if (index == null)
+ {
+ throw new LibGit2Exception("Index is not available in a bare repository.");
+ }
+
+ return index;
+ }
}
/// <summary>