[RFC] Using Git's internal config system
cgit at cryptocrack.de
Wed Jun 5 12:06:58 CEST 2013
We have been discussing the feasibility of using Git's internal config
system instead of our own configuration file parser on IRC and on the
mailing list. It seems that this is doable -- however, creating a sane
upgrade path is not that easy.
What cgit config files currently look like:
What cgit config files might look like when using Git's internal config
cache-size = 1000
enable-index-links = 1
url = repo1.git
path = /path/to/repo1.git/
desc = Repository 1
url = repo2.git
path = /path/to/repo2.git/
desc = Repository 2
I was thinking of a way to support both syntaxes so that people have
enough time to migrate to the new format (the other possibility is just
switching to the new format without providing any backwards
compatibility). Since Git's config system does not allow dots inside
variable names, I suggest following implementation:
1. Use strbuf instead of fixed-size buffers to read lines from the
configuration file (I already submitted a patch for this).
2. Allow following syntax which allows for creating subsections for each
repository instead of using "repo.url" as a delimiter:
3. Support sections and internally map each configuration variable "var"
that is specified inside section "section" to "var.section" and each
"var" that is specified inside section 'repo "reponame"' to
"repo.reponame.var", respectively (that is exactly how Git does it
internally). Prefix section-less configuration variables with "core."
4. Deprecate the old configuration format.
5. Drop support for the old configuration format, remove legacy code and
use Git's internal config system instead in a future major release.
I prepared patches for 2 and 3. However, there are several issues with
the new syntax:
* We can no longer use "mimetype." in the core section. Solution is
simple: Create a separate "mimetype" section.
* We need to find an alternate syntax for "repo.module-link.name =
value". As far as I know, Git does not support nested sections. Does
anybody have an idea how to do this? We need something like:
url = foo.git
path = /some/path/to/foo/
desc = Foo repository
format = formatstring1
format = formatstring2
Maybe just use "module-link = " and allow delimiters to specify pairs
of paths and corresponding format strings?
* How do we support "section = " statements? Basically the same issue.
Ideas and suggestions welcome!
More information about the CGit