Re: git svn forking an awful lot of "git config"s

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux