Re: [PATCH] gitweb: merge boolean feature subroutines
- From
- Matt Kraai <kraai@ftbfs.org>
- Date
- Jan 3, 2009, 16:40 UTC
- Message-ID
- <20090103164024.GA4205@ftbfs.org>
- In-Reply-To
- <9b18b3110901030818i242d81ccl20ef3f264ec64cad@mail.gmail.com>
On Sat, Jan 03, 2009 at 05:18:44PM +0100, demerphq wrote:
Show 21 quoted lines
> 2009/1/3 Matt Kraai <kraai@ftbfs.org>:
> [...]
> > -sub feature_blame {
> > - my ($val) = git_get_project_config('blame', '--bool');
> > +sub feature_bool {
> > + my $key = shift;
> > + my ($val) = git_get_project_config($key, '--bool');
> >
> > if ($val eq 'true') {
> > return 1;
>
> Maybe that should be:
>
> return ($val eq 'true');
>
> as It is not a good idea to use 0 as a replacement for perls false, as
> the two have different behaviour.
>
> $perl -wle'my $val=shift; my $x=$val eq "true"; print "<$_>" for $x, 0+$x' false
> <>
> <0>I don't think Perl has *a* false value, but rather has multiple values that are treated as false, such as undef, zero, and the empty string. Personally, I find 0 clearer than the empty string, but that's probably just my C bias sneaking in.
All of the boolean feature values use 0 or 1, so if this should be changed, I think it should probably be done as a separate patch.
-- Matt http://ftbfs.org/