git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nagy Balázs" <js@iksz.hu>
To: Jakub Narebski <jnareb@gmail.com>
Cc: Eric Wong <normalperson@yhbt.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	git@vger.kernel.org
Subject: Re: git svn forking an awful lot of "git config"s
Date: Thu, 21 Feb 2008 00:57:36 +0100	[thread overview]
Message-ID: <47BCBE70.8020706@iksz.hu> (raw)
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-

  reply	other threads:[~2008-02-20 23:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-20 15:27 git svn forking an awful lot of "git config"s Johannes Schindelin
2008-02-20 22:39 ` Eric Wong
2008-02-20 23:31   ` Jakub Narebski
2008-02-20 23:57     ` Nagy Balázs [this message]
2008-02-21  0:18   ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47BCBE70.8020706@iksz.hu \
    --to=js@iksz.hu \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).