[RFC] Implementing git config handling in Git.pm
From: Frank Lichtenheld <hidden>
Date: 2016-06-15 22:43:11
Hi.
A week ago or so when I presented my GITCVS::config patch I mentioned
that we should better implement most of it in Git.pm. I would like to
do so but get a bit of input first on how to implement it.
Targets:
1) We should offer to parse the config only once since that is
a huge performance gain if the caller wants to use several
values from it.
2) The parsing should be complete and safe.
3) If at all possible, we should not have to implement a
complete parser in Perl, since that is just needless
code to maintain.
Possible Solutions:
1) Call git-config.
Pro: Easy to implement
Contra: Violates at least target 2. Neither git-config --get nor
git-config --list offer a complete and safe view on the config
file. Just try including = in a subsection name (--list) or newlines in
a value (both) to see what I mean.
2) Extend git-config to give a machine parsable output and then
proceed with solution 1
Pro: Still reasonably easy to implement (?). Would benefit
other scripts, too.
Contra: Neither the fastest nor the most flexible
solution.
3) Try to use the C code from config.c directly.
Pro: Probably the fastest solution due to avoiding the
forks.
Contra: Probably a bit more complex (any XS experts here?),
both to implement and to maintain.
4) Implement an own git config parser in Perl
Pro: Might be actually easier than 3 and faster than 2
Contra: See target 3
I would go for solution 2. Any reason to prefer one of the
others (or one I didn't even think of)?
Gruesse,
--
Frank Lichtenheld [off-list ref]
www: http://www.djpig.de/