git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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-
Previous: Jakub NarebskiNext: Johannes Schindelin
Message 4 of 5 in “git svn forking an awful lot of "git config"s”
  1. Johannes SchindelinFeb 20, 2008
  2. Eric WongFeb 20, 2008
  3. Jakub NarebskiFeb 20, 2008
  4. Nagy BalázsFeb 20, 2008
  5. Johannes SchindelinFeb 21, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.