{"thread":{"id":"23416","subject":"[PATCH] More flexible URL patterns for gitweb","startedAt":"2010-04-11T00:40:29Z","lastAt":"2010-04-11T21:09:35Z","messageCount":4,"participants":["Damien Tournoud","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"139220","messageId":"1270946429-5366-1-git-send-email-damien@tournoud.net","threadId":"23416","inReplyTo":null,"subject":"[PATCH] More flexible URL patterns for gitweb","fromName":"Damien Tournoud","fromEmail":"damien@tournoud.net","sentAt":"2010-04-11T00:40:29Z","receivedAt":"2010-04-11T00:40:29Z","isPatch":true,"sender":{"key":"damien@tournoud.net","avatar":null},"body":"@git_base_url_list hardcodes URLs in the form \"$git_base_url/$project\",\nwhich makes impossible to generate proper URLs for SSH access scenarios.\n\nThis patch implements a more flexible replacement scheme, using a\nsimple placeholder for the project path, and fixes the associated\ndocumentation.\n\nSigned-off-by: Damien Tournoud <damien@tournoud.net>\n---\n gitweb/README      |   13 ++++++-------\n gitweb/gitweb.perl |    2 +-\n 2 files changed, 7 insertions(+), 8 deletions(-)\n\ndiff --git a/gitweb/README b/gitweb/README\nindex ad6a04c..f16729c 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -197,13 +197,12 @@ not include variables usually directly set during build):\n    full description is available as 'title' attribute (usually shown on\n    mouseover).  By default set to 25, which might be too small if you\n    use long project descriptions.\n- * @git_base_url_list\n-   List of git base URLs used for URL to where fetch project from, shown\n-   in project summary page.  Full URL is \"$git_base_url/$project\".\n-   You can setup multiple base URLs (for example one for  git:// protocol\n-   access, and one for http:// \"dumb\" protocol access).  Note that per\n-   repository configuration in 'cloneurl' file, or as values of gitweb.url\n-   project config.\n+ * @git_base_url_patterns\n+   List of git base URLs patterns used to build the URLs displayed in the\n+   project summary page. Examples include \"git://git.example.com/%project\",\n+   \"http://git.example.com/%project\" and \"git@git.example.com:%project\".\n+   Note that per repository configuration in a 'cloneurl' file, or configuration\n+   values of gitweb.url in the project config take precedence over this.\n  * $default_blob_plain_mimetype\n    Default mimetype for blob_plain (raw) view, if mimetype checking\n    doesn't result in some other type; by default 'text/plain'.\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex c356e95..0fc5957 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4904,7 +4904,7 @@ sub git_summary {\n \t# or make project git URL from git base URL and project name\n \tmy $url_tag = \"URL\";\n \tmy @url_list = git_get_project_url_list($project);\n-\t@url_list = map { \"$_/$project\" } @git_base_url_list unless @url_list;\n+\t@url_list = map { my $url = $_; $url =~ s/%project/$project/g; $url } @git_base_url_list unless @url_list;\n \tforeach my $git_url (@url_list) {\n \t\tnext unless $git_url;\n \t\tprint \"<tr class=\\\"metadata_url\\\"><td>$url_tag</td><td>$git_url</td></tr>\\n\";\n-- \n1.6.5.7\n"},{"id":"139265","messageId":"m37hodhp3e.fsf@localhost.localdomain","threadId":"23416","inReplyTo":"1270946429-5366-1-git-send-email-damien@tournoud.net","subject":"Re: [PATCH] More flexible URL patterns for gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-11T17:33:24Z","receivedAt":"2010-04-11T17:33:24Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Damien Tournoud <damien@tournoud.net> writes:\n\n> @git_base_url_list hardcodes URLs in the form \"$git_base_url/$project\",\n> which makes impossible to generate proper URLs for SSH access scenarios.\n\nAs I understand it, current way of creating project's URLs from\n@git_base_url_list and $project (and project name), via joining\nwith '/' as separator in the form of \"$git_base_url/$project\"\ndoes not work for a class of scp-like relative \"URLs\".  You can't\ncreate 'git@git.example.com:path/to/project' URL using current form\nof @git_base_url_list support.\n\nCurrent form of @git_base_url_list support works well both for\nabsolute scp-like URLs for SSH sccess, for example\n'git@git.example.com:/srv/git' + 'path/to/project', and also for\n\"ssh://\" URLs like 'ssh://git.example.com/srv/git' or \n'ssh://git@git.example.com/~' + 'path/to/project'.\n\n> \n> This patch implements a more flexible replacement scheme, using a\n> simple placeholder for the project path, and fixes the associated\n> documentation.\n\nNAK, at least in this form, for it breaks backwards compatibility.\nWe do not want to have upgrading gitweb break one's existing gitweb\nconfiguration.  But see below for proposed amendment of this patch.\n \n> Signed-off-by: Damien Tournoud <damien@tournoud.net>\n> ---\n>  gitweb/README      |   13 ++++++-------\n>  gitweb/gitweb.perl |    2 +-\n>  2 files changed, 7 insertions(+), 8 deletions(-)\n> \n> diff --git a/gitweb/README b/gitweb/README\n> index ad6a04c..f16729c 100644\n> --- a/gitweb/README\n> +++ b/gitweb/README\n> @@ -197,13 +197,12 @@ not include variables usually directly set during build):\n>     full description is available as 'title' attribute (usually shown on\n>     mouseover).  By default set to 25, which might be too small if you\n>     use long project descriptions.\n> - * @git_base_url_list\n> -   List of git base URLs used for URL to where fetch project from, shown\n> -   in project summary page.  Full URL is \"$git_base_url/$project\".\n> -   You can setup multiple base URLs (for example one for  git:// protocol\n> -   access, and one for http:// \"dumb\" protocol access).  Note that per\n> -   repository configuration in 'cloneurl' file, or as values of gitweb.url\n> -   project config.\n> + * @git_base_url_patterns\n> +   List of git base URLs patterns used to build the URLs displayed in the\n> +   project summary page. Examples include \"git://git.example.com/%project\",\n> +   \"http://git.example.com/%project\" and \"git@git.example.com:%project\".\n> +   Note that per repository configuration in a 'cloneurl' file, or configuration\n> +   values of gitweb.url in the project config take precedence over this.\n\nHere it looks like you would be using @git_base_url_patterns for the\nnew mechanism, while below one can see that you re-use @git_base_url_list...\nand break backwards compatibility with existing gitweb configuration using\n@git_base_url_list.\n\nAlso, you use %project as placeholder... while %project is valid path part\nof URLs (although unlikely one).\n\n>   * $default_blob_plain_mimetype\n>     Default mimetype for blob_plain (raw) view, if mimetype checking\n>     doesn't result in some other type; by default 'text/plain'.\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index c356e95..0fc5957 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -4904,7 +4904,7 @@ sub git_summary {\n>  \t# or make project git URL from git base URL and project name\n>  \tmy $url_tag = \"URL\";\n>  \tmy @url_list = git_get_project_url_list($project);\n> -\t@url_list = map { \"$_/$project\" } @git_base_url_list unless @url_list;\n> +\t@url_list = map { my $url = $_; $url =~ s/%project/$project/g; $url } @git_base_url_list unless @url_list;\n>  \tforeach my $git_url (@url_list) {\n>  \t\tnext unless $git_url;\n>  \t\tprint \"<tr class=\\\"metadata_url\\\"><td>$url_tag</td><td>$git_url</td></tr>\\n\";\n\nTo not break backward compatibility, wouldn't it be better to check if\nelements of @git_base_url_list end with ':' or '/', and join base with\nproject path depending on this condition, i.e.:\n\n+\t@url_list = map { m/[/:]$/ ? \"$_$project\" : \"$_/$project\" } @git_base_url_list\n+               unless @url_list;\n\nThis means: if base ends with colon ':' or slash '/', concatenate base\nand project path, otherwise join them using '/' as field separator.\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"139269","messageId":"r2te821df551004111046v2ef3219x5c012af27f2cc974@mail.gmail.com","threadId":"23416","inReplyTo":"m37hodhp3e.fsf@localhost.localdomain","subject":"Re: [PATCH] More flexible URL patterns for gitweb","fromName":"Damien Tournoud","fromEmail":"damien@tournoud.net","sentAt":"2010-04-11T17:46:06Z","receivedAt":"2010-04-11T17:46:06Z","isPatch":true,"sender":{"key":"damien@tournoud.net","avatar":null},"body":"On Sun, Apr 11, 2010 at 7:33 PM, Jakub Narebski <jnareb@gmail.com> wrote:\n> To not break backward compatibility, wouldn't it be better to check if\n> elements of @git_base_url_list end with ':' or '/', and join base with\n> project path depending on this condition, i.e.:\n>\n> +       @url_list = map { m/[/:]$/ ? \"$_$project\" : \"$_/$project\" } @git_base_url_list\n> +               unless @url_list;\n>\n> This means: if base ends with colon ':' or slash '/', concatenate base\n> and project path, otherwise join them using '/' as field separator.\n\nThanks for the review. Indeed this way sounds better.\n\nAll this is new to me so I'm not sure what is the way forward. Should\nI publish another patch or would you?\n\nDamien Tournoud\n"},{"id":"139288","messageId":"201004112309.37089.jnareb@gmail.com","threadId":"23416","inReplyTo":"r2te821df551004111046v2ef3219x5c012af27f2cc974@mail.gmail.com","subject":"Re: [PATCH] More flexible URL patterns for gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-11T21:09:35Z","receivedAt":"2010-04-11T21:09:35Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Sun, 11 Apr 2010, Damien Tournoud wrote:\n> On Sun, Apr 11, 2010 at 7:33 PM, Jakub Narebski <jnareb@gmail.com> wrote:\n\n> > To not break backward compatibility, wouldn't it be better to check if\n> > elements of @git_base_url_list end with ':' or '/', and join base with\n> > project path depending on this condition, i.e.:\n> >\n> > +       @url_list = map { m/[/:]$/ ? \"$_$project\" : \"$_/$project\" } @git_base_url_list\n> > +               unless @url_list;\n> >\n> > This means: if base ends with colon ':' or slash '/', concatenate base\n> > and project path, otherwise join them using '/' as field separator.\n> \n> Thanks for the review. Indeed this way sounds better.\n> \n> All this is new to me so I'm not sure what is the way forward. Should\n> I publish another patch or would you?\n\nIf you don't mind, I'd rather you send updated patch (perhaps as response\nto this email, or staring a separate thread).\n\nNote that you would need to:\n1. Perhaps update first line of commit message, i.e. email subject.\n   But current version might be good enough; if you don't change the\n   subject you should use [PATCH v2] rather than [PATCH] in it.\n\n2. Update commit message, to say that you are modifying the way project\n   URLs shown in gitweb are composed out of bases in @git_base_url_list\n   and $project, to allow possibility of generating scp-like relative\n   URL for SSH access, e.g. 'git@git.example.com:user/repo.git'\n\n3. You might want to put comment about what changed from previous\n   version of the patch between \"---\\n\" and diffstat.\n\n4. You would need to update description of @git_base_url_list in\n   gitweb/README, e.g. providing example what to put in @git_base_url_list\n   to get 'git@git.example.com:user/repo.git': it is 'git@git.example.com:'\n\n5. Update comment in gitweb.perl above declaration of @git_base_url_list\n   to follow modified way of getting URL from base and $project\n\n6. Make above change in git_summary.\n\n\nP.S. Thank you for contributing to git.\n-- \nJakub Narebski\nPoland\n"}]}