What system does git-config
use to manage configuration? Is it something that's publicly available as a stand-alone library/tool? or is it tightly interwined into git?
I'd like to have something like it for my project.
Is there a library that I can use which provides similar functionality? Or should I just write my own tool/library?
For Python, seems ConfigParser cannot be used directly due to the leading spaces in git config file. But it could be used in this way
from ConfigParser import ConfigParser
from StringIO import StringIO
with open('.gitconfig') as f:
c = f.readlines()
cp = ConfigParser()
cp.readfp(StringIO(''.join([l.lstrip() for l in c])))
The code is custom. Have a look for yourself (see builtin-config.c, config.c).
See the license (GPL v2) for details on reuse.
It is not a generic library, nor is it a generic tool (though you might be able to use it as one if you alway pass --file
and are OK with the way it does subsections), so it will take some work to adapt the code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With