{"thread":{"id":"42891","subject":"Complex gitweb URL","startedAt":"2016-07-20T19:31:34Z","lastAt":"2016-07-25T16:34:45Z","messageCount":7,"participants":["CLOSE Dave","Jakub Narębski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"291852","messageId":"225e6ff4-178c-cd2a-6a05-b621f0ad4a84@us.thalesgroup.com","threadId":"42891","inReplyTo":null,"subject":"Complex gitweb URL","fromName":"CLOSE Dave","fromEmail":"dave.close@us.thalesgroup.com","sentAt":"2016-07-20T19:24:52Z","receivedAt":"2016-07-20T19:31:34Z","isPatch":false,"sender":{"key":"dave.close@us.thalesgroup.com","avatar":null},"body":"I'm trying to create a URL that will always refer to the latest version \nof a file stored under Gerrit. gitweb access is available. The man page \nspecification doesn't seem to work for me. Instead, I seem to need to \nput most of the information into arguments (after the '?').\n\nFor example, the repo name includes several directories, so it doesn't \nwork to put it into the \n\".../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>\" format. \nOr, at least, I don't see how.\n\nInstead I'm trying to use a URL in the format, \n\"http://site/gitweb/?args\". If I use gitweb itself to navigate to my \ntarget file, I see a URL in this format that contains several arguments, \n\"p=repo;a=blob;f=file;h=SHA;hb=SHA\". If I use that URL directly, I get \nmy file. But those SHA values are not something I know how to determine \nin advance. And I suspect they are unique to the specific version of the \nfile accessed, not always the latest as I want.\n\nIf I replace the hb=SHA argument with hb=HEAD, the URL still works. But \nI have no idea what I can use to replace the h=SHA argument.\n\nA complication is that the target file is not in the master branch. \nSomehow I need to be able to specify the branch. I've tried putting it \nas the h= argument but that results in \"Reading blob failed\". If I leave \nout the h= argument entirely, gitweb responds, \"404 cannot find file\".\n\nAre these arguments documented somewhere? What is the recommended way to \nconstruct a URL like I need?\n-- \n\tDave Close"},{"id":"291872","messageId":"578FEB1E.5060302@gmail.com","threadId":"42891","inReplyTo":"225e6ff4-178c-cd2a-6a05-b621f0ad4a84@us.thalesgroup.com","subject":"Re: Complex gitweb URL","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-07-20T21:20:30Z","receivedAt":"2016-07-20T21:20:43Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 2016-07-20 o 21:24, CLOSE Dave pisze:\n> I'm trying to create a URL that will always refer to the latest version \n> of a file stored under Gerrit. gitweb access is available. The man page \n> specification doesn't seem to work for me. Instead, I seem to need to \n> put most of the information into arguments (after the '?').\n> \n> For example, the repo name includes several directories, so it doesn't \n> work to put it into the \n> \".../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>\" format. \n> Or, at least, I don't see how.\n\nThe fact that gitweb path_info-based URL uses <repo>/<action>... instead\nof <action>/<repo> is in my opinion a bit of an unfortunate design error,\nkept because of backward compatibility.\n\nThat said, gitweb can detect where the <repo> part ends and <action>\npart begins, even for hierarchical multi-part repository name. See e.g.\nhttp://repo.or.cz/git/zerocommit.git/tree/HEAD:/Documentation with\nrepository part being 'git/zerocommit.git' (a \"fork\" of git.git). So it\nshould work.\n\nThere are some cases however where the URL cannot be represented in\npath_info form, and some parameters must be put as query arguments,\ni.e. after '?'.\n\n> \n> Instead I'm trying to use a URL in the format, \n> \"http://site/gitweb/?args\". If I use gitweb itself to navigate to my \n> target file, I see a URL in this format that contains several arguments, \n> \"p=repo;a=blob;f=file;h=SHA;hb=SHA\". If I use that URL directly, I get \n> my file. But those SHA values are not something I know how to determine \n> in advance. And I suspect they are unique to the specific version of the \n> file accessed, not always the latest as I want.\n> \n> If I replace the hb=SHA argument with hb=HEAD, the URL still works. But \n> I have no idea what I can use to replace the h=SHA argument.\n\nYou can remove it.  'hb' (hash_base) and 'f' (filename) identify target\nfile in a repository unambiguously.\n\n> \n> A complication is that the target file is not in the master branch. \n> Somehow I need to be able to specify the branch. I've tried putting it \n> as the h= argument but that results in \"Reading blob failed\". If I leave \n> out the h= argument entirely, gitweb responds, \"404 cannot find file\".\n\nDid you forgot to set 'hb' parameter?  Is said file present in revision\ngiven by the 'hb' parameter?\n\nSee e.g. http://repo.or.cz/?p=git/zerocommit.git;a=tree;hb=master;f=t\n \n> Are these arguments documented somewhere? What is the recommended way to \n> construct a URL like I need?\n\nWell, they are not described in the documentation, but you can check\nthe code and its comments.\n\nBest,\n-- \nJakub Narębski\n\n"},{"id":"291874","messageId":"42f9c384-489d-3fce-2b27-8884e683a3d5@us.thalesgroup.com","threadId":"42891","inReplyTo":"578FEB1E.5060302@gmail.com","subject":"Re: Complex gitweb URL","fromName":"CLOSE Dave","fromEmail":"dave.close@us.thalesgroup.com","sentAt":"2016-07-20T21:35:51Z","receivedAt":"2016-07-20T21:36:23Z","isPatch":false,"sender":{"key":"dave.close@us.thalesgroup.com","avatar":null},"body":"Thanks, Jakub, for the quick response.\n\nOn 07/20/16 02:20 PM, Jakub Narębski wrote:\n\n>> If I replace the hb=SHA argument with hb=HEAD, the URL still works. But\n>> I have no idea what I can use to replace the h=SHA argument.\n>\n> You can remove it.  'hb' (hash_base) and 'f' (filename) identify target\n> file in a repository unambiguously.\n\nIf I do, leaving everything else present, I get \"404 cannot find file\".\n\n>> A complication is that the target file is not in the master branch.\n>> Somehow I need to be able to specify the branch. I've tried putting it\n>> as the h= argument but that results in \"Reading blob failed\". If I leave\n>> out the h= argument entirely, gitweb responds, \"404 cannot find file\".\n>\n> Did you forgot to set 'hb' parameter?  Is said file present in revision\n> given by the 'hb' parameter?\n\nThe file is present in both master and develop branches. If I include \nhb=HEAD and leave out h=, gitweb doesn't find either of them. Using \nhb=HEAD and h=develop or h=master results in \"Reading blob failed\".\n-- \n\tDave Close"},{"id":"291875","messageId":"6505ebe4-15ab-b0ae-10de-6918e1c885da@us.thalesgroup.com","threadId":"42891","inReplyTo":"578FEB1E.5060302@gmail.com","subject":"Re: Complex gitweb URL","fromName":"CLOSE Dave","fromEmail":"dave.close@us.thalesgroup.com","sentAt":"2016-07-20T21:46:42Z","receivedAt":"2016-07-20T21:46:57Z","isPatch":false,"sender":{"key":"dave.close@us.thalesgroup.com","avatar":null},"body":"On 07/20/16 02:20 PM, Jakub Narębski wrote:\n\n> See e.g. http://repo.or.cz/?p=git/zerocommit.git;a=tree;hb=master;f=t\n\nAh! You have the branch in the hb= parameter whereas I had HEAD in that \none. Since HEAD is the default, I suppose I don't really need it.\n\nIndeed, if I use a URL like \n\"http://site/gitweb/?p=repo;a=blob;f=file;hb=branch\", I get my file.\n\nThanks for the clue.\n-- \n\tDave Close"},{"id":"291882","messageId":"CANQwDwe4OvNx+3uOG6Qbzj1CKK+N-pvTyk_j2WxDs-R2LPv3YQ@mail.gmail.com","threadId":"42891","inReplyTo":"42f9c384-489d-3fce-2b27-8884e683a3d5@us.thalesgroup.com","subject":"Re: Complex gitweb URL","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-07-20T21:50:31Z","receivedAt":"2016-07-20T21:51:17Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On 20 July 2016 at 23:35, CLOSE Dave <Dave.Close@us.thalesgroup.com> wrote:\n> Thanks, Jakub, for the quick response.\n>\n> On 07/20/16 02:20 PM, Jakub Narębski wrote:\n>\n>>> If I replace the hb=SHA argument with hb=HEAD, the URL still works. But\n>>> I have no idea what I can use to replace the h=SHA argument.\n>>\n>> You can remove it.  'hb' (hash_base) and 'f' (filename) identify target\n>> file in a repository unambiguously.\n>\n> If I do, leaving everything else present, I get \"404 cannot find file\".\n\nWhich gitweb version are you using? For 'a=blob' (i.e. displaying\ncontents of the file), if 'h' (hash) parameter is not set, then gitweb\nfinds it by using `git ls-tree <hash_base> -- <filename>` in\ngit_get_hash_by_path() subroutine. No 'hb' is equivalent to 'hb=HEAD'\n\nWhat does `git ls-tree <hash_base> -- <filename>` results in your\nrepository?\n\n>>> A complication is that the target file is not in the master branch.\n>>> Somehow I need to be able to specify the branch. I've tried putting it\n>>> as the h= argument but that results in \"Reading blob failed\". If I leave\n>>> out the h= argument entirely, gitweb responds, \"404 cannot find file\".\n>>\n>> Did you forgot to set 'hb' parameter?  Is said file present in revision\n>> given by the 'hb' parameter?\n>\n> The file is present in both master and develop branches. If I include\n> hb=HEAD and leave out h=, gitweb doesn't find either of them.\n\nIt works for repo.or.cz (which uses gitweb as web interface). So we\nhave WORKSFORME situation. Now we need to find out what is\ndifferent in your case...\n\n>                                                                                            Using\n> hb=HEAD and h=develop or h=master results in \"Reading blob failed\".\n\n'h' must be hash of the blob as an abject (of its contents at given revision).\n\n-- \nJakub Narebski\n"},{"id":"292041","messageId":"5793ADAC.6030009@gmail.com","threadId":"42891","inReplyTo":"225e6ff4-178c-cd2a-6a05-b621f0ad4a84@us.thalesgroup.com","subject":"Re: Complex gitweb URL","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-07-23T17:47:24Z","receivedAt":"2016-07-23T17:47:42Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 2016-07-20 o 21:24, CLOSE Dave pisze:\n\n> I'm trying to create a URL that will always refer to the latest version \n> of a file stored under Gerrit. gitweb access is available. The man page \n> specification doesn't seem to work for me. Instead, I seem to need to \n> put most of the information into arguments (after the '?').\n[...]\n> \n> Are these arguments documented somewhere? What is the recommended way to \n> construct a URL like I need?\n\nActually it turns out that gitweb URLs are described in gitweb(1) manpage\nhttps://git.github.io/htmldocs/gitweb.html#_actions_and_urls in the\n\"Actions, and URLs\" section.\n\nWhat was missing was explanation of available query parameters (the URL\narguments after the '?').  Would the following patch help, or is it still\nmissing something (NOTE: not tested)?:\n\n----- >8 ------------------------------------------------------ >8 -----\nSubject: [PATCH] gitweb(1): Document query parameters\n\nThe gitweb manpage includes description of gitweb URL structure,\nbut it was limited to passing parameters in the path part of URL\n('path info'), and it didn't include explanation of query parameters.\n---\n Documentation/gitweb.txt | 37 +++++++++++++++++++++++++++++++++++++\n 1 file changed, 37 insertions(+)\n\ndiff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt\nindex 96156e5..301003f 100644\n--- a/Documentation/gitweb.txt\n+++ b/Documentation/gitweb.txt\n@@ -395,6 +395,43 @@ atom::\n \tGenerates an RSS (or Atom) feed of changes to repository.\n \n \n+Query parameters:\n+~~~~~~~~~~~~~~~~~\n+In some cases gitweb cannot pass a parameter in path part of URL, for\n+example if a filename contains double dots ('..') inside.  All parameters\n+that cannot be passed in that way are put as a query parameter, that is\n+after '?'.\n+\n+By default gitweb would generate links using query parameters, unless\n+the original URL was using path part, or gitweb was configured to use\n+pathinfo with the 'pathinfo' feature. All gitweb installations recognize\n+URL in either format, so you can use one that is better for you when\n+interacting with gitweb (handcrafting or editing URLs, or creating\n+a program interacting with gitweb installation).\n+\n+Here is the list of some of query parameters, together with their\n+long names (which should help remembering the short name of\n+each parameter):\n+\n+'a' (action)::\n+\tThe action that will be run.\n+\n+'p' (project)::\n+\tThe project repository that will be displayed.\n+\n+'h' (hash)::\n+\tThe object id of displayed object (commit, tag, tree, blob).\n+\tIn case of files 'hb' (hash_base) and 'f' (filename) might be\n+\tused instead.\n+\n+'hp' (hash_parent)::\n+'fp' (file_parent)::\n+'hpb' (hash_parent_base)::\n+      Those parameters define the second object for diff-like actions,\n+      the object gitweb is comparing againts.\n+\n+\n+\n WEBSERVER CONFIGURATION\n -----------------------\n This section explains how to configure some common webservers to run gitweb. In\n-- \n2.6.3\n\n\n\n"},{"id":"292102","messageId":"xmqqoa5l7k2q.fsf@gitster.mtv.corp.google.com","threadId":"42891","inReplyTo":"5793ADAC.6030009@gmail.com","subject":"Re: Complex gitweb URL","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-07-25T16:34:37Z","receivedAt":"2016-07-25T16:34:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narębski <jnareb@gmail.com> writes:\n\n> Subject: [PATCH] gitweb(1): Document query parameters\n>\n> The gitweb manpage includes description of gitweb URL structure,\n> but it was limited to passing parameters in the path part of URL\n> ('path info'), and it didn't include explanation of query parameters.\n> ---\n\nI think this weather-balloon patch adds the missing info at the most\nnatural place in the flow of the document.  An earlier part talks\nabout a GitWeb URL having <repo>, <action>, <revision>, <path> and\nfollowed by what is called <arguments> after a question mark '?',\nbut what <arguments> part means and how to formulate it are left\nunsaid.\n\nBy the way, the title of the section 'Actions, and URLs' needs to\nlose the comma, I would think.\n\n>  Documentation/gitweb.txt | 37 +++++++++++++++++++++++++++++++++++++\n>  1 file changed, 37 insertions(+)\n>\n> diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt\n> index 96156e5..301003f 100644\n> --- a/Documentation/gitweb.txt\n> +++ b/Documentation/gitweb.txt\n> @@ -395,6 +395,43 @@ atom::\n>  \tGenerates an RSS (or Atom) feed of changes to repository.\n>  \n>  \n> +Query parameters:\n> +~~~~~~~~~~~~~~~~~\n> +In some cases gitweb cannot pass a parameter in path part of URL, for\n> +example if a filename contains double dots ('..') inside.  All parameters\n> +that cannot be passed in that way are put as a query parameter, that is\n> +after '?'.\n\nUntil this point, the reader hasn't even been told about \"filename\"\nis one of the potential things that can be given to \"control the\nbehaviour of the action\", and is left wondering if she has a\nfilename that does not have double-dots, how it can be passed \"in\npath part of URL\" after reading the first sentence.  Then the second\nsentence adds more to the mystery by starting with \"All parameters\nthat cannot be passed\" \"in that way\": what are the possible things\nthat the users may want to pass?  what exactly is \"in that way\",\nwhich probably means \"encoded as part of the <path>\", but it is\nunclear how that encoding works (is it just to \"concatenate\"?).\n\nOr is \"filename in the revision\" the ONLY thing the above paragraph\ntalks about, and is the ONLY purpose of the \"<path> part\" to\nrepresent that \"filename in the revision\" in the URL?\n\n    .../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>\n\nThe above syntax (taken from the first paragraph of the section)\nsuggests that <path> cannot be used to hold filename with a colon,\ntoo.  Perhaps \"for example if a filename contains double-dots\" needs\nto become an exhaustive description somewhere, i.e. \"(see below for\nthe exact rules)\" added to that sentence?\n\n> +By default gitweb would generate links using query parameters, unless\n> +the original URL was using path part, or gitweb was configured to use\n> +pathinfo with the 'pathinfo' feature. All gitweb installations recognize\n> +URL in either format, so you can use one that is better for you when\n> +interacting with gitweb (handcrafting or editing URLs, or creating\n> +a program interacting with gitweb installation).\n> +\n> +Here is the list of some of query parameters, together with their\n> +long names (which should help remembering the short name of\n> +each parameter):\n> +\n> +'a' (action)::\n> +\tThe action that will be run.\n> +\n> +'p' (project)::\n> +\tThe project repository that will be displayed.\n> +\n> +'h' (hash)::\n> +\tThe object id of displayed object (commit, tag, tree, blob).\n> +\tIn case of files 'hb' (hash_base) and 'f' (filename) might be\n> +\tused instead.\n> +\n> +'hp' (hash_parent)::\n> +'fp' (file_parent)::\n> +'hpb' (hash_parent_base)::\n> +      Those parameters define the second object for diff-like actions,\n> +      the object gitweb is comparing againts.\n\nThere is no mention of \"filename\" or \"path\" here, which further\nconfuses a reader who was told in the first paragraph that these\nquery-parameters are used when <path> part cannot hold a certain\nfilename.  Also it is unclear if <revision> corresponds to 'h'ash\nin the above.\n\n> +\n> +\n> +\n>  WEBSERVER CONFIGURATION\n>  -----------------------\n>  This section explains how to configure some common webservers to run gitweb. In\n"}]}