git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Sam Vilain <samv@catalyst.net.nz>
Cc: Sam Vilain <sam.vilain@catalyst.net.nz>,
	Frank Lichtenheld <frank@lichtenheld.de>,
	git@vger.kernel.org, Petr Baudis <pasky@suse.cz>
Subject: Re: [PATCH] perl: add new module Git::Config for cached 'git config' access
Date: Thu, 9 Apr 2009 01:13:53 +0200	[thread overview]
Message-ID: <200904090113.54272.jnareb@gmail.com> (raw)
In-Reply-To: <49DC8002.6050503@catalyst.net.nz>

On Wed, 8 Apr 2009, Sam Vilain wrote:
> Jakub Narebski wrote:
>>
>> By the way, did you take a look how cached 'git config' access and
>> typecasting is done in gitweb?  See commit b201927 (gitweb: Read
>> repo config using 'git config -z -l') and following similar commits.
> 
> Right ... sure, looks fairly straightforward.  I guess gitweb could 
> potentially use this tested module instead of including that code 
> itself.  Also various parts of git-svn... anything really.

Well... first, gitweb use of config files is simplified to what, I guess,
you want, because it only considers _reading_ config, and doesn't worry
about writing and (what is I guess most difficult) rewriting config file.

Second, gitweb doesn't even use Git.pm (although "gitweb caching" project
by Lea Wiemann from GSoC 2008 introduced Git::Repo, the alternate OO
interface, and used it in caching gitweb).  This has the advantage of
being slightly easier to install... but we require git anyway, so it
is not much more diffucult requiring perl-Git / Git.pm.

> 
> I actually wrote this code because I wanted something a bit nicer for 
> writing the mirror-sync initial implementations.  And I wanted to have a 
> bit of control over when values get committed, and save work for 
> reading, so I wrote this.

Well, you could have written in C instead ;-)

>>> Any more gremlins? 
>>>     
>> I have nor examined your patch in detail; I'll try to do it soon,
>> but with git config file parsing there lies following traps.
>>
>> 1. In fully qualified variable name section name and variable name
>>    have to be compared case insensitive (or normalized, i.e.
>>    lowercased), while subsection part (if it exists) is case sensitive.
> 
> I noticed that 'git config' hides this by normalising the case of what 
> it outputs with 'git config --list'; do you think anything special is 
> required in light of this?

I'm not sure. I was thinking that get() method should normalize its
arguments before comparing... but I am not sure if it is necessary
(or even if it is a good idea).

>> 2. When coercing type to bool, you need to remember (and test) that
>>    there are values which are truish (no value, 'true', 'yes', non-zero
>>    integer usually 1), values which are falsish (empry, 'false', 'no',
>>    0); other values IIRC are truish too.
> 
> Yep, see the Git::Config::boolean mini-package which has a list of 
> those.  I think I used the documented legal values, which are 'true', 
> 'yes' and '1' for affirmative and 'false', 'no' and '0' for negative.  I 
> guess I could make that include non-zero integers as well.

They are, from what I understand, empty value, 'false', 'no' and '0' for
negative, all else is positive (which includes no value, 'true', 'yes'
and '1').  But you'd better check the C code yourself.

[...]
>> Why not represent it simply as an 'undef'? You can always distinguish 
>> between not defined and not existing by using 'exists'...
>>   
> 
> I don't like 'undef' being a data value.

Why not? It is IMHO the most natural way.

>                                           In this case I was already  
> using setting a value to undef to tell the module to remove the key from 
> the config file.

Why not use 'delete' to remove hash element, and 'exists' to check
whether it exists?


-- 
Jakub Narebski
Poland

  reply	other threads:[~2009-04-08 23:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-05 23:46 [PATCH] perl: add new module Git::Config for cached 'git config' access Sam Vilain
2009-04-05 23:46 ` [PATCH] perl: make Git.pm use new Git::Config module Sam Vilain
2009-04-06  9:29 ` [PATCH] perl: add new module Git::Config for cached 'git config' access Frank Lichtenheld
2009-04-06 22:50   ` Sam Vilain
2009-04-07 12:01     ` Jakub Narebski
2009-04-08  5:49       ` Sam Vilain
2009-04-08 10:18         ` Jakub Narebski
2009-04-08 10:44           ` Sam Vilain
2009-04-08 23:13             ` Jakub Narebski [this message]
2009-04-08  6:29       ` Junio C Hamano
2009-04-08  9:50         ` Sam Vilain
2009-04-08 18:51           ` Junio C Hamano
2009-04-08  8:12 ` Petr Baudis

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=200904090113.54272.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=frank@lichtenheld.de \
    --cc=git@vger.kernel.org \
    --cc=pasky@suse.cz \
    --cc=sam.vilain@catalyst.net.nz \
    --cc=samv@catalyst.net.nz \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).