git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] gitweb: Few doublequoted strings cleanups

From
Junio C Hamano <junkio@cox.net>
Date
Apr 3, 2007, 20:20 UTC
Message-ID
<7vlkh9w6pa.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200704012223.00087.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Replace a few doublequoted strings by theirs singlequoted equivalent,
> lose doublequotes around variable in string containing only
> of a variable name, use '' consistently as an empty string (and not
> sometimes as "").

Why? I do not in particular like a micro-cleanup like this (it seems more of personal taste than cleanup).

> -	} elsif ($char eq "\\") {
> +	} elsif ($char eq '\\') {
>  		$diff_class = " incomplete";
>  	}

Especially this makes a shell scripter think twice before realizing that this is Perl and a backslash expands inside single quotes. In other words, I find that the former is easier to read.

Show 6 quoted lines
> @@ -1052,7 +1052,7 @@ sub git_get_projects_list {
>  		my $dir = $projects_list . ($filter ? "/$filter" : '');
>  		# remove the trailing "/"
>  		$dir =~ s!/+$!!;
> -		my $pfxlen = length("$dir");
> +		my $pfxlen = length($dir);
On the other hand, I think this makes the code easier to read.
> @@ -1261,7 +1261,7 @@ sub parse_tag {
>  		} elsif ($line =~ m/--BEGIN/) {
>  			push @comment, $line;
>  			last;

One thing I noticed is that we seem to have needless 'm' as in the above m/--BEGIN/ in some places. My preferences are (this falls within "personal taste" category):

 * Unless the pattern has slashes, drop 'm' for match, always
   use '|' as the delimiter for substitution s/A/B;
 * If the pattern has slashes, consistently use the same
   alternate letter as the delimiter (gitweb seems to use '!').
Show 8 quoted lines
> @@ -3616,7 +3616,7 @@ sub git_snapshot {
>  
>  	print $cgi->header(
>  		-type => "application/$ctype",
> -		-content_disposition => 'inline; filename="' . "$filename" . '"',
> +		-content_disposition => 'inline; filename="' . $filename . '"',
>  		-status => '200 OK');
>  
Wouldn't it be easier to read if we did
	"inline; filename=\"$filename\""
instead?
Previous: Jakub NarebskiNext: Jakub Narebski
Message 5 of 6 in “gitweb: Few cleanup patches”
  1. 0/3 gitweb: Few cleanup patchesJakub Narebski, Apr 1, 2007
  2. 1/3 gitweb: Whitespace cleanup - tabs are for indent, spaces are for align (3)Jakub Narebski, Apr 1, 2007
  3. 2/3 gitweb: Quote hash keys, and do not use barewords keysJakub Narebski, Apr 1, 2007
  4. 3/3 gitweb: Few doublequoted strings cleanupsJakub Narebski, Apr 1, 2007
  5. Junio C HamanoApr 3, 2007
  6. Jakub NarebskiApr 4, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.