{"thread":{"id":"5355","subject":"[PATCH 2/3] gitweb: Use underscore instead of hyphen to separate words in HTTP headers names","startedAt":"2006-08-22T14:51:19Z","lastAt":"2006-08-23T09:55:38Z","messageCount":12,"participants":["Jakub Narebski","Junio C Hamano","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"25748","messageId":"200608221651.19629.jnareb@gmail.com","threadId":"5355","inReplyTo":null,"subject":"[PATCH 0/3] gitweb: Yet another cleanup series","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T14:51:19Z","receivedAt":"2006-08-22T14:51:19Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"This series of patches commences further gitweb cleanup.\nIt is based on earlier series of patches:\n* gitweb: Added parse_difftree_raw_line function for later use\n* gitweb: Use parse_difftree_raw_line in git_difftree_body\n\n---\n gitweb/gitweb.perl |  277 +++++++++++++++++++++++++++++++++++-----------------\n 1 files changed, 188 insertions(+), 89 deletions(-)\n\n* gitweb: Whitespace cleanup: realign, reindent\n* gitweb: Use underscore instead of hyphen to separate words\n  in HTTP headers names\n* gitweb: Route rest of action subroutines through %actions\n\n-- \nJakub Narebski\nPoland\n"},{"id":"25747","messageId":"200608221652.50443.jnareb@gmail.com","threadId":"5355","inReplyTo":"200608221651.19629.jnareb@gmail.com","subject":"[PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T14:52:50Z","receivedAt":"2006-08-22T14:52:50Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"This patch tries (but no too hard) to fit gitweb source in 80 columns,\nfor 2 columns wide tabs, and indent and align source for better\nreadibility.\n\nWhile at it added comment to 'snapshot' entry defaults for %feature\nhash, corrected \"blobl\" action in git_blame2 and git_blame to \"blob\",\nkey of argument to $cgi->a from 'class' to '-class'.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nQuite a large patch, but it doesn't change much.\n\n gitweb/gitweb.perl |  257 ++++++++++++++++++++++++++++++++++++----------------\n 1 files changed, 178 insertions(+), 79 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 607b8b7..182fe33 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -69,22 +69,30 @@ our $mimetypes_file = undef;\n \n # You define site-wide feature defaults here; override them with\n # $GITWEB_CONFIG as necessary.\n-our %feature =\n-(\n-\n-# feature  => {'sub' => feature-sub, 'override' => allow-override, 'default' => [ default options...]\n-\n-'blame'         => {'sub' => \\&feature_blame, 'override' => 0, 'default' => [0]},\n-'snapshot'      => {'sub' => \\&feature_snapshot, 'override' => 0, 'default' => ['x-gzip', 'gz', 'gzip']},\n-\n+our %feature = (\n+\t# feature => {'sub' => feature-sub, 'override' => allow-override, 'default' => [ default options...]\n+\t# if feature is overridable, feature-sub will be called with default options;\n+\t# return value indicates if to enable specified feature\n+\n+\t'blame' => {\n+\t\t'sub' => \\&feature_blame,\n+\t\t'override' => 0,\n+\t\t'default' => [0]},\n+\n+\t'snapshot' => {\n+\t\t'sub' => \\&feature_snapshot,\n+\t\t'override' => 0,\n+\t\t#         => [content-encoding, suffix, program]\n+\t\t'default' => ['x-gzip', 'gz', 'gzip']},\n );\n \n sub gitweb_check_feature {\n \tmy ($name) = @_;\n \treturn undef unless exists $feature{$name};\n-\tmy ($sub, $override, @defaults) = ($feature{$name}{'sub'},\n-\t\t\t\t\t\t$feature{$name}{'override'},\n-\t\t\t\t\t\t@{$feature{$name}{'default'}});\n+\tmy ($sub, $override, @defaults) = (\n+\t\t$feature{$name}{'sub'},\n+\t\t$feature{$name}{'override'},\n+\t\t@{$feature{$name}{'default'}});\n \tif (!$override) { return @defaults; }\n \treturn $sub->(@defaults);\n }\n@@ -463,7 +471,9 @@ sub format_log_line_html {\n \tif ($line =~ m/([0-9a-fA-F]{40})/) {\n \t\tmy $hash_text = $1;\n \t\tif (git_get_type($hash_text) eq \"commit\") {\n-\t\t\tmy $link = $cgi->a({-class => \"text\", -href => href(action=>\"commit\", hash=>$hash_text)}, $hash_text);\n+\t\t\tmy $link =\n+\t\t\t\t$cgi->a({-href => href(action=>\"commit\", hash=>$hash_text),\n+\t\t\t\t        -class => \"text\"}, $hash_text);\n \t\t\t$line =~ s/$hash_text/$link/;\n \t\t}\n \t}\n@@ -734,8 +744,10 @@ sub parse_date {\n \t$date{'mday'} = $mday;\n \t$date{'day'} = $days[$wday];\n \t$date{'month'} = $months[$mon];\n-\t$date{'rfc2822'} = sprintf \"%s, %d %s %4d %02d:%02d:%02d +0000\", $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;\n-\t$date{'mday-time'} = sprintf \"%d %s %02d:%02d\", $mday, $months[$mon], $hour ,$min;\n+\t$date{'rfc2822'} = sprintf \"%s, %d %s %4d %02d:%02d:%02d +0000\",\n+\t                   $days[$wday], $mday, $months[$mon], 1900+$year, $hour ,$min, $sec;\n+\t$date{'mday-time'} = sprintf \"%d %s %02d:%02d\",\n+\t                     $mday, $months[$mon], $hour ,$min;\n \n \t$tz =~ m/^([+\\-][0-9][0-9])([0-9][0-9])$/;\n \tmy $local = $epoch + ((int $1 + ($2/60)) * 3600);\n@@ -792,7 +804,8 @@ sub parse_commit {\n \t\t@commit_lines = @$commit_text;\n \t} else {\n \t\t$/ = \"\\0\";\n-\t\topen my $fd, \"-|\", $GIT, \"rev-list\", \"--header\", \"--parents\", \"--max-count=1\", $commit_id or return;\n+\t\topen my $fd, \"-|\", $GIT, \"rev-list\", \"--header\", \"--parents\", \"--max-count=1\", $commit_id\n+\t\t\tor return;\n \t\t@commit_lines = split '\\n', <$fd>;\n \t\tclose $fd or return;\n \t\t$/ = \"\\n\";\n@@ -1086,12 +1099,15 @@ sub git_header_html {\n \t# 'application/xhtml+xml', otherwise send it as plain old 'text/html'.\n \t# we have to do this because MSIE sometimes globs '*/*', pretending to\n \t# support xhtml+xml but choking when it gets what it asked for.\n-\tif (defined $cgi->http('HTTP_ACCEPT') && $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ && $cgi->Accept('application/xhtml+xml') != 0) {\n+\tif (defined $cgi->http('HTTP_ACCEPT') &&\n+\t    $cgi->http('HTTP_ACCEPT') =~ m/(,|;|\\s|^)application\\/xhtml\\+xml(,|;|\\s|$)/ &&\n+\t    $cgi->Accept('application/xhtml+xml') != 0) {\n \t\t$content_type = 'application/xhtml+xml';\n \t} else {\n \t\t$content_type = 'text/html';\n \t}\n-\tprint $cgi->header(-type=>$content_type, -charset => 'utf-8', -status=> $status, -expires => $expires);\n+\tprint $cgi->header(-type=>$content_type, -charset => 'utf-8',\n+\t                   -status=> $status, -expires => $expires);\n \tprint <<EOF;\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n@@ -1271,9 +1287,12 @@ sub git_print_page_path {\n \t} elsif (defined $type && $type eq 'blob') {\n \t\tprint \"<div class=\\\"page_path\\\">\";\n \t\tif (defined $hb) {\n-\t\t\tprint $cgi->a({-href => href(action=>\"blob_plain\", hash_base=>$hb, file_name=>$file_name)}, esc_html($name));\n+\t\t\tprint $cgi->a({-href => href(action=>\"blob_plain\", file_name=>$file_name,\n+\t\t\t                             hash_base=>$hb)},\n+\t\t\t              esc_html($name));\n \t\t} else {\n-\t\t\tprint $cgi->a({-href => href(action=>\"blob_plain\", file_name=>$file_name)}, esc_html($name));\n+\t\t\tprint $cgi->a({-href => href(action=>\"blob_plain\", file_name=>$file_name)},\n+\t\t\t              esc_html($name));\n \t\t}\n \t\tprint \"<br/></div>\\n\";\n \t} else {\n@@ -1523,7 +1542,8 @@ sub git_shortlog_body {\n \t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n \t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 10)) . \"</i></td>\\n\" .\n \t\t      \"<td>\";\n-\t\tprint format_subject_html($co{'title'}, $co{'title_short'}, href(action=>\"commit\", hash=>$commit), $ref);\n+\t\tprint format_subject_html($co{'title'}, $co{'title_short'},\n+\t\t                          href(action=>\"commit\", hash=>$commit), $ref);\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n@@ -1576,7 +1596,8 @@ sub git_history_body {\n \t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 15, 3)) . \"</i></td>\\n\" .\n \t\t      \"<td>\";\n \t\t# originally git_history used chop_str($co{'title'}, 50)\n-\t\tprint format_subject_html($co{'title'}, $co{'title_short'}, href(action=>\"commit\", hash=>$commit), $ref);\n+\t\tprint format_subject_html($co{'title'}, $co{'title_short'},\n+\t\t                          href(action=>\"commit\", hash=>$commit), $ref);\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") . \" | \" .\n@@ -1589,7 +1610,8 @@ sub git_history_body {\n \t\t\tif (defined $blob_current && defined $blob_parent &&\n \t\t\t\t\t$blob_current ne $blob_parent) {\n \t\t\t\tprint \" | \" .\n-\t\t\t\t\t$cgi->a({-href => href(action=>\"blobdiff\", hash=>$blob_current, hash_parent=>$blob_parent, hash_base=>$commit, file_name=>$file_name)},\n+\t\t\t\t\t$cgi->a({-href => href(action=>\"blobdiff\", hash=>$blob_current, hash_parent=>$blob_parent,\n+\t\t\t\t\t                       hash_base=>$commit, file_name=>$file_name)},\n \t\t\t\t\t        \"diff to current\");\n \t\t\t}\n \t\t}\n@@ -1634,7 +1656,8 @@ sub git_tags_body {\n \t\t      \"</td>\\n\" .\n \t\t      \"<td>\";\n \t\tif (defined $comment) {\n-\t\t\tprint format_subject_html($comment, $comment_short, href(action=>\"tag\", hash=>$tag{'id'}));\n+\t\t\tprint format_subject_html($comment, $comment_short,\n+\t\t\t                          href(action=>\"tag\", hash=>$tag{'id'}));\n \t\t}\n \t\tprint \"</td>\\n\" .\n \t\t      \"<td class=\\\"selflink\\\">\";\n@@ -1945,13 +1968,17 @@ sub git_tag {\n \t      \"<table cellspacing=\\\"0\\\">\\n\" .\n \t      \"<tr>\\n\" .\n \t      \"<td>object</td>\\n\" .\n-\t      \"<td>\" . $cgi->a({-class => \"list\", -href => href(action=>$tag{'type'}, hash=>$tag{'object'})}, $tag{'object'}) . \"</td>\\n\" .\n-\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>$tag{'type'}, hash=>$tag{'object'})}, $tag{'type'}) . \"</td>\\n\" .\n+\t      \"<td>\" . $cgi->a({-class => \"list\", -href => href(action=>$tag{'type'}, hash=>$tag{'object'})},\n+\t                       $tag{'object'}) . \"</td>\\n\" .\n+\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>$tag{'type'}, hash=>$tag{'object'})},\n+\t                                      $tag{'type'}) . \"</td>\\n\" .\n \t      \"</tr>\\n\";\n \tif (defined($tag{'author'})) {\n \t\tmy %ad = parse_date($tag{'epoch'}, $tag{'tz'});\n \t\tprint \"<tr><td>author</td><td>\" . esc_html($tag{'author'}) . \"</td></tr>\\n\";\n-\t\tprint \"<tr><td></td><td>\" . $ad{'rfc2822'} . sprintf(\" (%02d:%02d %s)\", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) . \"</td></tr>\\n\";\n+\t\tprint \"<tr><td></td><td>\" . $ad{'rfc2822'} .\n+\t\t\tsprintf(\" (%02d:%02d %s)\", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'}) .\n+\t\t\t\"</td></tr>\\n\";\n \t}\n \tprint \"</table>\\n\\n\" .\n \t      \"</div>\\n\";\n@@ -1988,8 +2015,11 @@ sub git_blame2 {\n \t\tor die_error(undef, \"Open git-blame failed\");\n \tgit_header_html();\n \tmy $formats_nav =\n-\t\t$cgi->a({-href => href(action=>\"blobl\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, \"blob\") .\n-\t\t\" | \" . $cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)}, \"head\");\n+\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},\n+\t\t        \"blob\") .\n+\t\t\" | \" .\n+\t\t$cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)},\n+\t\t        \"head\");\n \tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \tgit_print_page_path($file_name, $ftype, $hash_base);\n@@ -2015,14 +2045,17 @@ sub git_blame2 {\n \t\t}\n \t\tprint \"<tr class=\\\"$rev_color[$current_color]\\\">\\n\";\n \t\tprint \"<td class=\\\"sha1\\\">\" .\n-\t\t\t$cgi->a({-href => href(action=>\"commit\", hash=>$full_rev, file_name=>$file_name)}, esc_html($rev)) . \"</td>\\n\";\n-\t\tprint \"<td class=\\\"linenr\\\"><a id=\\\"l$lineno\\\" href=\\\"#l$lineno\\\" class=\\\"linenr\\\">\" . esc_html($lineno) . \"</a></td>\\n\";\n+\t\t\t$cgi->a({-href => href(action=>\"commit\", hash=>$full_rev, file_name=>$file_name)},\n+\t\t\t        esc_html($rev)) . \"</td>\\n\";\n+\t\tprint \"<td class=\\\"linenr\\\"><a id=\\\"l$lineno\\\" href=\\\"#l$lineno\\\" class=\\\"linenr\\\">\" .\n+\t\t      esc_html($lineno) . \"</a></td>\\n\";\n \t\tprint \"<td class=\\\"pre\\\">\" . esc_html($data) . \"</td>\\n\";\n \t\tprint \"</tr>\\n\";\n \t}\n \tprint \"</table>\\n\";\n \tprint \"</div>\";\n-\tclose $fd or print \"Reading blob failed\\n\";\n+\tclose $fd\n+\t\tor print \"Reading blob failed\\n\";\n \tgit_footer_html();\n }\n \n@@ -2045,8 +2078,11 @@ sub git_blame {\n \t\tor die_error(undef, \"Open git-annotate failed\");\n \tgit_header_html();\n \tmy $formats_nav =\n-\t\t$cgi->a({-href => href(action=>\"blobl\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, \"blob\") .\n-\t\t\" | \" . $cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)}, \"head\");\n+\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)},\n+\t\t        \"blob\") .\n+\t\t\" | \" .\n+\t\t$cgi->a({-href => href(action=>\"blame\", file_name=>$file_name)},\n+\t\t        \"head\");\n \tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \tgit_print_page_path($file_name, 'blob', $hash_base);\n@@ -2110,7 +2146,8 @@ HTML\n HTML\n \t} # while (my $line = <$fd>)\n \tprint \"</table>\\n\\n\";\n-\tclose $fd or print \"Reading blob failed.\\n\";\n+\tclose $fd \n+\t\tor print \"Reading blob failed.\\n\";\n \tprint \"</div>\";\n \tgit_footer_html();\n }\n@@ -2197,13 +2234,23 @@ sub git_blob {\n \tif (defined $hash_base && (my %co = parse_commit($hash_base))) {\n \t\tif (defined $file_name) {\n \t\t\tif ($have_blame) {\n-\t\t\t\t$formats_nav .= $cgi->a({-href => href(action=>\"blame\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, \"blame\") . \" | \";\n+\t\t\t\t$formats_nav .=\n+\t\t\t\t\t$cgi->a({-href => href(action=>\"blame\", hash_base=>$hash_base,\n+\t\t\t\t\t                       hash=>$hash, file_name=>$file_name)},\n+\t\t\t\t\t        \"blame\") .\n+\t\t\t\t\t\" | \";\n \t\t\t}\n \t\t\t$formats_nav .=\n-\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", hash=>$hash, file_name=>$file_name)}, \"plain\") .\n-\t\t\t\t\" | \" . $cgi->a({-href => href(action=>\"blob\", hash_base=>\"HEAD\", file_name=>$file_name)}, \"head\");\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\",\n+\t\t\t\t                       hash=>$hash, file_name=>$file_name)},\n+\t\t\t\t        \"plain\") .\n+\t\t\t\t\" | \" .\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob\",\n+\t\t\t\t                       hash_base=>\"HEAD\", file_name=>$file_name)},\n+\t\t\t\t        \"head\");\n \t\t} else {\n-\t\t\t$formats_nav .= $cgi->a({-href => href(action=>\"blob_plain\", hash=>$hash)}, \"plain\");\n+\t\t\t$formats_nav .=\n+\t\t\t\t$cgi->a({-href => href(action=>\"blob_plain\", hash=>$hash)}, \"plain\");\n \t\t}\n \t\tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \t\tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n@@ -2219,9 +2266,11 @@ sub git_blob {\n \t\tchomp $line;\n \t\t$nr++;\n \t\t$line = untabify($line);\n-\t\tprintf \"<div class=\\\"pre\\\"><a id=\\\"l%i\\\" href=\\\"#l%i\\\" class=\\\"linenr\\\">%4i</a> %s</div>\\n\", $nr, $nr, $nr, esc_html($line);\n+\t\tprintf \"<div class=\\\"pre\\\"><a id=\\\"l%i\\\" href=\\\"#l%i\\\" class=\\\"linenr\\\">%4i</a> %s</div>\\n\",\n+\t\t       $nr, $nr, $nr, esc_html($line);\n \t}\n-\tclose $fd or print \"Reading blob failed.\\n\";\n+\tclose $fd \n+\t\tor print \"Reading blob failed.\\n\";\n \tprint \"</div>\";\n \tgit_footer_html();\n }\n@@ -2282,23 +2331,37 @@ sub git_tree {\n \t\tprint \"<td class=\\\"mode\\\">\" . mode_str($t_mode) . \"</td>\\n\";\n \t\tif ($t_type eq \"blob\") {\n \t\t\tprint \"<td class=\\\"list\\\">\" .\n-\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key), -class => \"list\"}, esc_html($t_name)) .\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key),\n+\t\t\t              -class => \"list\"}, esc_html($t_name)) .\n \t\t\t      \"</td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)}, \"blob\");\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)},\n+\t\t\t              \"blob\");\n \t\t\tif ($have_blame) {\n-\t\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"blame\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)}, \"blame\");\n+\t\t\t\tprint \" | \" .\n+\t\t\t\t\t$cgi->a({-href => href(action=>\"blame\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)},\n+\t\t\t\t\t        \"blame\");\n \t\t\t}\n-\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"history\", hash=>$t_hash, hash_base=>$hash_base, file_name=>\"$base$t_name\")}, \"history\") .\n-\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"blob_plain\", hash=>$t_hash, file_name=>\"$base$t_name\")}, \"raw\") .\n+\t\t\tprint \" | \" .\n+\t\t\t      $cgi->a({-href => href(action=>\"history\", hash_base=>$hash_base,\n+\t\t\t                             hash=>$t_hash, file_name=>\"$base$t_name\")},\n+\t\t\t              \"history\") .\n+\t\t\t      \" | \" .\n+\t\t\t      $cgi->a({-href => href(action=>\"blob_plain\",\n+\t\t\t                             hash=>$t_hash, file_name=>\"$base$t_name\")},\n+\t\t\t              \"raw\") .\n \t\t\t      \"</td>\\n\";\n \t\t} elsif ($t_type eq \"tree\") {\n \t\t\tprint \"<td class=\\\"list\\\">\" .\n-\t\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)}, esc_html($t_name)) .\n+\t\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)},\n+\t\t\t              esc_html($t_name)) .\n \t\t\t      \"</td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)}, \"tree\") .\n-\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"history\", hash_base=>$hash_base, file_name=>\"$base$t_name\")}, \"history\") .\n+\t\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)},\n+\t\t\t              \"tree\") .\n+\t\t\t      \" | \" .\n+\t\t\t      $cgi->a({-href => href(action=>\"history\", hash_base=>$hash_base, file_name=>\"$base$t_name\")},\n+\t\t\t              \"history\") .\n \t\t\t      \"</td>\\n\";\n \t\t}\n \t\tprint \"</tr>\\n\";\n@@ -2323,10 +2386,9 @@ sub git_snapshot {\n \tmy $filename = basename($project) . \"-$hash.tar.$suffix\";\n \n \tprint $cgi->header(-type => 'application/x-tar',\n-\t\t\t   -content-encoding => $ctype,\n-\t\t\t   '-content-disposition' =>\n-\t\t\t   \"inline; filename=\\\"$filename\\\"\",\n-\t\t\t   -status => '200 OK');\n+\t                   -content-encoding => $ctype,\n+\t                  '-content-disposition' => \"inline; filename=\\\"$filename\\\"\",\n+\t                   -status => '200 OK');\n \n \topen my $fd, \"-|\", \"$GIT tar-tree $hash \\'$project\\' | $command\" or\n \t\tdie_error(undef, \"Execute git-tar-tree failed.\");\n@@ -2377,7 +2439,8 @@ sub git_log {\n \t\tprint \"<div class=\\\"title_text\\\">\\n\" .\n \t\t      \"<div class=\\\"log_link\\\">\\n\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$commit)}, \"commit\") .\n-\t\t      \" | \" . $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n+\t\t      \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$commit)}, \"commitdiff\") .\n \t\t      \"<br/>\\n\" .\n \t\t      \"</div>\\n\" .\n \t\t      \"<i>\" . esc_html($co{'author_name'}) .  \" [$ad{'rfc2822'}]</i><br/>\\n\" .\n@@ -2421,12 +2484,14 @@ sub git_commit {\n \tmy $formats_nav = '';\n \tif (defined $file_name && defined $co{'parent'}) {\n \t\tmy $parent = $co{'parent'};\n-\t\t$formats_nav .= $cgi->a({-href => href(action=>\"blame\", hash_parent=>$parent, file_name=>$file_name)}, \"blame\");\n+\t\t$formats_nav .=\n+\t\t\t$cgi->a({-href => href(action=>\"blame\", hash_parent=>$parent, file_name=>$file_name)},\n+\t\t\t        \"blame\");\n \t}\n \tgit_header_html(undef, $expires);\n \tgit_print_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',\n-\t             $hash, $co{'tree'}, $hash,\n-\t             $formats_nav);\n+\t                   $hash, $co{'tree'}, $hash,\n+\t                   $formats_nav);\n \n \tif (defined $co{'parent'}) {\n \t\tgit_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);\n@@ -2439,23 +2504,31 @@ sub git_commit {\n \t      \"<tr>\" .\n \t      \"<td></td><td> $ad{'rfc2822'}\";\n \tif ($ad{'hour_local'} < 6) {\n-\t\tprintf(\" (<span class=\\\"atnight\\\">%02d:%02d</span> %s)\", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});\n+\t\tprintf(\" (<span class=\\\"atnight\\\">%02d:%02d</span> %s)\",\n+\t\t       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});\n \t} else {\n-\t\tprintf(\" (%02d:%02d %s)\", $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});\n+\t\tprintf(\" (%02d:%02d %s)\",\n+\t\t       $ad{'hour_local'}, $ad{'minute_local'}, $ad{'tz_local'});\n \t}\n \tprint \"</td>\" .\n \t      \"</tr>\\n\";\n \tprint \"<tr><td>committer</td><td>\" . esc_html($co{'committer'}) . \"</td></tr>\\n\";\n-\tprint \"<tr><td></td><td> $cd{'rfc2822'}\" . sprintf(\" (%02d:%02d %s)\", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) . \"</td></tr>\\n\";\n+\tprint \"<tr><td></td><td> $cd{'rfc2822'}\" .\n+\t      sprintf(\" (%02d:%02d %s)\", $cd{'hour_local'}, $cd{'minute_local'}, $cd{'tz_local'}) .\n+\t      \"</td></tr>\\n\";\n \tprint \"<tr><td>commit</td><td class=\\\"sha1\\\">$co{'id'}</td></tr>\\n\";\n \tprint \"<tr>\" .\n \t      \"<td>tree</td>\" .\n \t      \"<td class=\\\"sha1\\\">\" .\n-\t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash), class => \"list\"}, $co{'tree'}) .\n+\t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash),\n+\t               class => \"list\"}, $co{'tree'}) .\n \t      \"</td>\" .\n-\t      \"<td class=\\\"link\\\">\" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)}, \"tree\");\n+\t      \"<td class=\\\"link\\\">\" .\n+\t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$hash)},\n+\t              \"tree\");\n \tif ($have_snapshot) {\n-\t\tprint \" | \" .  $cgi->a({-href => href(action=>\"snapshot\", hash=>$hash)}, \"snapshot\");\n+\t\tprint \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"snapshot\", hash=>$hash)}, \"snapshot\");\n \t}\n \tprint \"</td>\" .\n \t      \"</tr>\\n\";\n@@ -2463,10 +2536,14 @@ sub git_commit {\n \tforeach my $par (@$parents) {\n \t\tprint \"<tr>\" .\n \t\t      \"<td>parent</td>\" .\n-\t\t      \"<td class=\\\"sha1\\\">\" . $cgi->a({-href => href(action=>\"commit\", hash=>$par), class => \"list\"}, $par) . \"</td>\" .\n+\t\t      \"<td class=\\\"sha1\\\">\" .\n+\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$par),\n+\t\t               class => \"list\"}, $par) .\n+\t\t      \"</td>\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n \t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$par)}, \"commit\") .\n-\t\t      \" | \" . $cgi->a({-href => href(action=>\"commitdiff\", hash=>$hash, hash_parent=>$par)}, \"commitdiff\") .\n+\t\t      \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"commitdiff\", hash=>$hash, hash_parent=>$par)}, \"commitdiff\") .\n \t\t      \"</td>\" .\n \t\t      \"</tr>\\n\";\n \t}\n@@ -2487,7 +2564,9 @@ sub git_blobdiff {\n \tgit_header_html();\n \tif (defined $hash_base && (my %co = parse_commit($hash_base))) {\n \t\tmy $formats_nav =\n-\t\t\t$cgi->a({-href => href(action=>\"blobdiff_plain\", hash=>$hash, hash_parent=>$hash_parent)}, \"plain\");\n+\t\t\t$cgi->a({-href => href(action=>\"blobdiff_plain\",\n+\t\t\t                       hash=>$hash, hash_parent=>$hash_parent)},\n+\t\t\t        \"plain\");\n \t\tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);\n \t\tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \t} else {\n@@ -2498,12 +2577,16 @@ sub git_blobdiff {\n \tgit_print_page_path($file_name, \"blob\", $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\" .\n \t      \"<div class=\\\"diff_info\\\">blob:\" .\n-\t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash_parent, hash_base=>$hash_base, file_name=>($file_parent || $file_name))}, $hash_parent) .\n+\t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash_parent,\n+\t                             hash_base=>$hash_base, file_name=>($file_parent || $file_name))},\n+\t              $hash_parent) .\n \t      \" -> blob:\" .\n-\t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, $hash) .\n+\t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash,\n+\t                             hash_base=>$hash_base, file_name=>$file_name)},\n+\t              $hash) .\n \t      \"</div>\\n\";\n \tgit_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);\n-\tprint \"</div>\";\n+\tprint \"</div>\"; # page_body\n \tgit_footer_html();\n }\n \n@@ -2535,7 +2618,8 @@ sub git_commitdiff {\n \tmy $refs = git_get_references();\n \tmy $ref = format_ref_marker($refs, $co{'id'});\n \tmy $formats_nav =\n-\t\t$cgi->a({-href => href(action=>\"commitdiff_plain\", hash=>$hash, hash_parent=>$hash_parent)}, \"plain\");\n+\t\t$cgi->a({-href => href(action=>\"commitdiff_plain\", hash=>$hash, hash_parent=>$hash_parent)},\n+\t\t        \"plain\");\n \tgit_header_html(undef, $expires);\n \tgit_print_page_nav('commitdiff','', $hash,$co{'tree'},$hash, $formats_nav);\n \tgit_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash);\n@@ -2556,22 +2640,30 @@ sub git_commitdiff {\n \t\tmy $file = validate_input(unquote($6));\n \t\tif ($status eq \"A\") {\n \t\t\tprint \"<div class=\\\"diff_info\\\">\" . file_type($to_mode) . \":\" .\n-\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, $to_id) . \"(new)\" .\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash_base=>$hash,\n+\t\t\t                             hash=>$to_id, file_name=>$file)},\n+\t\t\t              $to_id) . \"(new)\" .\n \t\t\t      \"</div>\\n\";\n \t\t\tgit_diff_print(undef, \"/dev/null\", $to_id, \"b/$file\");\n \t\t} elsif ($status eq \"D\") {\n \t\t\tprint \"<div class=\\\"diff_info\\\">\" . file_type($from_mode) . \":\" .\n-\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$from_id, hash_base=>$hash_parent, file_name=>$file)}, $from_id) . \"(deleted)\" .\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash_base=>$hash_parent,\n+\t\t\t                             hash=>$from_id, file_name=>$file)},\n+\t\t\t              $from_id) . \"(deleted)\" .\n \t\t\t      \"</div>\\n\";\n \t\t\tgit_diff_print($from_id, \"a/$file\", undef, \"/dev/null\");\n \t\t} elsif ($status eq \"M\") {\n \t\t\tif ($from_id ne $to_id) {\n \t\t\t\tprint \"<div class=\\\"diff_info\\\">\" .\n \t\t\t\t      file_type($from_mode) . \":\" .\n-\t\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$from_id, hash_base=>$hash_parent, file_name=>$file)}, $from_id) .\n+\t\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash_base=>$hash_parent,\n+\t\t\t\t                             hash=>$from_id, file_name=>$file)},\n+\t\t\t\t              $from_id) .\n \t\t\t\t      \" -> \" .\n \t\t\t\t      file_type($to_mode) . \":\" .\n-\t\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, $to_id);\n+\t\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash_base=>$hash,\n+\t\t\t\t                             hash=>$to_id, file_name=>$file)},\n+\t\t\t\t              $to_id);\n \t\t\t\tprint \"</div>\\n\";\n \t\t\t\tgit_diff_print($from_id, \"a/$file\",  $to_id, \"b/$file\");\n \t\t\t}\n@@ -2611,7 +2703,9 @@ sub git_commitdiff_plain {\n \t\t}\n \t}\n \n-\tprint $cgi->header(-type => \"text/plain\", -charset => 'utf-8', '-content-disposition' => \"inline; filename=\\\"git-$hash.patch\\\"\");\n+\tprint $cgi->header(-type => \"text/plain\",\n+\t                   -charset => 'utf-8',\n+\t                  '-content-disposition' => \"inline; filename=\\\"git-$hash.patch\\\"\");\n \tmy %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});\n \tmy $comment = $co{'comment'};\n \tprint \"From: $co{'author'}\\n\" .\n@@ -2791,7 +2885,8 @@ sub git_search {\n \t\t\tprint \"</td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n \t\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$co{'id'})}, \"commit\") .\n-\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$co{'id'})}, \"tree\");\n+\t\t\t      \" | \" .\n+\t\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$co{'id'})}, \"tree\");\n \t\t\tprint \"</td>\\n\" .\n \t\t\t      \"</tr>\\n\";\n \t\t}\n@@ -2828,18 +2923,22 @@ sub git_search {\n \t\t\t\t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n \t\t\t\t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 15, 5)) . \"</i></td>\\n\" .\n \t\t\t\t\t      \"<td>\" .\n-\t\t\t\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$co{'id'}), -class => \"list subject\"},\n+\t\t\t\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$co{'id'}),\n+\t\t\t\t\t              -class => \"list subject\"},\n \t\t\t\t\t              esc_html(chop_str($co{'title'}, 50)) . \"<br/>\");\n \t\t\t\t\twhile (my $setref = shift @files) {\n \t\t\t\t\t\tmy %set = %$setref;\n-\t\t\t\t\t\tprint $cgi->a({-href => href(action=>\"blob\", hash=>$set{'id'}, hash_base=>$co{'id'}, file_name=>$set{'file'}), class => \"list\"},\n-\t\t\t\t\t\t      \"<span class=\\\"match\\\">\" . esc_html($set{'file'}) . \"</span>\") .\n+\t\t\t\t\t\tprint $cgi->a({-href => href(action=>\"blob\", hash_base=>$co{'id'},\n+\t\t\t\t\t\t                             hash=>$set{'id'}, file_name=>$set{'file'}),\n+\t\t\t\t\t\t              -class => \"list\"},\n+\t\t\t\t\t\t              \"<span class=\\\"match\\\">\" . esc_html($set{'file'}) . \"</span>\") .\n \t\t\t\t\t\t      \"<br/>\\n\";\n \t\t\t\t\t}\n \t\t\t\t\tprint \"</td>\\n\" .\n \t\t\t\t\t      \"<td class=\\\"link\\\">\" .\n \t\t\t\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$co{'id'})}, \"commit\") .\n-\t\t\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$co{'id'})}, \"tree\");\n+\t\t\t\t\t      \" | \" .\n+\t\t\t\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$co{'tree'}, hash_base=>$co{'id'})}, \"tree\");\n \t\t\t\t\tprint \"</td>\\n\" .\n \t\t\t\t\t      \"</tr>\\n\";\n \t\t\t\t}\n-- \n1.4.1.1\n"},{"id":"25746","messageId":"200608221655.34246.jnareb@gmail.com","threadId":"5355","inReplyTo":"200608221651.19629.jnareb@gmail.com","subject":"[PATCH 2/3] gitweb: Use underscore instead of hyphen to separate words in HTTP headers names","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T14:55:34Z","receivedAt":"2006-08-22T14:55:34Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Use underscore (which will be turned into hyphen) to separate words in\nHTTP header names, in keys to CGI header() method, consistently.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nSometimes using quites for header() keys and sometimes not was not\na good practice.\n\nExcerpt from CGI(3pm):\n\n       The last example shows the named argument style for passing arguments to\n       the CGI methods using named parameters.  Recognized parameters are -type,\n       -status, -expires, and -cookie.  Any other named parameters will be\n       stripped of their initial hyphens and turned into header fields, allowing\n       you to specify any HTTP header you desire.  Internal underscores will be\n       turned into hyphens:\n\n           print header(-Content_length=>3002);\n\n\n gitweb/gitweb.perl |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 182fe33..f59213e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2202,7 +2202,8 @@ sub git_blob_plain {\n \t\t$save_as .= '.txt';\n \t}\n \n-\tprint $cgi->header(-type => \"$type\", '-content-disposition' => \"inline; filename=\\\"$save_as\\\"\");\n+\tprint $cgi->header(-type => \"$type\",\n+\t                   -content_disposition => \"inline; filename=\\\"$save_as\\\"\");\n \tundef $/;\n \tbinmode STDOUT, ':raw';\n \tprint <$fd>;\n@@ -2386,8 +2387,8 @@ sub git_snapshot {\n \tmy $filename = basename($project) . \"-$hash.tar.$suffix\";\n \n \tprint $cgi->header(-type => 'application/x-tar',\n-\t                   -content-encoding => $ctype,\n-\t                  '-content-disposition' => \"inline; filename=\\\"$filename\\\"\",\n+\t                   -content_encoding => $ctype,\n+\t                   -content_disposition => \"inline; filename=\\\"$filename\\\"\",\n \t                   -status => '200 OK');\n \n \topen my $fd, \"-|\", \"$GIT tar-tree $hash \\'$project\\' | $command\" or\n@@ -2705,7 +2706,7 @@ sub git_commitdiff_plain {\n \n \tprint $cgi->header(-type => \"text/plain\",\n \t                   -charset => 'utf-8',\n-\t                  '-content-disposition' => \"inline; filename=\\\"git-$hash.patch\\\"\");\n+\t                   -content_disposition => \"inline; filename=\\\"git-$hash.patch\\\"\");\n \tmy %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});\n \tmy $comment = $co{'comment'};\n \tprint \"From: $co{'author'}\\n\" .\n-- \n1.4.1.1\n"},{"id":"25749","messageId":"200608221659.20655.jnareb@gmail.com","threadId":"5355","inReplyTo":"200608221651.19629.jnareb@gmail.com","subject":"[PATCH 3/3] gitweb: Route rest of action subroutines through %actions","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T14:59:20Z","receivedAt":"2006-08-22T14:59:20Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Route rest of action subroutines, namely git_project_list and git_opml\n(both of which doesn't need $project) through %actions hash.\n\nThis has disadvantage that all parameters are read and validated;\nearlier git_opml was called as soon as $action was parsed and\nvalidated, git_project_list was called as soon as $project was parsed\nand validated.  This has advantage that all action dispatch is grouped\nin one place.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis is an alternative to (not accepted) patch by Martin Waitz from\nin http://permalink.gmane.org/gmane.comp.version-control.git/25535\nMessage-Id: <11557673281583-git-send-email-tali@admingilde.org>\n\n  gitweb: use action dispatcher for non-project actions, too.\n\n\n gitweb/gitweb.perl |   17 ++++++++---------\n 1 files changed, 8 insertions(+), 9 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex f59213e..e09204d 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -155,11 +155,6 @@ if (defined $action) {\n \tif ($action =~ m/[^0-9a-zA-Z\\.\\-_]/) {\n \t\tdie_error(undef, \"Invalid action parameter\");\n \t}\n-\t# action which does not check rest of parameters\n-\tif ($action eq \"opml\") {\n-\t\tgit_opml();\n-\t\texit;\n-\t}\n }\n \n our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});\n@@ -179,9 +174,6 @@ if (defined $project) {\n \t\tdie_error(undef, \"No such project\");\n \t}\n \t$ENV{'GIT_DIR'} = \"$projectroot/$project\";\n-} else {\n-\tgit_project_list();\n-\texit;\n }\n \n our $file_name = $cgi->param('f');\n@@ -255,9 +247,16 @@ my %actions = (\n \t\"tags\" => \\&git_tags,\n \t\"tree\" => \\&git_tree,\n \t\"snapshot\" => \\&git_snapshot,\n+\t# those below don't need $project\n+\t\"opml\" => \\&git_opml,\n+\t\"project_list\" => \\&git_project_list,\n );\n \n-$action = 'summary' if (!defined($action));\n+if (defined $project) {\n+\t$action ||= 'summary';\n+} else {\n+\t$action ||= 'project_list';\n+}\n if (!defined($actions{$action})) {\n \tdie_error(undef, \"Unknown action\");\n }\n-- \n1.4.1.1\n"},{"id":"25750","messageId":"ecf6c7$40e$1@sea.gmane.org","threadId":"5355","inReplyTo":"200608221651.19629.jnareb@gmail.com","subject":"Re: [PATCH 0/3] gitweb: Yet another cleanup series","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T15:03:37Z","receivedAt":"2006-08-22T15:03:37Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n\n> This series of patches commences further gitweb cleanup.\n> It is based on earlier series of patches:\n> * gitweb: Added parse_difftree_raw_line function for later use\n> * gitweb: Use parse_difftree_raw_line in git_difftree_body\n\nActually, I think that only first patch in this series needs\n\"parse_difftree_raw_line\" series.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25765","messageId":"200608222342.53861.jnareb@gmail.com","threadId":"5355","inReplyTo":"200608221651.19629.jnareb@gmail.com","subject":"[PATCH 4/3] gitweb: Use here-doc","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T21:42:53Z","receivedAt":"2006-08-22T21:42:53Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis patch uses undocumented, at least in perlop(1), trick in\ninterpolation that allows calling function from interpolated string,\nusing ${\\subroutine_name(parameters...)}, found in git_blame,\nand used in git_rss here-doc in this patch.\n\nThis patch is part of \"[PATCH 0/3] gitweb: Yet another cleanup series\"\nseries.\n\n gitweb/gitweb.perl |   75 \n+++++++++++++++++++++++++++++++---------------------\n 1 files changed, 44 insertions(+), 31 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex e09204d..5301213 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1185,11 +1185,13 @@ sub die_error {\n \tmy $error = shift || \"Malformed query, file missing or permission \ndenied\";\n \n \tgit_header_html($status);\n-\tprint \"<div class=\\\"page_body\\\">\\n\" .\n-\t      \"<br/><br/>\\n\" .\n-\t      \"$status - $error\\n\" .\n-\t      \"<br/>\\n\" .\n-\t      \"</div>\\n\";\n+\tprint <<EOF;\n+<div class=\"page_body\">\n+<br /><br />\n+$status - $error\n+<br />\n+</div>\n+EOF\n \tgit_footer_html();\n \texit;\n }\n@@ -2026,9 +2028,11 @@ sub git_blame2 {\n \tmy $num_colors = scalar(@rev_color);\n \tmy $current_color = 0;\n \tmy $last_rev;\n-\tprint \"<div class=\\\"page_body\\\">\\n\";\n-\tprint \"<table class=\\\"blame\\\">\\n\";\n-\tprint \"<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\\n\";\n+\tprint <<HTML;\n+<div class=\"page_body\">\n+<table class=\"blame\">\n+<tr><th>Commit</th><th>Line</th><th>Data</th></tr>\n+HTML\n \twhile (<$fd>) {\n \t\t/^([0-9a-fA-F]{40}).*?(\\d+)\\)\\s{1}(\\s*.*)/;\n \t\tmy $full_rev = $1;\n@@ -2570,9 +2574,10 @@ sub git_blobdiff {\n \t\tgit_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, \n$formats_nav);\n \t\tgit_print_header_div('commit', esc_html($co{'title'}), $hash_base);\n \t} else {\n-\t\tprint \"<div class=\\\"page_nav\\\">\\n\" .\n-\t\t      \"<br/><br/></div>\\n\" .\n-\t\t      \"<div class=\\\"title\\\">$hash vs $hash_parent</div>\\n\";\n+\t\tprint <<HTML;\n+<div class=\"page_nav\"><br/><br/></div>\n+<div class=\"title\">$hash vs $hash_parent</div>\n+HTML\n \t}\n \tgit_print_page_path($file_name, \"blob\", $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\" .\n@@ -2708,9 +2713,11 @@ sub git_commitdiff_plain {\n \t                   -content_disposition => \"inline; \nfilename=\\\"git-$hash.patch\\\"\");\n \tmy %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});\n \tmy $comment = $co{'comment'};\n-\tprint \"From: $co{'author'}\\n\" .\n-\t      \"Date: $ad{'rfc2822'} ($ad{'tz_local'})\\n\".\n-\t      \"Subject: $co{'title'}\\n\";\n+\tprint <<TEXT;\n+From: $co{'author'}\n+Date: $ad{'rfc2822'} ($ad{'tz_local'})\n+Subject: $co{'title'}\n+TEXT\n \tif (defined $tagname) {\n \t\tprint \"X-Git-Tag: $tagname\\n\";\n \t}\n@@ -2995,13 +3002,15 @@ sub git_rss {\n \tmy @revlist = map { chomp; $_ } <$fd>;\n \tclose $fd or die_error(undef, \"Reading git-rev-list failed\");\n \tprint $cgi->header(-type => 'text/xml', -charset => 'utf-8');\n-\tprint \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n\".\n-\t      \"<rss version=\\\"2.0\\\" \nxmlns:content=\\\"http://purl.org/rss/1.0/modules/content/\\\">\\n\";\n-\tprint \"<channel>\\n\";\n-\tprint \"<title>$project</title>\\n\".\n-\t      \"<link>\" . esc_html(\"$my_url?p=$project;a=summary\") . \n\"</link>\\n\".\n-\t      \"<description>$project log</description>\\n\".\n-\t      \"<language>en</language>\\n\";\n+\tprint <<XML;\n+<?xml version=\"1.0\" encoding=\"utf-8\"?>\n+<rss version=\"2.0\" \nxmlns:content=\"http://purl.org/rss/1.0/modules/content/\">\n+<channel>\n+<title>$project $my_uri $my_url</title>\n+<link>${\\esc_html(\"$my_url?p=$project;a=summary\")}</link>\n+<description>$project log</description>\n+<language>en</language>\n+XML\n \n \tfor (my $i = 0; $i <= $#revlist; $i++) {\n \t\tmy $commit = $revlist[$i];\n@@ -3050,13 +3059,15 @@ sub git_opml {\n \tmy @list = git_get_projects_list();\n \n \tprint $cgi->header(-type => 'text/xml', -charset => 'utf-8');\n-\tprint \"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n\".\n-\t      \"<opml version=\\\"1.0\\\">\\n\".\n-\t      \"<head>\".\n-\t      \"  <title>$site_name Git OPML Export</title>\\n\".\n-\t      \"</head>\\n\".\n-\t      \"<body>\\n\".\n-\t      \"<outline text=\\\"git RSS feeds\\\">\\n\";\n+\tprint <<XML;\n+<?xml version=\"1.0\" encoding=\"utf-8\"?>\n+<opml version=\"1.0\">\n+<head>\n+  <title>$site_name Git OPML Export</title>\n+</head>\n+<body>\n+<outline text=\"git RSS feeds\">\n+XML\n \n \tforeach my $pr (@list) {\n \t\tmy %proj = %$pr;\n@@ -3075,7 +3086,9 @@ sub git_opml {\n \t\tmy $html = \"$my_url?p=$proj{'path'};a=summary\";\n \t\tprint \"<outline type=\\\"rss\\\" text=\\\"$path\\\" title=\\\"$path\\\" \nxmlUrl=\\\"$rss\\\" htmlUrl=\\\"$html\\\"/>\\n\";\n \t}\n-\tprint \"</outline>\\n\".\n-\t      \"</body>\\n\".\n-\t      \"</opml>\\n\";\n+\tprint <<XML;\n+</outline>\n+</body>\n+</opml>\n+XML\n }\n-- \n1.4.1.1\n"},{"id":"25766","messageId":"ecfuef$riq$1@sea.gmane.org","threadId":"5355","inReplyTo":"200608222342.53861.jnareb@gmail.com","subject":"Re: [PATCH 4/3] gitweb: Use here-doc","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-22T21:54:26Z","receivedAt":"2006-08-22T21:54:26Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jakub Narebski wrote:\n\n> This patch uses undocumented, at least in perlop(1), trick in\n> interpolation that allows calling function from interpolated string,\n> using ${\\subroutine_name(parameters...)}, found in git_blame,\n> and used in git_rss here-doc in this patch.\n\nIt is trick, using ${...} syntax described in perlref(1), where ... is a\nexpression returning reference (in our case scalar reference).\n${\\...} is similar to @{[...]} trick, dereference(reference(value)), where\ndereference is only to have interpolation.  \n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25774","messageId":"7voducjkvg.fsf@assigned-by-dhcp.cox.net","threadId":"5355","inReplyTo":"200608222342.53861.jnareb@gmail.com","subject":"Re: [PATCH 4/3] gitweb: Use here-doc","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-23T01:34:11Z","receivedAt":"2006-08-23T01:34:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index e09204d..5301213 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -1185,11 +1185,13 @@ sub die_error {\n>  \tmy $error = shift || \"Malformed query, file missing or permission \n> denied\";\n\nCorrupt patch applied by hand.  Please check the result in\n\"next\".\n"},{"id":"25775","messageId":"7virkkjkvd.fsf@assigned-by-dhcp.cox.net","threadId":"5355","inReplyTo":"200608221652.50443.jnareb@gmail.com","subject":"Re: [PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-23T01:34:14Z","receivedAt":"2006-08-23T01:34:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> This patch tries (but no too hard) to fit gitweb source in 80 columns,\n> for 2 columns wide tabs, and indent and align source for better\n> readibility.\n\nIf you are doing the wrapping, which I think is a good idea, I\ndo not think you should target for an oddball setting.  Where\ndid you get the idea of 2-column tabs?\n\n> While at it added comment to 'snapshot' entry defaults for %feature\n> hash, corrected \"blobl\" action in git_blame2 and git_blame to \"blob\",\n> key of argument to $cgi->a from 'class' to '-class'.\n\nAll look good otherwise; applied.\n\n> +our %feature = (\n> +\t# feature => {'sub' => feature-sub, 'override' => allow-override, 'default' => [ default options...]\n> +\t# if feature is overridable, feature-sub will be called with default options;\n> +\t# return value indicates if to enable specified feature\n\nI'd prefer if you wrapped these to match the real ones.\n\n> +\t'snapshot' => {\n> +\t\t'sub' => \\&feature_snapshot,\n> +\t\t'override' => 0,\n> +\t\t#         => [content-encoding, suffix, program]\n> +\t\t'default' => ['x-gzip', 'gz', 'gzip']},\n>  );\n\nBecause making this 3-tuple into a hashref would be an overkill,\nit is a very good idea to comment it here.\n"},{"id":"25790","messageId":"ech55l$reh$1@sea.gmane.org","threadId":"5355","inReplyTo":"7virkkjkvd.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-23T08:55:22Z","receivedAt":"2006-08-23T08:55:22Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> This patch tries (but no too hard) to fit gitweb source in 80 columns,\n>> for 2 columns wide tabs, and indent and align source for better\n>> readibility.\n> \n> If you are doing the wrapping, which I think is a good idea, I\n> do not think you should target for an oddball setting.  Where\n> did you get the idea of 2-column tabs?\n\nSo what is the default? 5-column tabs? 8-column tabs? And to what width?\n80-column wide? 120-column wide?\n\nI use 2-column tabs to have code not too wide; minimal sensible width.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25791","messageId":"44EC1AB8.1090005@op5.se","threadId":"5355","inReplyTo":"ech55l$reh$1@sea.gmane.org","subject":"Re: [PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-08-23T09:07:04Z","receivedAt":"2006-08-23T09:07:04Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Jakub Narebski wrote:\n> Junio C Hamano wrote:\n> \n>> Jakub Narebski <jnareb@gmail.com> writes:\n>>\n>>> This patch tries (but no too hard) to fit gitweb source in 80 columns,\n>>> for 2 columns wide tabs, and indent and align source for better\n>>> readibility.\n>> If you are doing the wrapping, which I think is a good idea, I\n>> do not think you should target for an oddball setting.  Where\n>> did you get the idea of 2-column tabs?\n> \n> So what is the default? 5-column tabs? 8-column tabs? And to what width?\n> 80-column wide? 120-column wide?\n> \n> I use 2-column tabs to have code not too wide; minimal sensible width.\n\nDefault is 8-column tabs. BSD folks use (used?) 4 column tabs by \ndefault. I've never seen 2 column tabs, although GNU does 2-step \nindentation (they use spaces though, not tabs).\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"25796","messageId":"7vac5vixnp.fsf@assigned-by-dhcp.cox.net","threadId":"5355","inReplyTo":"ech55l$reh$1@sea.gmane.org","subject":"Re: [PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-23T09:55:38Z","receivedAt":"2006-08-23T09:55:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> So what is the default? 5-column tabs? 8-column tabs? And to what width?\n> 80-column wide? 120-column wide?\n\nQuoting the person who invented git:\n\n                    Chapter 1: Indentation\n\n    Tabs are 8 characters, and thus indentations are also 8 characters.\n    There are heretic movements that try to make indentations 4 (or even 2!)\n    characters deep, and that is akin to trying to define the value of PI to\n    be 3.\n\n    Rationale: The whole idea behind indentation is to clearly define where\n    a block of control starts and ends.  Especially when you've been looking\n    at your screen for 20 straight hours, you'll find it a lot easier to see\n    how the indentation works if you have large indentations.\n\n    Now, some people will claim that having 8-character indentations makes\n    the code move too far to the right, and makes it hard to read on a\n    80-character terminal screen.  The answer to that is that if you need\n    more than 3 levels of indentation, you're screwed anyway, and should fix\n    your program.\n"}]}