Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/Microsoft.Build.Tasks.Git.UnitTests/GitRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,33 @@ public void OpenRepository_Version1_Extensions()
Assert.Null(repository.WorkingDirectory);
}

[Fact]
public void OpenRepository_Version1_RelativeWorktreesExtension()
{
using var temp = new TempRoot();

var workingDir = temp.CreateDirectory();
var gitDir = workingDir.CreateDirectory(".git");

gitDir.CreateFile("HEAD");
gitDir.CreateFile("config").WriteAllText(@"
[core]
repositoryformatversion = 1
[extensions]
relativeWorktrees = true
");

Assert.True(GitRepository.TryFindRepository(gitDir.Path, out var location));
Assert.Equal(gitDir.Path, location.CommonDirectory);
Assert.Equal(gitDir.Path, location.GitDirectory);
Assert.Null(location.WorkingDirectory);

var repository = GitRepository.OpenRepository(location, GitEnvironment.Empty);
Assert.Equal(gitDir.Path, repository.CommonDirectory);
Assert.Equal(gitDir.Path, repository.GitDirectory);
Assert.Null(repository.WorkingDirectory);
}

[Fact]
public void OpenRepository_Version1_UnknownExtension()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal sealed class GitRepository
private const string GitModulesFileName = ".gitmodules";

private static readonly ImmutableArray<string> s_knownExtensions =
ImmutableArray.Create("noop", "preciousObjects", "partialclone", "worktreeConfig");
ImmutableArray.Create("noop", "preciousObjects", "partialclone", "worktreeConfig", "relativeWorktrees");

public GitConfig Config { get; }

Expand Down