Re: git svn forking an awful lot of "git config"s
- From
Nagy Balázs <js@iksz.hu>
- Date
- Feb 20, 2008, 23:57 UTC
- Message-ID
- <47BCBE70.8020706@iksz.hu>
- In-Reply-To
- <m3ejb7tdbo.fsf@localhost.localdomain>
Jakub Narebski wrote:
> Take a look how gitweb uses "git config -z -l" to read all config > in one go, and save it to hash for later use, lazily.
...
> This is an alternate solution, better for simple scripts and one-off > scripts (you don't need to write "git config -z -l" parser), but > I think that additional eval might be not good for performance. >
Maybe I'll finish my git-depot proof of concept script someday. Here's the configuration reader method I use (please note git-depot doesn't use repositories -- yet):
sub readConfig
{
my $self = shift;
my ($cfg, @cfg, $cat, $key, $val); $cfg = Git::command(qw/config -z -l/);
@cfg = split(/\000/m, $cfg);
%{$self->{cfg}} = ();
foreach (@cfg) {
if (($cat, $key, $val) = (/\A(\S+)\.(\S+)[\n\r]+^(.+)\Z/ms)) {
next unless $cat eq 'depot';
$self->{cfg}->{$key} = $val;
}
}
return 1;
}Works like a charm.
-- -jul-