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

can not set multiple configs at the same time #757

Closed
thisconnect opened this issue Oct 18, 2015 · 2 comments
Closed

can not set multiple configs at the same time #757

thisconnect opened this issue Oct 18, 2015 · 2 comments

Comments

@thisconnect
Copy link

I tried to set multiple configs with Promise.all, but it seems as nodegit / libgit2 will lock the config on the first Config.setString call. So my first question is: Is it correct that it is only possible to set 1 config at the time?

Failed to lock file '/user/tom/.gitconfig.lock' for writing: 
    ---------------------------------------------------------------------
      operator: error
      expected: |-
        undefined
      actual: |-
        [Error: Failed to lock file '/user/tom/.gitconfig.lock' for writing: ]
      at: tryCallOne (/user/tom/project/nodegit-kit/node_modules/nodegit/node_modules/nodegit-promise/lib/core.js:37:12)

Second question: Is Config.setString always --global?
I would like to set the local config of the repo:

Finally, Git looks for configuration values in the configuration file in the Git directory (.git/config) of whatever repository you’re currently using. These values are specific to that single repository.
http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

From the git docs there seems to be system, global and local. Can this be configured?

@johnhaley81
Copy link
Collaborator

You'll have to get it off of the repository object if you want it at that level http://www.nodegit.org/api/repository/#config

I do think that the it will only allow you to set one at a time right now. There will be a config.lock file in your .git directory that will cause them to thread lock.

@thisconnect
Copy link
Author

You are right, setting the config off the repository will store it specific for that repo in (.git/config)

Setting configs sequentially works well, it was just so tempting to use the promises in parallel with Promise.all :)

Reading user.name from a repo without specific configs will find the global Git user.name, same behavior on Git CLI.

@johnhaley81 Thanks for your help!

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

2 participants