Skip to content

Commit 1533ddf

Browse files
author
Edward Thomson
committed
Test that bare repositories have no index
1 parent 296ee5d commit 1533ddf

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void CanCreateBareRepo()
2626
Assert.Null(repo.Info.WorkingDirectory);
2727
Assert.Equal(Path.GetFullPath(repoPath), repo.Info.Path);
2828
Assert.True(repo.Info.IsBare);
29+
Assert.Throws<BareRepositoryException>(() => { var idx = repo.Index; });
2930

3031
AssertInitializedRepository(repo, "refs/heads/master");
3132

LibGit2Sharp/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public Index Index
231231
throw new BareRepositoryException("Index is not available in a bare repository.");
232232
}
233233

234-
return index.Value;
234+
return index != null ? index.Value : null;
235235
}
236236
}
237237

0 commit comments

Comments
 (0)