{"thread":{"id":"11303","subject":"[PATCH 0/3 (resend)] gitweb: Miscelanous fixes","startedAt":"2007-12-15T14:34:50Z","lastAt":"2007-12-18T00:49:32Z","messageCount":8,"participants":["Jakub Narebski","Petr Baudis","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"63247","messageId":"200712151534.50951.jnareb@gmail.com","threadId":"11303","inReplyTo":null,"subject":"[PATCH 0/3 (resend)] gitweb: Miscelanous fixes","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-12-15T14:34:50Z","receivedAt":"2007-12-15T14:34:50Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"There were a few gitweb patches which were send (and seemed to\nbe accepted) before 1.5.4-rc0 (and before feature freeze request),\nbut are not in 'master'; it is not even in 'offcuts' (what is this\nbranch for by the way?).\n\nAll those patches are simple bugfixes (well, perhaps exept last one,\nbut even it can be treated as bugfix). All passes the gitweb test:\nt9500-gitweb-standalone-no-errors (not that it says much).\n\nPatches are independent conceptually, and should be textually\nindependent. Apply to 'master'\n\nTable of contents:\n [PATCH] gitweb: Make config_to_multi return [] instead of [undef]\n [PATCH] gitweb: disambiguate heads and tags withs the same name\n [PATCH] gitweb: Teach \"a=blob\" action to be more lenient about\n         blob/file mime type\n\nDiffstat:\n gitweb/gitweb.perl                     |   38 ++++++++++++++++---------------\n t/t9500-gitweb-standalone-no-errors.sh |   25 +++++++++++++++++++++\n 2 files changed, 45 insertions(+), 18 deletions(-)\n\n\nP.S. I could not check if gitweb shows correct output as my Apache\nhas very mysteriously stopped working and refused to restart. It might\nhave been cause by an incident when runaway program filled whole disk\nspace with log, leaving no space on device... but it might not.\n\n# /etc/rc.d/init.d/httpd status\nhttpd is stopped\n# /etc/rc.d/init.d/httpd configtest \nSyntax OK\n# /etc/rc.d/init.d/httpd start     \nStarting httpd:                                            [FAILED]\n# cat /var/log/httpd/error_log\nConfiguration Failed\n$ rpm -q httpd\nhttpd-2.0.54-10.3\n\n-- \nJakub Narębski\nPoland\n"},{"id":"63249","messageId":"200712151536.33296.jnareb@gmail.com","threadId":"11303","inReplyTo":"200712151534.50951.jnareb@gmail.com","subject":"[PATCH] gitweb: Make config_to_multi return [] instead of [undef]","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-12-15T14:36:32Z","receivedAt":"2007-12-15T14:36:32Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"From: Petr Baudis <pasky@suse.cz>\nDate: Sat, 8 Dec 2007 12:30:59 +0100\nSubject: [PATCH] gitweb: Make config_to_multi return [] instead of [undef]\n\nThis is important for the list of clone urls, where if there are\nno per-repository clone URL configured, the default base URLs\nare never used for URL construction without this patch.\n\nAdd tests for different ways of setting project URLs, just in case.\nNote that those tests in current form wouldn't detect breakage fixed\nby this patch, as it only checks for errors and not for expected\noutput.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nOriginally by Petr Baudis, changed to use defined($val). I have also\nadded parentheses for better readibility.\n\nI have added tests _then_ I have realized that in current form they\ncannot detect regression corrected by this patch. So if you want, you\ncan not apply changes to test (and remove paragraph about test from\ncommit message).\n\nThe fact that patch was not applied might be cause by the lack of Ack\nfrom pasky.\n\n gitweb/gitweb.perl                     |    2 +-\n t/t9500-gitweb-standalone-no-errors.sh |   25 +++++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 24b3158..a746a85 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1511,7 +1511,7 @@ sub config_to_int {\n sub config_to_multi {\n        my $val = shift;\n \n-       return ref($val) ? $val : [ $val ];\n+       return ref($val) ? $val : (defined($val) ? [ $val ] : []);\n }\n \n sub git_get_project_config {\ndiff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh\nindex 35fff3d..2d3d4e8 100755\n--- a/t/t9500-gitweb-standalone-no-errors.sh\n+++ b/t/t9500-gitweb-standalone-no-errors.sh\n@@ -558,6 +558,31 @@ test_expect_success \\\n test_debug 'cat gitweb.log'\n \n # ----------------------------------------------------------------------\n+# testing config_to_multi / cloneurl\n+\n+test_expect_success \\\n+       'URL: no project URLs, no base URL' \\\n+       'gitweb_run \"p=.git;a=summary\"'\n+test_debug 'cat gitweb.log'\n+\n+test_expect_success \\\n+       'URL: project URLs via gitweb.url' \\\n+       'git config --add gitweb.url git://example.com/git/trash.git &&\n+        git config --add gitweb.url http://example.com/git/trash.git &&\n+        gitweb_run \"p=.git;a=summary\"'\n+test_debug 'cat gitweb.log'\n+\n+cat >.git/cloneurl <<\\EOF\n+git://example.com/git/trash.git\n+http://example.com/git/trash.git\n+EOF\n+\n+test_expect_success \\\n+       'URL: project URLs via cloneurl file' \\\n+       'gitweb_run \"p=.git;a=summary\"'\n+test_debug 'cat gitweb.log'\n+\n+# ----------------------------------------------------------------------\n # gitweb config and repo config\n \n cat >>gitweb_config.perl <<EOF\n-- \n1.5.3.7\n"},{"id":"63248","messageId":"200712151540.29187.jnareb@gmail.com","threadId":"11303","inReplyTo":"200712151534.50951.jnareb@gmail.com","subject":"[PATCH] gitweb: disambiguate heads and tags withs the same name","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-12-15T14:40:28Z","receivedAt":"2007-12-15T14:40:28Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Avoid wrong disambiguation that would link logs/trees of tags and\nheads which share the same name to the same page, leading to\na disambiguation that would prefer the tag, thus making it impossible\nto access the corresponding head log and tree without hacking the url\nby hand.\n\nIt does it by using full refname (with 'refs/heads/' or 'refs/tags/'\nprefix) instead of shortened one in the URLs in 'heads' and 'tags'\ntables.  This makes URLs (and refs) provided by gitweb unambiguous.\n\nSigned-off-by: Guillaume Seguin <guillaume@segu.in>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nBased on the patch by Guillaume Seguin, which solved the same problem\nin slightly different way, by re-adding 'refs/heads/' or 'refs/tags/'.\nI think this way is slightly better.\n\nNote that there is companion RFC patch (which is not a part of this\nmini-series) which added check if the refname is ambiguous in git_tag:\n  \"gitweb: Try harder in parse_tag; perhaps it was given ambiguous name\"\n\n gitweb/gitweb.perl |   14 ++++++++------\n 1 files changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a746a85..448dca7 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2233,6 +2233,7 @@ sub git_get_heads_list {\n \t\tmy ($hash, $name, $title) = split(' ', $refinfo, 3);\n \t\tmy ($committer, $epoch, $tz) =\n \t\t\t($committerinfo =~ /^(.*) ([0-9]+) (.*)$/);\n+\t\t$ref_item{'fullname'}  = $name;\n \t\t$name =~ s!^refs/heads/!!;\n \n \t\t$ref_item{'name'}  = $name;\n@@ -2270,6 +2271,7 @@ sub git_get_tags_list {\n \t\tmy ($id, $type, $name, $refid, $reftype, $title) = split(' ', $refinfo, 6);\n \t\tmy ($creator, $epoch, $tz) =\n \t\t\t($creatorinfo =~ /^(.*) ([0-9]+) (.*)$/);\n+\t\t$ref_item{'fullname'} = $name;\n \t\t$name =~ s!^refs/tags/!!;\n \n \t\t$ref_item{'type'} = $type;\n@@ -3690,8 +3692,8 @@ sub git_tags_body {\n \t\t      \"<td class=\\\"link\\\">\" . \" | \" .\n \t\t      $cgi->a({-href => href(action=>$tag{'reftype'}, hash=>$tag{'refid'})}, $tag{'reftype'});\n \t\tif ($tag{'reftype'} eq \"commit\") {\n-\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'name'})}, \"shortlog\") .\n-\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"log\", hash=>$tag{'name'})}, \"log\");\n+\t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"shortlog\", hash=>$tag{'fullname'})}, \"shortlog\") .\n+\t\t\t      \" | \" . $cgi->a({-href => href(action=>\"log\", hash=>$tag{'fullname'})}, \"log\");\n \t\t} elsif ($tag{'reftype'} eq \"blob\") {\n \t\t\tprint \" | \" . $cgi->a({-href => href(action=>\"blob_plain\", hash=>$tag{'refid'})}, \"raw\");\n \t\t}\n@@ -3726,13 +3728,13 @@ sub git_heads_body {\n \t\t$alternate ^= 1;\n \t\tprint \"<td><i>$ref{'age'}</i></td>\\n\" .\n \t\t      ($curr ? \"<td class=\\\"current_head\\\">\" : \"<td>\") .\n-\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$ref{'name'}),\n+\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$ref{'fullname'}),\n \t\t               -class => \"list name\"},esc_html($ref{'name'})) .\n \t\t      \"</td>\\n\" .\n \t\t      \"<td class=\\\"link\\\">\" .\n-\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$ref{'name'})}, \"shortlog\") . \" | \" .\n-\t\t      $cgi->a({-href => href(action=>\"log\", hash=>$ref{'name'})}, \"log\") . \" | \" .\n-\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$ref{'name'}, hash_base=>$ref{'name'})}, \"tree\") .\n+\t\t      $cgi->a({-href => href(action=>\"shortlog\", hash=>$ref{'fullname'})}, \"shortlog\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"log\", hash=>$ref{'fullname'})}, \"log\") . \" | \" .\n+\t\t      $cgi->a({-href => href(action=>\"tree\", hash=>$ref{'fullname'}, hash_base=>$ref{'name'})}, \"tree\") .\n \t\t      \"</td>\\n\" .\n \t\t      \"</tr>\";\n \t}\n-- \n1.5.3.7\n"},{"id":"63250","messageId":"200712151541.50404.jnareb@gmail.com","threadId":"11303","inReplyTo":"200712151534.50951.jnareb@gmail.com","subject":"[PATCH] gitweb: Teach \"a=blob\" action to be more lenient about blob/file mime type","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-12-15T14:41:49Z","receivedAt":"2007-12-15T14:41:49Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Since 930cf7dd7cc6b87d173f182230763e1f1913d319 'blob' action knows the\nfile type; if the file type is not \"text/*\" or one of common network\nimage formats/mimetypes (gif, png, jpeg) then the action \"blob\"\ndefaulted to \"blob_plain\".  This caused the problem if mimetypes file\nwas not well suited for web, for example returning \"application/x-sh\"\nfor \"*.sh\" shell scripts, instead of \"text/plain\" (or other \"text/*\").\n\nNow \"blob\" action defaults to \"blob_plain\" ('raw' view) only if file\nis of type which is neither \"text/*\" nor \"image/{gif,png,jpeg}\"\nAND it is binary file.  Otherwise it assumes that it can be displayed\neither in <img> tag (\"image/*\" mimetype), or can be displayed line by\nline (otherwise).\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nOriginal version of the patch has a simple bug.\n\n gitweb/gitweb.perl |   22 +++++++++++-----------\n 1 files changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 448dca7..6256641 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4290,7 +4290,7 @@ sub git_blob {\n \topen my $fd, \"-|\", git_cmd(), \"cat-file\", \"blob\", $hash\n \t\tor die_error(undef, \"Couldn't cat $file_name, $hash\");\n \tmy $mimetype = blob_mimetype($fd, $file_name);\n-\tif ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)!) {\n+\tif ($mimetype !~ m!^(?:text/|image/(?:gif|png|jpeg)$)! && -B $fd) {\n \t\tclose $fd;\n \t\treturn git_blob_plain($mimetype);\n \t}\n@@ -4331,16 +4331,7 @@ sub git_blob {\n \t}\n \tgit_print_page_path($file_name, \"blob\", $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n-\tif ($mimetype =~ m!^text/!) {\n-\t\tmy $nr;\n-\t\twhile (my $line = <$fd>) {\n-\t\t\tchomp $line;\n-\t\t\t$nr++;\n-\t\t\t$line = untabify($line);\n-\t\t\tprintf \"<div class=\\\"pre\\\"><a id=\\\"l%i\\\" href=\\\"#l%i\\\" class=\\\"linenr\\\">%4i</a> %s</div>\\n\",\n-\t\t\t       $nr, $nr, $nr, esc_html($line, -nbsp=>1);\n-\t\t}\n-\t} elsif ($mimetype =~ m!^image/!) {\n+\tif ($mimetype =~ m!^image/!) {\n \t\tprint qq!<img type=\"$mimetype\"!;\n \t\tif ($file_name) {\n \t\t\tprint qq! alt=\"$file_name\" title=\"$file_name\"!;\n@@ -4349,6 +4340,15 @@ sub git_blob {\n \t\t      href(action=>\"blob_plain\", hash=>$hash,\n \t\t           hash_base=>$hash_base, file_name=>$file_name) .\n \t\t      qq!\" />\\n!;\n+\t} else {\n+\t\tmy $nr;\n+\t\twhile (my $line = <$fd>) {\n+\t\t\tchomp $line;\n+\t\t\t$nr++;\n+\t\t\t$line = untabify($line);\n+\t\t\tprintf \"<div class=\\\"pre\\\"><a id=\\\"l%i\\\" href=\\\"#l%i\\\" class=\\\"linenr\\\">%4i</a> %s</div>\\n\",\n+\t\t\t       $nr, $nr, $nr, esc_html($line, -nbsp=>1);\n+\t\t}\n \t}\n \tclose $fd\n \t\tor print \"Reading blob failed.\\n\";\n-- \n1.5.3.7\n"},{"id":"63252","messageId":"20071215150501.GM10769@machine.or.cz","threadId":"11303","inReplyTo":"200712151536.33296.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: Make config_to_multi return [] instead of [undef]","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-12-15T15:05:01Z","receivedAt":"2007-12-15T15:05:01Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Sat, Dec 15, 2007 at 03:36:32PM +0100, Jakub Narebski wrote:\n> From: Petr Baudis <pasky@suse.cz>\n> Date: Sat, 8 Dec 2007 12:30:59 +0100\n> Subject: [PATCH] gitweb: Make config_to_multi return [] instead of [undef]\n> \n> This is important for the list of clone urls, where if there are\n> no per-repository clone URL configured, the default base URLs\n> are never used for URL construction without this patch.\n> \n> Add tests for different ways of setting project URLs, just in case.\n> Note that those tests in current form wouldn't detect breakage fixed\n> by this patch, as it only checks for errors and not for expected\n> output.\n> \n> Signed-off-by: Petr Baudis <pasky@suse.cz>\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n\nAcked-by: Petr Baudis <pasky@suse.cz>\n\nThank you all for catching the defined($val). :-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nWe don't know who it was that discovered water, but we're pretty sure\nthat it wasn't a fish.\t\t-- Marshall McLuhan\n"},{"id":"63266","messageId":"7vlk7vn4x2.fsf@gitster.siamese.dyndns.org","threadId":"11303","inReplyTo":"200712151534.50951.jnareb@gmail.com","subject":"Re: [PATCH 0/3 (resend)] gitweb: Miscelanous fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-15T19:17:45Z","receivedAt":"2007-12-15T19:17:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks for a reminder.  Will look at it but I'll be offline for several\nhours today.\n"},{"id":"63529","messageId":"200712180112.52094.jnareb@gmail.com","threadId":"11303","inReplyTo":"200712151536.33296.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: Make config_to_multi return [] instead of [undef]","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-12-18T00:12:51Z","receivedAt":"2007-12-18T00:12:51Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sat, 15 Dec 2007, Jakub Narebski wrote:\n\n> This is important for the list of clone urls, where if there are\n> no per-repository clone URL configured, the default base URLs\n> are never used for URL construction without this patch.\n> \n> Add tests for different ways of setting project URLs, just in case.\n> Note that those tests in current form wouldn't detect breakage fixed\n> by this patch, as it only checks for errors and not for expected\n> output.\n\nThe patch applied to master bc8b95ae4a4b21753e84bbfd28cbcbf1b3f6e0a8\ndoes have above paragraph in commit message, but DOES NOT have the\ntests itself.\n \n> I have added tests _then_ I have realized that in current form they\n> cannot detect regression corrected by this patch. So if you want, you\n> can not apply changes to test (and remove paragraph about test from\n> commit message).\n\nSee above...\n\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 24b3158..a746a85 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -1511,7 +1511,7 @@ sub config_to_int {\n>  sub config_to_multi {\n>         my $val = shift;\n>  \n> -       return ref($val) ? $val : [ $val ];\n> +       return ref($val) ? $val : (defined($val) ? [ $val ] : []);\n>  }\n\nAnd somehow (I don't know how[*1*]) patch got whitespace corrupted,\nand now the line is indented with spaces, instead of with tab.\n\n[*1*] Other patches are fine.\n-- \nJakub Narebski\nPoland\n"},{"id":"63536","messageId":"7v7ijc4yjn.fsf@gitster.siamese.dyndns.org","threadId":"11303","inReplyTo":"200712180112.52094.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: Make config_to_multi return [] instead of [undef]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-18T00:49:32Z","receivedAt":"2007-12-18T00:49:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Please send updates if something is not right.  Thanks.\n"}]}