libgit2 / libgit2/libgit2sharp

Repository.Init wants to write to workingDirectoryPath

Open
#1,861 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

Reproduction steps

Run the following code with workingDirectoryPath set to a write-protected directory path and gitDirectoryPath set to a writable directory path:

Lib2GitSharp.Repository.Init(workingDirectoryPath: "/", gitDirectoryPath: "/some/dir/.git")
Expected behavior

The Init() call works exactly as this git command: git --git-dir /some/dir/.git --work-tree /:

  • it creates a .git repository directory at /some/dir/.git with its config's core.worktree set to /
  • it does not touch the --work-tree directory / in any way and thus does not need write permissions in this directory
Actual behavior

An Exception of type Lib2GitException is thrown:
failed to initialize repository with template '.git': Permission denied

Version of LibGit2Sharp (release number or SHA1)

0.26.2 (NuGet)

Operating system(s) tested; .NET runtime tested

Linux 5.9.14-arch1-1 #1 SMP PREEMPT Sat, 12 Dec 2020 14:37:12 +0000 x86_64 GNU/Linux
Microsoft.NETCore.App 3.1.8

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Repository.Init entry point and reproduce the issue with a write-protected workingDirectoryPath and a writable gitDirectoryPath. Done means initialization creates the repository and sets core.worktree to the working directory without attempting to write there, matching the stated git command behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.