Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Is there a way to add safe.directory '*' via libgit2 #2058

Open
belkhir-aziz opened this issue Aug 31, 2023 · 3 comments
Open

[Question] Is there a way to add safe.directory '*' via libgit2 #2058

belkhir-aziz opened this issue Aug 31, 2023 · 3 comments

Comments

@belkhir-aziz
Copy link

I want to avoid executing commands and updating files manually.
Is there an existing API within libgit2 that replace this command => git config --global --add safe.directory '*'

@maw136
Copy link

maw136 commented Oct 5, 2023

Hi, Is there an issue with using Repository.Config of Configuration type. Specifically Set<> family of methods?
From the top of my head your call would look like:
repostiory.Config.Set("save.directory", "*");
Or am I missing something?
Be advised that I haven't used the library yet and I am just getting familiar with the API - hoping to use it in a following months.

@BastianKamp
Copy link

Hi, Is there an issue with using Repository.Config of Configuration type. Specifically Set<> family of methods? From the top of my head your call would look like: repostiory.Config.Set("save.directory", "*"); Or am I missing something? Be advised that I haven't used the library yet and I am just getting familiar with the API - hoping to use it in a following months.

Yes. I get the error "repository path .... is not owned by current user" when i try to create the repository with:
new Repository(workRepoPath)

That is the reason why i want to add the save directory option.

@AlexSchNev
Copy link

AlexSchNev commented Dec 8, 2023

Hi,
you would need any local repository, which you can access, and create a configuration for this one.
With this configuration instance, you are able to change global settings.
For Example, if you have an existing local repository under LocalPath, then you could do the following:
Configuration.BuildFrom(LocalPath).Add("safe.directory", "*", ConfigurationLevel.Global)
This would set the same global configuration value as: git config --global --add safe.directory '*'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants