Re: [PATCH] gitweb: Fix @git_base_url_list usage

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

 



Petr Baudis <pasky@xxxxxxx> writes:

> As it is now, that array was never used because the customurl accessor was
> broken and ''unless @url_list'' never happenned.
>
> Signed-off-by: Petr Baudis <pasky@xxxxxxx>
> ---
>...
>  sub git_get_project_url_list {
>  	my $path = shift;
>  
> -	open my $fd, "$projectroot/$path/cloneurl" or return undef;
> +	open my $fd, "$projectroot/$path/cloneurl" or return wantarray ? () : undef;
>  	my @git_project_url_list = map { chomp; $_ } <$fd>;
>  	close $fd;

Why on earth do you want to use wantarray for something like
this?

It's not like you are implementinging any fancy DWIM magic.

Isn't

	open my $fd, "foobar" or return;

much easier to read?

#!/usr/bin/perl

sub return_undef {
	open my $fd, "no-such-file"
	    or return wantarray ? () : undef;
}
sub return_broken {
	open my $fd, "no-such-file"
	    or return undef;
}

sub return_empty {
	open my $fd, "no-such-file"
	    or return;
}

my $returned_undef_1 = return_undef();
my ($returned_undef_2) = return_undef();
my @returned_undef = return_undef();

my $returned_broken_1 = return_broken();
my ($returned_broken_2) = return_broken();
my @returned_broken = return_broken();

my $returned_empty_1 = return_empty();
my ($returned_empty_2) = return_empty();
my @returned_empty = return_empty();

printf "U %d B %d E %d\n",
    scalar(@returned_undef),
    scalar(@returned_broken),
    scalar(@returned_empty);

for ($returned_undef_1,
     $returned_undef_2,
     $returned_broken_1,
     $returned_broken_2,
     $returned_empty_1,
     $returned_empty_2) {
	print "What I said was bogus.\n" if (defined $_);
}

-
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]