libgit2 / libgit2/libgit2sharp
gitdir
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 3.5k
- Forks
- 925
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
Problem Description
The Worktree API in LibGit2Sharp does not expose any property to retrieve the actual working directory path associated with a worktree (i.e., the folder where the code is checked out).
Currently, the Worktree object only provides:
Name→ the name of the worktree (e.g., "core")GitDirectory→ the path.git/worktrees/<name>, which does not correspond to the working directory
Due to this limitation, consumers must manually:
- Read the content of
.git/worktrees/<name>/gitdir - Use
Directory.GetParent()to resolve the real worktree folder path
This approach is both fragile and undocumented.
Expected Behavior
Expose a property like Worktree.WorkingDirectory (similar to Repository.Info.WorkingDirectory) that returns the actual working directory path of the worktree (e.g., C:\repo-core).
Example Workaround
var worktreePaths = new List<string>();
var gitDir = Path.Combine(repoPath, ".git", "worktrees");
foreach (var folder in Directory.GetDirectories(gitDir))
{
var gitdirFile = Path.Combine(folder, "gitdir");
if (File.Exists(gitdirFile))
{
var gitdirPath = File.ReadAllText(gitdirFile).Trim();
var worktreePath = Directory.GetParent(gitdirPath)?.FullName;
if (!string.IsNullOrEmpty(worktreePath))
worktreePaths.Add(worktreePath);
}
}
This code reads the .git/worktrees/<name>/gitdir file and manually resolves the worktree’s root folder. A native API would make this more reliable and developer-friendly.
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece pela Worktree API e compare-a com Repository.Info.WorkingDirectory. Rastreie como .git/worktrees//gitdir identifica o caminho do checkout e, em seguida, verifique se a nova propriedade retorna o diretório real do worktree, como C:\repo-core. Está concluído quando os consumidores não precisam mais ler e resolver o arquivo gitdir por conta própria.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, git
- Domínio
- backend-api-design, devtools
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 42/100