Re: [PATCH] gitweb: Refactor git_header_html

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

 



Jakub Narebski <jnareb@xxxxxxxxx> writes:

> P.S. I wonder if print_search_form() should also get passed %opts as
> one of its parameters...

I do not particularly care for this:

	sub foo {
        	my %opts = @_;

		if ($opts{-option} eq 'bar') {
                	... do this ...

style, which lets a caller pass any random typo to the callee, like so:

	foo(-optoin => 'value');

But maybe it is just me.

> +sub print_header_links {
> +	my %opts = @_;
> +
> +	# print out each stylesheet that exist, providing backwards capability
> +	# for those people who defined $stylesheet in a config file
> +	if (defined $stylesheet) {
> +		print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\n";
> +	} else {
> +		foreach my $stylesheet (@stylesheets) {
> +			next unless $stylesheet;
> +			print '<link rel="stylesheet" type="text/css" href="'.esc_url($stylesheet).'"/>'."\n";
> +		}
> +	}
> +	if ($opts{'-feed'}) {
> +		print_feed_meta();
> +	}

Here, we refrain from showing the <link> elements that are related to the
RSS/Atom feeds (if we know what $project we are talking about), or <link>
elements that are related to the project list (html top page and opml) if
we are not showing a normal return, as $opts{'-feed'} is true only when we
are returning '200 OK'.

The original implementation, even though it used statement modifiers after
this print_feed_meta(), was much easier to follow, at least for me. The
association between "feed-meta" and "200 OK" was close together and more
direct.

> ...
> -		}
> -	}
> -	print_feed_meta()
> -		if ($status eq '200 OK');

Other than that, this looks a correct no-op patch that makes the resulting
smaller functions easier to grok.

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