{"thread":{"id":"5299","subject":"[PATCH] gitweb: continue consolidation of URL generation.","startedAt":"2006-08-16T22:28:36Z","lastAt":"2006-08-19T21:44:27Z","messageCount":25,"participants":["Martin Waitz","Junio C Hamano","Jakub Narebski","Carl Worth","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"25432","messageId":"11557673213372-git-send-email-tali@admingilde.org","threadId":"5299","inReplyTo":null,"subject":"[PATCH] gitweb: continue consolidation of URL generation.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:28:36Z","receivedAt":"2006-08-16T22:28:36Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"Further use href() instead of URL generation by string concatenation.\nAlmost all functions are converted now.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n---\n gitweb/gitweb.perl |   68 +++++++++++++++++++++++++++-------------------------\n 1 files changed, 35 insertions(+), 33 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 37a6284..72e687e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -204,7 +204,9 @@ sub href(%) {\n \n \tmy $href = \"$my_uri?\";\n \t$href .= esc_param( join(\";\",\n-\t\tmap { \"$mapping{$_}=$params{$_}\" } keys %params\n+\t\tmap {\n+\t\t\t\"$mapping{$_}=$params{$_}\" if $params{$_}\n+\t\t} keys %params\n \t) );\n \n \treturn $href;\n@@ -1047,7 +1049,7 @@ sub git_footer_html {\n \t\t}\n \t\tprint $cgi->a({-href => href(action=>\"rss\"), -class => \"rss_logo\"}, \"RSS\") . \"\\n\";\n \t} else {\n-\t\tprint $cgi->a({-href => \"$my_uri?\" . esc_param(\"a=opml\"), -class => \"rss_logo\"}, \"OPML\") . \"\\n\";\n+\t\tprint $cgi->a({-href => href(action=>\"opml\"), -class => \"rss_logo\"}, \"OPML\") . \"\\n\";\n \t}\n \tprint \"</div>\\n\" .\n \t      \"</body>\\n\" .\n@@ -1252,7 +1254,7 @@ sub git_difftree_body {\n \t\t\t      \"<td class=\\\"link\\\">\" .\n \t\t\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, \"blob\");\n \t\t\tif ($to_id ne $from_id) { # modified\n-\t\t\t\tprint $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, \"diff\");\n+\t\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, \"diff\");\n \t\t\t}\n \t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"history\", hash_base=>$hash, file_name=>$file)}, \"history\") . \"\\n\";\n \t\t\tprint \"</td>\\n\";\n@@ -1663,16 +1665,16 @@ sub git_project_list {\n \t\t\tprint \"<tr class=\\\"light\\\">\\n\";\n \t\t}\n \t\t$alternate ^= 1;\n-\t\tprint \"<td>\" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$pr->{'path'};a=summary\"),\n+\t\tprint \"<td>\" . $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"summary\"),\n \t\t                        -class => \"list\"}, esc_html($pr->{'path'})) . \"</td>\\n\" .\n \t\t      \"<td>\" . esc_html($pr->{'descr'}) . \"</td>\\n\" .\n \t\t      \"<td><i>\" . chop_str($pr->{'owner'}, 15) . \"</i></td>\\n\";\n \t\tprint \"<td class=\\\"\". age_class($pr->{'commit'}{'age'}) . \"\\\">\" .\n \t\t      $pr->{'commit'}{'age_string'} . \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$pr->{'path'};a=summary\")}, \"summary\")   . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$pr->{'path'};a=shortlog\")}, \"shortlog\") . \" | \" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$pr->{'path'};a=log\")}, \"log\") .\n+\t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"summary\")}, \"summary\")   . \" | \" .\n+\t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"shortlog\")}, \"shortlog\") . \" | \" .\n+\t\t      $cgi->a({-href => href(project=>$pr->{'path'}, action=>\"log\")}, \"log\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\\n\";\n \t}\n@@ -2036,11 +2038,11 @@ sub git_tree {\n \tmy $refs = git_get_references();\n \tmy $ref = format_ref_marker($refs, $hash_base);\n \tgit_header_html();\n-\tmy $base_key = \"\";\n+\tmy %base_key = ();\n \tmy $base = \"\";\n \tmy $have_blame = git_get_project_config_bool ('blame');\n \tif (defined $hash_base && (my %co = parse_commit($hash_base))) {\n-\t\t$base_key = \";hb=$hash_base\";\n+\t\t$base_key{hash_base} = $hash_base;\n \t\tgit_print_page_nav('tree','', $hash_base);\n \t\tgit_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);\n \t} else {\n@@ -2071,23 +2073,23 @@ 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 => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name\"), -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), -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 => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name\")}, \"blob\");\n+\t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$t_hash, file_name=>\"$base$t_name\", %base_key)}, \"blob\");\n \t\t\tif ($have_blame) {\n-\t\t\t\tprint \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blame;h=$t_hash$base_key;f=$base$t_name\")}, \"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}\n-\t\t\tprint \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=history;h=$t_hash;hb=$hash_base;f=$base$t_name\")}, \"history\") .\n-\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob_plain;h=$t_hash;f=$base$t_name\")}, \"raw\") .\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\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 => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name\")}, esc_html($t_name)) .\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      \"</td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name\")}, \"tree\") .\n-\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=history;hb=$hash_base;f=$base$t_name\")}, \"history\") .\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      \"</td>\\n\";\n \t\t}\n \t\tprint \"</tr>\\n\";\n@@ -2276,7 +2278,7 @@ 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 => \"$my_uri?\" . esc_param(\"p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent\")}, \"plain\");\n+\t\t\t$cgi->a({-href => href(action=>\"blobdiff_plain\", hash=>$hash, hash_parent=>$hash_parent)}, \"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@@ -2287,9 +2289,9 @@ sub git_blobdiff {\n \tgit_print_page_path($file_name, \"blob\");\n \tprint \"<div class=\\\"page_body\\\">\\n\" .\n \t      \"<div class=\\\"diff_info\\\">blob:\" .\n-\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name\")}, $hash_parent) .\n+\t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash_parent, hash_base=>$hash_base, file_name=>$file_name)}, $hash_parent) .\n \t      \" -> blob:\" .\n-\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name\")}, $hash) .\n+\t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, $hash) .\n \t      \"</div>\\n\";\n \tgit_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);\n \tprint \"</div>\";\n@@ -2324,7 +2326,7 @@ 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 => \"$my_uri?\" . esc_param(\"p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent\")}, \"plain\");\n+\t\t$cgi->a({-href => href(action=>\"commitdiff_plain\", hash=>$hash, hash_parent=>$hash_parent)}, \"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@@ -2367,22 +2369,22 @@ 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 => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$file\")}, $to_id) . \"(new)\" .\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      \"</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 => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$from_id;hb=$hash_parent;f=$file\")}, $from_id) . \"(deleted)\" .\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      \"</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 => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$from_id;hb=$hash_parent;f=$file\")}, $from_id) .\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      \" -> \" .\n \t\t\t\t      file_type($to_mode) . \":\" .\n-\t\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$to_id;hb=$hash;f=$file\")}, $to_id);\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\tprint \"</div>\\n\";\n \t\t\t\tgit_diff_print($from_id, \"a/$file\",  $to_id, \"b/$file\");\n \t\t\t}\n@@ -2544,7 +2546,7 @@ sub git_search {\n \t\t\tprint \"<td title=\\\"$co{'age_string_age'}\\\"><i>$co{'age_string_date'}</i></td>\\n\" .\n \t\t\t      \"<td><i>\" . esc_html(chop_str($co{'author_name'}, 15, 5)) . \"</i></td>\\n\" .\n \t\t\t      \"<td>\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$co{'id'}\"), -class => \"list\"}, \"<b>\" . esc_html(chop_str($co{'title'}, 50)) . \"</b><br/>\");\n+\t\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$co{'id'}) -class => \"list\"}, \"<b>\" . esc_html(chop_str($co{'title'}, 50)) . \"</b><br/>\");\n \t\t\tmy $comment = $co{'comment'};\n \t\t\tforeach my $line (@$comment) {\n \t\t\t\tif ($line =~ m/^(.*)($searchtext)(.*)$/i) {\n@@ -2559,8 +2561,8 @@ sub git_search {\n \t\t\t}\n \t\t\tprint \"</td>\\n\" .\n \t\t\t      \"<td class=\\\"link\\\">\" .\n-\t\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$co{'id'}\")}, \"commit\") .\n-\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}\")}, \"tree\");\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\tprint \"</td>\\n\" .\n \t\t\t      \"</tr>\\n\";\n \t\t}\n@@ -2597,18 +2599,18 @@ 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 => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$co{'id'}\"), -class => \"list\"}, \"<b>\" .\n+\t\t\t\t\t      $cgi->a({-href => href(action=>\"commit\", hash=>$co{'id'}), -class => \"list\"}, \"<b>\" .\n \t\t\t\t\t      esc_html(chop_str($co{'title'}, 50)) . \"</b><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 => \"$my_uri?\" . esc_param(\"p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}\"), class => \"list\"},\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\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 => \"$my_uri?\" . esc_param(\"p=$project;a=commit;h=$co{'id'}\")}, \"commit\") .\n-\t\t\t\t\t      \" | \" . $cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}\")}, \"tree\");\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\tprint \"</td>\\n\" .\n \t\t\t\t\t      \"</tr>\\n\";\n \t\t\t\t}\n@@ -2641,7 +2643,7 @@ sub git_shortlog {\n \tmy $next_link = '';\n \tif ($#revlist >= (100 * ($page+1)-1)) {\n \t\t$next_link =\n-\t\t\t$cgi->a({-href => \"$my_uri?\" . esc_param(\"p=$project;a=shortlog;h=$hash;pg=\" . ($page+1)),\n+\t\t\t$cgi->a({-href => href(action=>\"shortlog\", hash=>$hash, page=>$page+1),\n \t\t\t         -title => \"Alt-n\"}, \"next\");\n \t}\n \n-- \n1.4.2.rc2.gf055\n"},{"id":"25433","messageId":"11557673212235-git-send-email-tali@admingilde.org","threadId":"5299","inReplyTo":"11557673213372-git-send-email-tali@admingilde.org","subject":"[PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:28:37Z","receivedAt":"2006-08-16T22:28:37Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"The \"o\" (list order) parameter was handled special.\nNow it is generated with the common href() function and parsed together with\nall other parameters.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n---\n gitweb/gitweb.perl |   19 ++++++++++---------\n 1 files changed, 10 insertions(+), 9 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 72e687e..ed6bd0e 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -91,6 +91,11 @@ if (defined $action) {\n \t}\n }\n \n+our $order = $cgi->param('o');\n+if (defined $order && $order !~ m/project|descr|owner|age/) {\n+\tdie_error(undef, \"Unknown order parameter\");\n+}\n+\n our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});\n if (defined $project) {\n \t$project =~ s|^/||;\n@@ -197,6 +202,7 @@ sub href(%) {\n \t\thash_base => \"hb\",\n \t\tpage => \"pg\",\n \t\tsearchtext => \"s\",\n+\t\torder => \"o\",\n \t);\n \n \tmy %params = @_;\n@@ -1577,11 +1583,6 @@ ## =====================================\n ## actions\n \n sub git_project_list {\n-\tmy $order = $cgi->param('o');\n-\tif (defined $order && $order !~ m/project|descr|owner|age/) {\n-\t\tdie_error(undef, \"Unknown order parameter\");\n-\t}\n-\n \tmy @list = git_get_projects_list();\n \tmy @projects;\n \tif (!@list) {\n@@ -1624,7 +1625,7 @@ sub git_project_list {\n \t\tprint \"<th>Project</th>\\n\";\n \t} else {\n \t\tprint \"<th>\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"o=project\"),\n+\t\t      $cgi->a({-href => href(order=>\"project\"),\n \t\t               -class => \"header\"}, \"Project\") .\n \t\t      \"</th>\\n\";\n \t}\n@@ -1633,7 +1634,7 @@ sub git_project_list {\n \t\tprint \"<th>Description</th>\\n\";\n \t} else {\n \t\tprint \"<th>\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"o=descr\"),\n+\t\t      $cgi->a({-href => href(order=>\"descr\"),\n \t\t               -class => \"header\"}, \"Description\") .\n \t\t      \"</th>\\n\";\n \t}\n@@ -1642,7 +1643,7 @@ sub git_project_list {\n \t\tprint \"<th>Owner</th>\\n\";\n \t} else {\n \t\tprint \"<th>\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"o=owner\"),\n+\t\t      $cgi->a({-href => href(order=>\"owner\"),\n \t\t               -class => \"header\"}, \"Owner\") .\n \t\t      \"</th>\\n\";\n \t}\n@@ -1651,7 +1652,7 @@ sub git_project_list {\n \t\tprint \"<th>Last Change</th>\\n\";\n \t} else {\n \t\tprint \"<th>\" .\n-\t\t      $cgi->a({-href => \"$my_uri?\" . esc_param(\"o=age\"),\n+\t\t      $cgi->a({-href => href(order=>\"age\"),\n \t\t               -class => \"header\"}, \"Last Change\") .\n \t\t      \"</th>\\n\";\n \t}\n-- \n1.4.2.rc2.gf055\n"},{"id":"25437","messageId":"1155767325181-git-send-email-tali@admingilde.org","threadId":"5299","inReplyTo":"11557673212235-git-send-email-tali@admingilde.org","subject":"[PATCH] gitweb: support for \"fp\" parameter.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:28:38Z","receivedAt":"2006-08-16T22:28:38Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"The \"fp\" (file name parent) parameter was previously generated for\nblob diffs of renamed files.  However, it was not used in any code.\n\nNow href() can generate \"fp\" parameters and they are used by the\nblobdiff code to show the correct file name.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n---\n gitweb/gitweb.perl |   16 +++++++++++-----\n 1 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex ed6bd0e..a022569 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -124,6 +124,13 @@ if (defined $file_name) {\n \t}\n }\n \n+our $file_parent = $cgi->param('fp');\n+if (defined $file_parent) {\n+\tif (!validate_input($file_parent)) {\n+\t\tdie_error(undef, \"Invalid file parent parameter\");\n+\t}\n+}\n+\n our $hash = $cgi->param('h');\n if (defined $hash) {\n \tif (!validate_input($hash)) {\n@@ -197,6 +204,7 @@ sub href(%) {\n \t\taction => \"a\",\n \t\tproject => \"p\",\n \t\tfile_name => \"f\",\n+\t\tfile_parent => \"fp\",\n \t\thash => \"h\",\n \t\thash_parent => \"hp\",\n \t\thash_base => \"hb\",\n@@ -1282,8 +1290,7 @@ sub git_difftree_body {\n \t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, \"blob\");\n \t\t\tif ($to_id ne $from_id) {\n \t\t\t\tprint \" | \" .\n-\t\t\t\t      $cgi->a({-href => \"$my_uri?\" .\n-\t\t\t\t              esc_param(\"p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file;fp=$from_file\")}, \"diff\");\n+\t\t\t\t      $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$to_file, file_parent=>$from_file)}, \"diff\");\n \t\t\t}\n \t\t\tprint \"</td>\\n\";\n \n@@ -1304,8 +1311,7 @@ sub git_difftree_body {\n \t\t\t      $cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$to_file)}, \"blob\");\n \t\t\tif ($to_id ne $from_id) {\n \t\t\t\tprint \" | \" .\n-\t\t\t\t      $cgi->a({-href => \"$my_uri?\" .\n-\t\t\t\t              esc_param(\"p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file;fp=$from_file\")}, \"diff\");\n+\t\t\t\t      $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$to_file, file_parent=>$from_file)}, \"diff\");\n \t\t\t}\n \t\t\tprint \"</td>\\n\";\n \t\t} # we should not encounter Unmerged (U) or Unknown (X) status\n@@ -2290,7 +2296,7 @@ sub git_blobdiff {\n \tgit_print_page_path($file_name, \"blob\");\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_name)}, $hash_parent) .\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      \" -> blob:\" .\n \t      $cgi->a({-href => href(action=>\"blob\", hash=>$hash, hash_base=>$hash_base, file_name=>$file_name)}, $hash) .\n \t      \"</div>\\n\";\n-- \n1.4.2.rc2.gf055\n"},{"id":"25434","messageId":"11557673263081-git-send-email-tali@admingilde.org","threadId":"5299","inReplyTo":"1155767325181-git-send-email-tali@admingilde.org","subject":"[PATCH] gitweb: support for / as home_link.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:28:39Z","receivedAt":"2006-08-16T22:28:39Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"If the webserver is configured to use gitweb even for the root directory\nof the site, then my_uri is empty which leads to a non-functional home\nlink.  Fix that by defaulting to \"/\" in this case.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a022569..0a0b37f 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -34,7 +34,7 @@ # location for temporary files needed fo\n our $git_temp = \"/tmp/gitweb\";\n \n # target of the home link on top of all pages\n-our $home_link = $my_uri;\n+our $home_link = $my_uri || \"/\";\n \n # string of the home link on top of all pages\n our $home_link_str = \"++GITWEB_HOME_LINK_STR++\";\n-- \n1.4.2.rc2.gf055\n"},{"id":"25436","messageId":"11557673262714-git-send-email-tali@admingilde.org","threadId":"5299","inReplyTo":"11557673263081-git-send-email-tali@admingilde.org","subject":"[PATCH] gitweb: fix project list if PATH_INFO==\"/\".","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:28:40Z","receivedAt":"2006-08-16T22:28:40Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"The project list now uses several common header / footer generation functions.\nThese functions only check for \"defined $project\", but when PATH_INFO just\ncontains a \"/\" (which is often generated by web servers), then this test\nfails.\n\nNow explicitly undef $project if there is none so that the tests in other\ngitweb parts work again.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\n---\n gitweb/gitweb.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 0a0b37f..3b6333c 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -100,8 +100,9 @@ our $project = ($cgi->param('p') || $ENV\n if (defined $project) {\n \t$project =~ s|^/||;\n \t$project =~ s|/$||;\n+\t$project = undef unless $project;\n }\n-if (defined $project && $project) {\n+if (defined $project) {\n \tif (!validate_input($project)) {\n \t\tdie_error(undef, \"Invalid project parameter\");\n \t}\n-- \n1.4.2.rc2.gf055\n"},{"id":"25435","messageId":"11557673281583-git-send-email-tali@admingilde.org","threadId":"5299","inReplyTo":"11557673262714-git-send-email-tali@admingilde.org","subject":"[PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-16T22:28:41Z","receivedAt":"2006-08-16T22:28:41Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"Allow to use the global action dispatcher for all actions by introducing\n\"/actions\".  If no project directory is given then a / is prepended to the\naction and the normal dispatcher is called.\nProject list and OPML generation are now hooked into the list as \"/summary\"\nand \"/opml\".\n\nAs \"/\" is not an allowed character in actions accepted through the CGI\nparameters, it is still ensured that no normal action can be called without\ngiving a valid project directory.\n\nSigned-off-by: Martin Waitz <tali@admingilde.org>\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 3b6333c..9a7faab 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -84,11 +84,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 $order = $cgi->param('o');\n@@ -113,9 +108,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@@ -185,12 +177,19 @@ my %actions = (\n \t\"search\" => \\&git_search,\n \t\"shortlog\" => \\&git_shortlog,\n \t\"summary\" => \\&git_summary,\n+\t\"/summary\" => \\&git_project_list,\n+\t\"/opml\" => \\&git_opml,\n \t\"tag\" => \\&git_tag,\n \t\"tags\" => \\&git_tags,\n \t\"tree\" => \\&git_tree,\n );\n \n-$action = 'summary' if (!defined($action));\n+# default action\n+$action ||= 'summary';\n+\n+#only allow non-/ actions if we have a project directory\n+$action = \"/$action\" if !defined($project);\n+\n if (!defined($actions{$action})) {\n \tdie_error(undef, \"Unknown action\");\n }\n-- \n1.4.2.rc2.gf055\n"},{"id":"25442","messageId":"7voduk15sc.fsf@assigned-by-dhcp.cox.net","threadId":"5299","inReplyTo":"11557673213372-git-send-email-tali@admingilde.org","subject":"Re: [PATCH] gitweb: continue consolidation of URL generation.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-17T01:59:15Z","receivedAt":"2006-08-17T01:59:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Waitz <tali@admingilde.org> writes:\n\n> Further use href() instead of URL generation by string concatenation.\n> Almost all functions are converted now.\n>\n> Signed-off-by: Martin Waitz <tali@admingilde.org>\n> ---\n>  gitweb/gitweb.perl |   68 +++++++++++++++++++++++++++-------------------------\n>  1 files changed, 35 insertions(+), 33 deletions(-)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 37a6284..72e687e 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -204,7 +204,9 @@ sub href(%) {\n>  \n>  \tmy $href = \"$my_uri?\";\n>  \t$href .= esc_param( join(\";\",\n> -\t\tmap { \"$mapping{$_}=$params{$_}\" } keys %params\n> +\t\tmap {\n> +\t\t\t\"$mapping{$_}=$params{$_}\" if $params{$_}\n> +\t\t} keys %params\n>  \t) );\n>  \n>  \treturn $href;\n\nThis is not about \"further use href()\".\n\nI think \"if $params{$_}\" is unsafe here.  Can you guarantee that\nwe will never want to pass 0 or an empty string as an parameter\nvalue both in the current and the future code?\n\nI think it needs to be \"if defined $params{$_}\", at least.\n\n> @@ -1252,7 +1254,7 @@ sub git_difftree_body {\n>  \t\t\t      \"<td class=\\\"link\\\">\" .\n>  \t\t\t\t$cgi->a({-href => href(action=>\"blob\", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, \"blob\");\n>  \t\t\tif ($to_id ne $from_id) { # modified\n> -\t\t\t\tprint $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, \"diff\");\n> +\t\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"blobdiff\", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, \"diff\");\n>  \t\t\t}\n>  \t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"history\", hash_base=>$hash, file_name=>$file)}, \"history\") . \"\\n\";\n>  \t\t\tprint \"</td>\\n\";\n\nWell spotted.\n"},{"id":"25443","messageId":"7vk65815h1.fsf@assigned-by-dhcp.cox.net","threadId":"5299","inReplyTo":"11557673281583-git-send-email-tali@admingilde.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-17T02:06:02Z","receivedAt":"2006-08-17T02:06:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Waitz <tali@admingilde.org> writes:\n\n> Allow to use the global action dispatcher for all actions by introducing\n> \"/actions\".  If no project directory is given then a / is prepended to the\n> action and the normal dispatcher is called.\n> Project list and OPML generation are now hooked into the list as \"/summary\"\n> and \"/opml\".\n>\n> As \"/\" is not an allowed character in actions accepted through the CGI\n> parameters, it is still ensured that no normal action can be called without\n> giving a valid project directory.\n>\n> Signed-off-by: Martin Waitz <tali@admingilde.org>\n> ---\n>  gitweb/gitweb.perl |   17 ++++++++---------\n>  1 files changed, 8 insertions(+), 9 deletions(-)\n\nYou completely lost me.  What are you trying to achieve here?\n\nI suspect this kind of funkies (and PATH_INFO) might be easier\nto do in mod_rewrite() outside gitweb, but that is probably just\nme.\n"},{"id":"25471","messageId":"ec1d6q$823$2@sea.gmane.org","threadId":"5299","inReplyTo":"11557673212235-git-send-email-tali@admingilde.org","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-17T09:35:18Z","receivedAt":"2006-08-17T09:35:18Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Martin Waitz wrote:\n\n> The \"o\" (list order) parameter was handled special.\n> Now it is generated with the common href() function and parsed together with\n> all other parameters.\n \nThis was because \"o\" (sort table by) parameter was used only\nin one place, and valid values of order parameter depends on\nthe place it is used.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25473","messageId":"ec1dis$823$3@sea.gmane.org","threadId":"5299","inReplyTo":"11557673281583-git-send-email-tali@admingilde.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-17T09:41:43Z","receivedAt":"2006-08-17T09:41:43Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Martin Waitz wrote:\n\n> Project list and OPML generation are now hooked into the list as\n> \"/summary\" and \"/opml\".\n\nIt would be better to use \"/list\" or \"/projects\", although empty or undef or\n\"/\" action would work as well.\n\nHaving both \"/summary\" (for projects list) and \"summary\" (for project\nsummary) is bad, bad idea.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25484","messageId":"87y7tnxv9g.wl%cworth@cworth.org","threadId":"5299","inReplyTo":"7vk65815h1.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-08-17T15:00:11Z","receivedAt":"2006-08-17T15:00:11Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"On Wed, 16 Aug 2006 19:06:02 -0700, Junio C Hamano wrote:\n>\n> You completely lost me.  What are you trying to achieve here?\n\nPresumably the goal is to take better advantage of the hierarchical\nnamespace provided with the path component of the URL before dropping\nto the query string.\n\n> I suspect this kind of funkies (and PATH_INFO) might be easier\n> to do in mod_rewrite() outside gitweb, but that is probably just\n> me.\n\nPersonally, I disagree, (at least as far as PATH_INFO---my feelings\naren't as strong for the action parameters).\n\nA current problem I have with git is the difficulty of publishing a\nnew repository to the world. With our current setup on\nfreedesktop.org, for example, I have to publish 3 separate URLs\ndepending on how users might decide to interact with my repository,\n(one for gitweb browsing and two separate URLs for doing git\nclone/fetch/pull over either git: or http:). Much of that can now be\nfixed with configuration changes on our server---but anything git can\ndo to simplify the amount of configuration is definitely appreciated.\n\n-Carl\n\nPS. A secondary problem is the difficulty of publishing a new\nbranch. But if I can get the 3 URLs above down to 1, then I could\nprobably live with the user having to figure out how to combine the\nrepository URL with the branch name, (in different ways depending on\nwhat the user is doing).\n"},{"id":"25501","messageId":"20060817191300.GA11477@admingilde.org","threadId":"5299","inReplyTo":"ec1d6q$823$2@sea.gmane.org","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-17T19:13:00Z","receivedAt":"2006-08-17T19:13:00Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Thu, Aug 17, 2006 at 11:35:18AM +0200, Jakub Narebski wrote:\n> > The \"o\" (list order) parameter was handled special.\n> > Now it is generated with the common href() function and parsed together with\n> > all other parameters.\n>  \n> This was because \"o\" (sort table by) parameter was used only\n> in one place, and valid values of order parameter depends on\n> the place it is used.\n\nBut I'd really like to have all the parameter parsing and generation\ncode in one place.\n\nPerhaps we can agree that only the validation should be coupled with the\nactual user?  E.g. use normal validate_input() for it and then check\nfor actual values inside git_project_list (which is already done now).\n\n-- \nMartin Waitz\n"},{"id":"25502","messageId":"20060817193251.GB11477@admingilde.org","threadId":"5299","inReplyTo":"7voduk15sc.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: continue consolidation of URL generation.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-17T19:32:51Z","receivedAt":"2006-08-17T19:32:51Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Wed, Aug 16, 2006 at 06:59:15PM -0700, Junio C Hamano wrote:\n> This is not about \"further use href()\".\n\nRight.\n\nI thought that it was needed in order to generate links to the\nmain project list page.  But as this is only done via $home_link\nthis hunk is not needed.  I just forgot to remove it again.\n\nShould I send another patch or do you want to remove it yourself?\n\n-- \nMartin Waitz\n"},{"id":"25503","messageId":"200608172134.38751.jnareb@gmail.com","threadId":"5299","inReplyTo":"20060817191300.GA11477@admingilde.org","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-17T19:34:38Z","receivedAt":"2006-08-17T19:34:38Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Thu, Aug 17, 2006 at 21:13, Martin Waitz wrote:\n> On Thu, Aug 17, 2006 at 11:35:18AM +0200, Jakub Narebski wrote:\n>>> The \"o\" (list order) parameter was handled special.\n>>> Now it is generated with the common href() function and parsed together with\n>>> all other parameters.\n>>  \n>> This was because \"o\" (sort table by) parameter was used only\n>> in one place, and valid values of order parameter depends on\n>> the place it is used.\n> \n> But I'd really like to have all the parameter parsing and generation\n> code in one place.\n> \n> Perhaps we can agree that only the validation should be coupled with the\n> actual user?  E.g. use normal validate_input() for it and then check\n> for actual values inside git_project_list (which is already done now).\n\nThe validate_input() function has too generic name and is too widely used:\nit should be split into validate_ref() and validate_path(); perhaps \"o\"\nshould be validate with $order =~ m/^[a-zA-Z]$/ \n\nBut I was thinking about moving parameter parsing to the \"action\" functions\nwhich use them, the opposite of what you want to do...\n\n-- \nJakub Narebski\nPoland\n"},{"id":"25504","messageId":"20060817194332.GC11477@admingilde.org","threadId":"5299","inReplyTo":"7vk65815h1.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-17T19:43:32Z","receivedAt":"2006-08-17T19:43:32Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Wed, Aug 16, 2006 at 07:06:02PM -0700, Junio C Hamano wrote:\n> Martin Waitz <tali@admingilde.org> writes:\n> \n> > Allow to use the global action dispatcher for all actions by introducing\n> > \"/actions\".  If no project directory is given then a / is prepended to the\n> > action and the normal dispatcher is called.\n> > Project list and OPML generation are now hooked into the list as \"/summary\"\n> > and \"/opml\".\n> >\n> > As \"/\" is not an allowed character in actions accepted through the CGI\n> > parameters, it is still ensured that no normal action can be called without\n> > giving a valid project directory.\n> >\n> > Signed-off-by: Martin Waitz <tali@admingilde.org>\n> > ---\n> >  gitweb/gitweb.perl |   17 ++++++++---------\n> >  1 files changed, 8 insertions(+), 9 deletions(-)\n> \n> You completely lost me.  What are you trying to achieve here?\n\nI just want to separate all the URL generation/parsing from the rest\nof the code.\nSo I removed the opml/project list calls from the parsing code.\n\nThe target is to be able to be able to replace it without influencing\nother parts of the code.\n\n> I suspect this kind of funkies (and PATH_INFO) might be easier\n> to do in mod_rewrite() outside gitweb, but that is probably just\n> me.\n\nWell, I think that the URL shown in the browser is one important\npart of the user interface of a web page. So we should not rely\non the system administrator to implement it on his own.\n\n-- \nMartin Waitz\n"},{"id":"25505","messageId":"20060817194913.GD11477@admingilde.org","threadId":"5299","inReplyTo":"ec1dis$823$3@sea.gmane.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-17T19:49:14Z","receivedAt":"2006-08-17T19:49:14Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Thu, Aug 17, 2006 at 11:41:43AM +0200, Jakub Narebski wrote:\n> > Project list and OPML generation are now hooked into the list as\n> > \"/summary\" and \"/opml\".\n> \n> It would be better to use \"/list\" or \"/projects\", although empty or undef or\n> \"/\" action would work as well.\n> \n> Having both \"/summary\" (for projects list) and \"summary\" (for project\n> summary) is bad, bad idea.\n\nwell, it was a little trick so that only one default action \"summary\"\nis needed.  I have no strong feelings about it so any other name is\ngood for me, too.\n\n-- \nMartin Waitz\n"},{"id":"25506","messageId":"ec2hrj$a37$1@sea.gmane.org","threadId":"5299","inReplyTo":"20060817194913.GD11477@admingilde.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-17T20:00:50Z","receivedAt":"2006-08-17T20:00:50Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Martin Waitz wrote:\n\n> hoi :)\n> \n> On Thu, Aug 17, 2006 at 11:41:43AM +0200, Jakub Narebski wrote:\n>> > Project list and OPML generation are now hooked into the list as\n>> > \"/summary\" and \"/opml\".\n>> \n>> It would be better to use \"/list\" or \"/projects\", although empty or \n>> undef or \"/\" action would work as well.\n>> \n>> Having both \"/summary\" (for projects list) and \"summary\" (for project\n>> summary) is bad, bad idea.\n> \n> well, it was a little trick so that only one default action \"summary\"\n> is needed.  I have no strong feelings about it so any other name is\n> good for me, too.\n\nif (defined $project) { # with the patch that undef $project when empty\n        $action ||= \"summary\";\n} else {\n        $action ||= \"/projects_list\"; # or simply \"projects_list\", or \"/\"\n}\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25554","messageId":"20060818131656.GR13776@pasky.or.cz","threadId":"5299","inReplyTo":"87y7tnxv9g.wl%cworth@cworth.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-08-18T13:16:57Z","receivedAt":"2006-08-18T13:16:57Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, Aug 17, 2006 at 05:00:11PM CEST, I got a letter\nwhere Carl Worth <cworth@cworth.org> said that...\n> PS. A secondary problem is the difficulty of publishing a new\n> branch. But if I can get the 3 URLs above down to 1, then I could\n> probably live with the user having to figure out how to combine the\n> repository URL with the branch name, (in different ways depending on\n> what the user is doing).\n\nCould you be more specific here, please? Is it just that Git won't\nautomagically pick up new branches published on the server?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nSnow falling on Perl. White noise covering line noise.\nHides all the bugs too. -- J. Putnam\n"},{"id":"25559","messageId":"87k656rvim.wl%cworth@cworth.org","threadId":"5299","inReplyTo":"20060818131656.GR13776@pasky.or.cz","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Carl Worth","fromEmail":"cworth@cworth.org","sentAt":"2006-08-18T14:03:29Z","receivedAt":"2006-08-18T14:03:29Z","isPatch":true,"sender":{"key":"cworth@cworth.org","avatar":"https://gravatar.com/avatar/3746dc28cde609bdbd7f939058356e7e2bbd16d21e32274df0725eb3d998bc5b?d=mp&s=160"},"body":"On Fri, 18 Aug 2006 15:16:57 +0200, Petr Baudis wrote:\n>\n> Dear diary, on Thu, Aug 17, 2006 at 05:00:11PM CEST, I got a letter\n> where Carl Worth <cworth@cworth.org> said that...\n> > PS. A secondary problem is the difficulty of publishing a new\n> > branch. But if I can get the 3 URLs above down to 1, then I could\n> > probably live with the user having to figure out how to combine the\n> > repository URL with the branch name, (in different ways depending on\n> > what the user is doing).\n>\n> Could you be more specific here, please? Is it just that Git won't\n> automagically pick up new branches published on the server?\n\nThe best I've been able to come up with is:\n\n\tSee my new branch <branch> at <URL>\n\nThen it's up to the user to do one of the following (depending on what\nthey want):\n\n1. For gitweb, either:\n\n  a. Browse to <URL> and manually find <branch> in the list (ugh!)\n\n  b. Manually construct a branch-specific URL: <URL>;h=<branch>\n\n2. For git fetch/clone:\n\n  Construct a command line looking something like this:\n\n\tgit fetch <URL> <branch>:tracking-branch\n\n  and optionally do some manual editing of a config file if they want\n  to easily get at this branch again in the future.\n\nAnd that assumes I can give out a single <URL> in the first place, of\ncourse.\n\nBeyond that, here are some of the things I would like:\n\n* A single thingy I could publish for <URL> and <branch>. Ideally this\n  would have no whitespace in it and would be directly\n  cut-and-paste-able for use in either gitweb or the git command-line.\n\n* A mechanism for not requiring me to invent tracking-branch names.  I\n  end up manually doing a scheme with short prefixes for any given\n  repository. It would be nice if I could configure that (in\n  .git/remotes/<something> say) once so that any new branch I pulled\n  would get its properly named tracking branch. And git could find the\n  right remotes file by matching up the URL.\n\n* An easy way, (maybe a one-letter command-line option), for stashing\n  a branch I'm fetching off into .git/remotes/<something> where again,\n  it would find the right file by matching the URL. This option might\n  also let me/help me name <something> if this is the first time I'm\n  fetching from a particular URL.\n\n-Carl\n"},{"id":"25560","messageId":"ec4ie9$sht$1@sea.gmane.org","threadId":"5299","inReplyTo":"87k656rvim.wl%cworth@cworth.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-18T14:22:01Z","receivedAt":"2006-08-18T14:22:01Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Carl Worth wrote:\n\n> * A mechanism for not requiring me to invent tracking-branch names.  I\n>   end up manually doing a scheme with short prefixes for any given\n>   repository. It would be nice if I could configure that (in\n>   .git/remotes/<something> say) once so that any new branch I pulled\n>   would get its properly named tracking branch. And git could find the\n>   right remotes file by matching up the URL.\n\nThis mechanism is called 'git clone --use-separate-remote'.\n\n  --use-separate-remote\n     Save remotes  heads under $GIT_DIR/remotes/origin/ instead  of\n     $GIT_DIR/refs/heads/. Only the master branch is saved in the latter.\n     (as origin).\n\n(Shouldn't it be $GIT_DIT/refs/remotes/<repository>/ instead, BTW?)\nAnd of course you can configure pull lines in the following way:\n\n  Pull: refs/heads/<branch>:refs/remotes/<repository>/<branch>\n\nUnfortunately, there is no way to automatically pull new refs and tags\nin such a way.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25564","messageId":"20060818154020.GU13764@pasky.or.cz","threadId":"5299","inReplyTo":"87k656rvim.wl%cworth@cworth.org","subject":"Re: [PATCH] gitweb: use action dispatcher for non-project actions, too.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-08-18T15:40:20Z","receivedAt":"2006-08-18T15:40:20Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Aug 18, 2006 at 04:03:29PM CEST, I got a letter\nwhere Carl Worth <cworth@cworth.org> said that...\n> * A single thingy I could publish for <URL> and <branch>. Ideally this\n>   would have no whitespace in it and would be directly\n>   cut-and-paste-able for use in either gitweb or the git command-line.\n\nPerhaps you could paste a fetch URL to some gitweb inputbox at the top\nof every page and it would show the right thing, sort of like mldonkey\nwith ed2k URLs...\n\n> * A mechanism for not requiring me to invent tracking-branch names.  I\n>   end up manually doing a scheme with short prefixes for any given\n>   repository. It would be nice if I could configure that (in\n>   .git/remotes/<something> say) once so that any new branch I pulled\n>   would get its properly named tracking branch. And git could find the\n>   right remotes file by matching up the URL.\n\nWe already have .git/refs/remote/ where the tracking branches are just\nthe same name as on the other side, we only need to start really using\nit.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nSnow falling on Perl. White noise covering line noise.\nHides all the bugs too. -- J. Putnam\n"},{"id":"25587","messageId":"20060818202013.GB30022@admingilde.org","threadId":"5299","inReplyTo":"200608172134.38751.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-18T20:20:13Z","receivedAt":"2006-08-18T20:20:13Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Thu, Aug 17, 2006 at 09:34:38PM +0200, Jakub Narebski wrote:\n> > Perhaps we can agree that only the validation should be coupled with the\n> > actual user?  E.g. use normal validate_input() for it and then check\n> > for actual values inside git_project_list (which is already done now).\n> \n> The validate_input() function has too generic name and is too widely used:\n> it should be split into validate_ref() and validate_path(); perhaps \"o\"\n> should be validate with $order =~ m/^[a-zA-Z]$/ \n\nagreed.\n\n> But I was thinking about moving parameter parsing to the \"action\" functions\n> which use them, the opposite of what you want to do...\n\nbut only short-term.\n\nI think we both agree on the same target:\nwe need some simple to pass parameters to a function which should only\nbe called if the user clicks on a specific link.\n\nNow lets talk about the interface to do this.\n\nWe need one interface for generating the URL (stub in RPC talk)\nand one for calling the function once the link is clicked (skeleton).\nWe now have the href() function which is not so bad for the stub side.\nWe now need a nice generic skeleton.\n\nPerhaps introduce a new function which is used to access the parameters?\nThis new function could check the URL or CGI->param or whatever and then\nreturn the requested value.\n\nThen the action functions could get all parameters they need, validate\nthem themselves and then act on them.\nThis would suit my \"break out parameter parsing from actions\" and your\n\"validate parameters in the action function\".\n(And I really interpret your sentence in such a way that you only want\nto move the _validation_, not the actual parsing (which is done inside\nCGI->param at the moment.)\n\n-- \nMartin Waitz\n"},{"id":"25605","messageId":"ec6qnp$aal$1@sea.gmane.org","threadId":"5299","inReplyTo":"20060818202013.GB30022@admingilde.org","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-19T10:55:57Z","receivedAt":"2006-08-19T10:55:57Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Martin Waitz wrote:\n\n> Perhaps introduce a new function which is used to access the parameters?\n> This new function could check the URL or CGI->param or whatever and then\n> return the requested value.\n\nCGI->param. There is no reason to duplicate CGI module.\n\n> Then the action functions could get all parameters they need, validate\n> them themselves and then act on them.\n> This would suit my \"break out parameter parsing from actions\" and your\n> \"validate parameters in the action function\".\n> (And I really interpret your sentence in such a way that you only want\n> to move the _validation_, not the actual parsing (which is done inside\n> CGI->param at the moment.)\n\nValidation and accessing. Parsing via CGI->param.\n\nThere is another reason I want to move accessing and validation of\nparameters to the \"action\" function (perhaps, as you suggested, via\n\"wrapper\" function), namely removing some global variables. Perhaps it is\nunnecessary, but I wonder how well that works with mod_perl. Other global\nvariables are configuration and do not change form execution to execution\nof script...\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"25623","messageId":"20060819183303.GC30022@admingilde.org","threadId":"5299","inReplyTo":"ec6qnp$aal$1@sea.gmane.org","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-08-19T18:33:03Z","receivedAt":"2006-08-19T18:33:03Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Sat, Aug 19, 2006 at 12:55:57PM +0200, Jakub Narebski wrote:\n> > Perhaps introduce a new function which is used to access the parameters?\n> > This new function could check the URL or CGI->param or whatever and then\n> > return the requested value.\n> \n> CGI->param. There is no reason to duplicate CGI module.\n\nyes there is.\nusing CGI->param it is not possible to use nice URLs ala\nhttp://git.site.org/projectpath.git\n\nI would really appreciate to be able to use nice URLs in gitweb that\ncorrespond to the repository URL.\n\n-- \nMartin Waitz\n"},{"id":"25628","messageId":"ec80nk$i25$1@sea.gmane.org","threadId":"5299","inReplyTo":"20060819183303.GC30022@admingilde.org","subject":"Re: [PATCH] gitweb: use common parameter parsing and generation for \"o\", too.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-19T21:44:27Z","receivedAt":"2006-08-19T21:44:27Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Martin Waitz wrote:\n\n> hoi :)\n> \n> On Sat, Aug 19, 2006 at 12:55:57PM +0200, Jakub Narebski wrote:\n>>> Perhaps introduce a new function which is used to access the parameters?\n>>> This new function could check the URL or CGI->param or whatever and then\n>>> return the requested value.\n>> \n>> CGI->param. There is no reason to duplicate CGI module.\n> \n> yes there is.\n> using CGI->param it is not possible to use nice URLs ala\n> http://git.site.org/projectpath.git\n> \n> I would really appreciate to be able to use nice URLs in gitweb that\n> correspond to the repository URL.\n\nAs far as I know it is now possible (of course if your web server is\nconfigured to redirect / to gitweb.cgi, e.g. for Apache using ScriptAlias\ndirective) via PATH_INFO support. At least it is what is intended.\n\nGitweb doesn't generate links in such a way, yet, but this should be fairly\neasy now, changing only href() subroutine.\n\nBut apart from this one parameter the rest have to be passed as CGI\nparameters,\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}