libgit2sharp
libgit2sharp copied to clipboard
Worktrees.Add throws an exception if a slash is in the branch name
Reproduction steps
have a repository with the branches
- main [default]
- feature/branch-name
Clone the repository and add the worktree.
SourceCode:
var cloneOptions = new CloneOptions()
{
CredentialsProvider = (_url, _user, _cred) => this.Credentials,
Checkout = true,
RecurseSubmodules = true,
};
this.gitRepositoryPath = Repository.Clone(this.SourceUrl, this.WorkdirPath, cloneOptions);
using (var repo = new Repository(this.gitRepositoryPath))
{
var path = Path.Combine(this.WorkdirPath, "..", this.Branch);
repo.Worktrees.Add(this.Branch, path, false);
}
Expected behavior
Worktree should be created
Actual behavior
Exception is thrown: failed to make directory 'xxx/.git/worktrees/feature/branch-name': The system cannot find the path specified.
Version of LibGit2Sharp (release number or SHA1)
0,26, 0.27.0-preview-0182
Operating system(s) tested; .NET runtime tested
Windows 10, Windows Server 2016, .Net Framework 4.8
I have this same issue :(