{"thread":{"id":"8060","subject":"[PATCH] gitweb: choose appropriate view for file type if a= parameter missing.","startedAt":"2007-05-09T22:19:28Z","lastAt":"2007-05-13T00:32:36Z","messageCount":5,"participants":["Gerrit Pape","Junio C Hamano","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"41675","messageId":"20070509221928.17244.qmail@f9729cdcdf57d1.315fe32.mid.smarden.org","threadId":"8060","inReplyTo":null,"subject":"[PATCH] gitweb: choose appropriate view for file type if a= parameter missing.","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-05-09T22:19:28Z","receivedAt":"2007-05-09T22:19:28Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"See http://bugs.debian.org/410465\n\ngitweb URLs use the a= parameter for the view to use on the given path, such\nas \"blob\" or \"tree\".  Currently, if a gitweb URL omits the a= parameter,\ngitweb just shows the top-level repository summary, regardless of the path\ngiven.  gitweb could instead choose an appropriate view based on the file\ntype: blob for blobs (files), tree for trees (directories), and summary if no\npath given (the URL included no f= parameter, or an empty f= parameter).\n\nApart from making gitweb more robust and supporting URL editing more easily,\nthis change would aid the creation of shortcuts to git repositories using\nsimple substitution, such as:\nhttp://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s\n\n- Josh Triplett\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n gitweb/gitweb.perl |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 90243fd..21864c6 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -458,10 +458,16 @@ my %actions = (\n \t\"project_index\" => \\&git_project_index,\n );\n \n-if (defined $project) {\n-\t$action ||= 'summary';\n-} else {\n-\t$action ||= 'project_list';\n+if (!defined $action) {\n+\tif (defined $hash) {\n+\t\t$action = git_get_type($hash);\n+\t} elsif (defined $hash_base && defined $file_name) {\n+\t\t$action = git_get_type(\"$hash_base:$file_name\");\n+\t} elsif (defined $project) {\n+\t\t$action = 'summary';\n+\t} else {\n+\t\t$action = 'project_list';\n+\t}\n }\n if (!defined($actions{$action})) {\n \tdie_error(undef, \"Unknown action\");\n-- \n1.5.1.3\n"},{"id":"41696","messageId":"7vvef1o2ni.fsf@assigned-by-dhcp.cox.net","threadId":"8060","inReplyTo":"20070509221928.17244.qmail@f9729cdcdf57d1.315fe32.mid.smarden.org","subject":"Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-10T02:04:01Z","receivedAt":"2007-05-10T02:04:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Gerrit Pape <pape@smarden.org> writes:\n\n> See http://bugs.debian.org/410465\n>\n> gitweb URLs use the a= parameter for the view to use on the given path, such\n> as \"blob\" or \"tree\".  Currently, if a gitweb URL omits the a= parameter,\n> gitweb just shows the top-level repository summary, regardless of the path\n> given.  gitweb could instead choose an appropriate view based on the file\n> type: blob for blobs (files), tree for trees (directories), and summary if no\n> path given (the URL included no f= parameter, or an empty f= parameter).\n>\n> Apart from making gitweb more robust and supporting URL editing more easily,\n> this change would aid the creation of shortcuts to git repositories using\n> simple substitution, such as:\n> http://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s\n>\n> - Josh Triplett\n>\n> Signed-off-by: Gerrit Pape <pape@smarden.org>\n\nI am not sure if this is a \"good\" feature or just \"because we\ncan\" feature, but I am slightly in favor.  I do not know about\nothers.\n\nI'd however request a few changes to the proposed commit log\nmessage:\n\n * \"See http://...\" is not the primary information, but \"see\n   ... for further details\"; please have it at the end, not at\n   the beginning.\n\n * Was the patch authored by you, or Josh?  If the former,\n   what's his name doing here?  Perhaps you wanted to say\n   \"Reported by Josh Triplett\"?\n"},{"id":"41710","messageId":"20070510073207.21562.qmail@25d0c789693af2.315fe32.mid.smarden.org","threadId":"8060","inReplyTo":"7vvef1o2ni.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] gitweb: choose appropriate view for file type if a= parameter missing","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-05-10T07:32:07Z","receivedAt":"2007-05-10T07:32:07Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"gitweb URLs use the a= parameter for the view to use on the given path, such\nas \"blob\" or \"tree\".  Currently, if a gitweb URL omits the a= parameter,\ngitweb just shows the top-level repository summary, regardless of the path\ngiven.  gitweb could instead choose an appropriate view based on the file\ntype: blob for blobs (files), tree for trees (directories), and summary if\nno path given (the URL included no f= parameter, or an empty f= parameter).\n\nApart from making gitweb more robust and supporting URL editing more easily,\nthis change would aid the creation of shortcuts to git repositories using\nsimple substitution, such as:\nhttp://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s\n\nWith this patch, if given the hash through the h= parameter, or the hash\nbase (hb=) and a filename (f=), gitweb uses cat-file -t to automatically set\nthe a= parameter.\n\nThis feature was requested by Josh Triplett through\n http://bugs.debian.org/410465\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n\nOn Wed, May 09, 2007 at 07:04:01PM -0700, Junio C Hamano wrote:\n> I'd however request a few changes to the proposed commit log\n> message:\n>\n>  * \"See http://...\" is not the primary information, but \"see\n>    ... for further details\"; please have it at the end, not at\n>    the beginning.\n\nOkay.\n\n>  * Was the patch authored by you, or Josh?  If the former,\n>    what's his name doing here?  Perhaps you wanted to say\n>    \"Reported by Josh Triplett\"?\n\nSometimes I'm lazy, it was just a copy&paste from the Debian bug report\nsubmitted by Josh.\n\nRegards, Gerrit.\n\n gitweb/gitweb.perl |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 90243fd..21864c6 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -458,10 +458,16 @@ my %actions = (\n \t\"project_index\" => \\&git_project_index,\n );\n \n-if (defined $project) {\n-\t$action ||= 'summary';\n-} else {\n-\t$action ||= 'project_list';\n+if (!defined $action) {\n+\tif (defined $hash) {\n+\t\t$action = git_get_type($hash);\n+\t} elsif (defined $hash_base && defined $file_name) {\n+\t\t$action = git_get_type(\"$hash_base:$file_name\");\n+\t} elsif (defined $project) {\n+\t\t$action = 'summary';\n+\t} else {\n+\t\t$action = 'project_list';\n+\t}\n }\n if (!defined($actions{$action})) {\n \tdie_error(undef, \"Unknown action\");\n-- \n1.5.1.3\n"},{"id":"41712","messageId":"7vvef1kttk.fsf@assigned-by-dhcp.cox.net","threadId":"8060","inReplyTo":"20070510073207.21562.qmail@25d0c789693af2.315fe32.mid.smarden.org","subject":"Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-10T07:43:03Z","receivedAt":"2007-05-10T07:43:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"},{"id":"41991","messageId":"f25m2b$1b1$1@sea.gmane.org","threadId":"8060","inReplyTo":"20070510073207.21562.qmail@25d0c789693af2.315fe32.mid.smarden.org","subject":"Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-05-13T00:32:36Z","receivedAt":"2007-05-13T00:32:36Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"<opublikowany i wysłany>\n\n[Cc: Gerrit Pape <pape@smarden.org>, Junio C Hamano <junkio@cox.net>,\n git@vger.kernel.org]\n\nGerrit Pape wrote:\n\n> this change would aid the creation of shortcuts to git repositories using\n> simple substitution, such as:\n> http://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s\n> \n> With this patch, if given the hash through the h= parameter, or the hash\n> base (hb=) and a filename (f=), gitweb uses cat-file -t to automatically set\n> the a= parameter.\n\n> -if (defined $project) {\n> -     $action ||= 'summary';\n> -} else {\n> -     $action ||= 'project_list';\n> +if (!defined $action) {\n> +     if (defined $hash) {\n> +             $action = git_get_type($hash);\n> +     } elsif (defined $hash_base && defined $file_name) {\n> +             $action = git_get_type(\"$hash_base:$file_name\");\n> +     } elsif (defined $project) {\n> +             $action = 'summary';\n> +     } else {\n> +             $action = 'project_list';\n> +     }\n\nNOTE:\n\nWe have something similar for the only committag we support, namely\nthe shortened sha1 of object, which leads to an \"object\", which chooses\nappropriate view using git_get_type / git-cat-file -t.\n\nBut contrary to the above solution it does it by creating a _redirect_\nto a proper view, instead of silently selecting proper view like in\na patch above. Creating a redirect allows price for invoking \ngit-cat-file -t to be paid only once. User would bookmark correct view.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}