libgit2 / libgit2/libgit2sharp
Repositories with git-dir and work-dir should't create .git file in working directory
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
Reproduction steps
Repository.Init("/working/path", "/git/path");
Expected behavior
For most cases the whole point of doing this separation of working directory and git directory is to avoid the existence of .git file/folder in working directory
Actual behavior
The repo_is_worktree in repository.c of libgit2, should not checking for gitdir in working directory.
In config file, in git directory there is a field worktree = /working/path which could be used to find out which is the working directory.
My suggestion would be, in private Repository constructor to get the worktree value from config file in git-directory and pass it to the Proxy.git_repository_set_workdir in Repository class
instead of reading the value from options that were given from caller.
Future improvement would be not event passing the working directory, because it can be extracted from config file.
Hope to hear soon your opinion on this
Max
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Repository.Init and the private Repository constructor, then inspect Repository.cs around Proxy.git_repository_set_workdir. Compare that path with repo_is_worktree and gitdir handling in src/repository.c, using the worktree value in the git-directory config as described. Reproduce the issue with separate working and git paths and confirm that initialization no longer creates a .git file in the working directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100