Skip to content

Repository.Init wants to write to workingDirectoryPath #1861

Open
@vogeljo

Description

@vogeljo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions