Skip to content

Commit e2f1399

Browse files
Edward Thomsonnulltoken
authored andcommitted
Repository: allow Options with a bare repo
Fix a minor logic bug, where we assumed that any RepositoryOptions would provide a workdir and index such that the repo is not bare.
1 parent db0b052 commit e2f1399

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

LibGit2Sharp.Tests/RepositoryOptionsFixture.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ public void CanOpenABareRepoAsIfItWasAStandardOneWithANonExisitingIndexFile()
5252
}
5353
}
5454

55+
[Fact]
56+
public void CanOpenABareRepoWithOptions()
57+
{
58+
var options = new RepositoryOptions { GlobalConfigurationLocation = null };
59+
60+
string path = SandboxBareTestRepo();
61+
using (var repo = new Repository(path, options))
62+
{
63+
Assert.True(repo.Info.IsBare);
64+
}
65+
}
66+
5567
[Fact]
5668
public void CanProvideADifferentWorkDirToAStandardRepo()
5769
{

LibGit2Sharp/Repository.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ public Repository(string path, RepositoryOptions options = null)
7676
"When overriding the opening of a bare repository, both RepositoryOptions.WorkingDirectoryPath an RepositoryOptions.IndexPath have to be provided.");
7777
}
7878

79-
isBare = false;
79+
if (!isWorkDirNull)
80+
{
81+
isBare = false;
82+
}
8083

8184
if (!isIndexNull)
8285
{

0 commit comments

Comments
 (0)