git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Complex gitweb URL
@ 2016-07-20 19:24 CLOSE Dave
  2016-07-20 21:20 ` Jakub Narębski
  2016-07-23 17:47 ` Jakub Narębski
  0 siblings, 2 replies; 7+ messages in thread
From: CLOSE Dave @ 2016-07-20 19:24 UTC (permalink / raw
  To: git@vger.kernel.org

I'm trying to create a URL that will always refer to the latest version 
of a file stored under Gerrit. gitweb access is available. The man page 
specification doesn't seem to work for me. Instead, I seem to need to 
put most of the information into arguments (after the '?').

For example, the repo name includes several directories, so it doesn't 
work to put it into the 
".../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>" format. 
Or, at least, I don't see how.

Instead I'm trying to use a URL in the format, 
"http://site/gitweb/?args". If I use gitweb itself to navigate to my 
target file, I see a URL in this format that contains several arguments, 
"p=repo;a=blob;f=file;h=SHA;hb=SHA". If I use that URL directly, I get 
my file. But those SHA values are not something I know how to determine 
in advance. And I suspect they are unique to the specific version of the 
file accessed, not always the latest as I want.

If I replace the hb=SHA argument with hb=HEAD, the URL still works. But 
I have no idea what I can use to replace the h=SHA argument.

A complication is that the target file is not in the master branch. 
Somehow I need to be able to specify the branch. I've tried putting it 
as the h= argument but that results in "Reading blob failed". If I leave 
out the h= argument entirely, gitweb responds, "404 cannot find file".

Are these arguments documented somewhere? What is the recommended way to 
construct a URL like I need?
-- 
	Dave Close

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Complex gitweb URL
  2016-07-20 19:24 Complex gitweb URL CLOSE Dave
@ 2016-07-20 21:20 ` Jakub Narębski
  2016-07-20 21:35   ` CLOSE Dave
  2016-07-20 21:46   ` CLOSE Dave
  2016-07-23 17:47 ` Jakub Narębski
  1 sibling, 2 replies; 7+ messages in thread
From: Jakub Narębski @ 2016-07-20 21:20 UTC (permalink / raw
  To: CLOSE Dave, git@vger.kernel.org

W dniu 2016-07-20 o 21:24, CLOSE Dave pisze:
> I'm trying to create a URL that will always refer to the latest version 
> of a file stored under Gerrit. gitweb access is available. The man page 
> specification doesn't seem to work for me. Instead, I seem to need to 
> put most of the information into arguments (after the '?').
> 
> For example, the repo name includes several directories, so it doesn't 
> work to put it into the 
> ".../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>" format. 
> Or, at least, I don't see how.

The fact that gitweb path_info-based URL uses <repo>/<action>... instead
of <action>/<repo> is in my opinion a bit of an unfortunate design error,
kept because of backward compatibility.

That said, gitweb can detect where the <repo> part ends and <action>
part begins, even for hierarchical multi-part repository name. See e.g.
http://repo.or.cz/git/zerocommit.git/tree/HEAD:/Documentation with
repository part being 'git/zerocommit.git' (a "fork" of git.git). So it
should work.

There are some cases however where the URL cannot be represented in
path_info form, and some parameters must be put as query arguments,
i.e. after '?'.

> 
> Instead I'm trying to use a URL in the format, 
> "http://site/gitweb/?args". If I use gitweb itself to navigate to my 
> target file, I see a URL in this format that contains several arguments, 
> "p=repo;a=blob;f=file;h=SHA;hb=SHA". If I use that URL directly, I get 
> my file. But those SHA values are not something I know how to determine 
> in advance. And I suspect they are unique to the specific version of the 
> file accessed, not always the latest as I want.
> 
> If I replace the hb=SHA argument with hb=HEAD, the URL still works. But 
> I have no idea what I can use to replace the h=SHA argument.

You can remove it.  'hb' (hash_base) and 'f' (filename) identify target
file in a repository unambiguously.

> 
> A complication is that the target file is not in the master branch. 
> Somehow I need to be able to specify the branch. I've tried putting it 
> as the h= argument but that results in "Reading blob failed". If I leave 
> out the h= argument entirely, gitweb responds, "404 cannot find file".

Did you forgot to set 'hb' parameter?  Is said file present in revision
given by the 'hb' parameter?

See e.g. http://repo.or.cz/?p=git/zerocommit.git;a=tree;hb=master;f=t
 
> Are these arguments documented somewhere? What is the recommended way to 
> construct a URL like I need?

Well, they are not described in the documentation, but you can check
the code and its comments.

Best,
-- 
Jakub Narębski


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Complex gitweb URL
  2016-07-20 21:20 ` Jakub Narębski
@ 2016-07-20 21:35   ` CLOSE Dave
  2016-07-20 21:50     ` Jakub Narębski
  2016-07-20 21:46   ` CLOSE Dave
  1 sibling, 1 reply; 7+ messages in thread
From: CLOSE Dave @ 2016-07-20 21:35 UTC (permalink / raw
  To: git@vger.kernel.org; +Cc: Jakub Narębski

Thanks, Jakub, for the quick response.

On 07/20/16 02:20 PM, Jakub Narębski wrote:

>> If I replace the hb=SHA argument with hb=HEAD, the URL still works. But
>> I have no idea what I can use to replace the h=SHA argument.
>
> You can remove it.  'hb' (hash_base) and 'f' (filename) identify target
> file in a repository unambiguously.

If I do, leaving everything else present, I get "404 cannot find file".

>> A complication is that the target file is not in the master branch.
>> Somehow I need to be able to specify the branch. I've tried putting it
>> as the h= argument but that results in "Reading blob failed". If I leave
>> out the h= argument entirely, gitweb responds, "404 cannot find file".
>
> Did you forgot to set 'hb' parameter?  Is said file present in revision
> given by the 'hb' parameter?

The file is present in both master and develop branches. If I include 
hb=HEAD and leave out h=, gitweb doesn't find either of them. Using 
hb=HEAD and h=develop or h=master results in "Reading blob failed".
-- 
	Dave Close

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Complex gitweb URL
  2016-07-20 21:20 ` Jakub Narębski
  2016-07-20 21:35   ` CLOSE Dave
@ 2016-07-20 21:46   ` CLOSE Dave
  1 sibling, 0 replies; 7+ messages in thread
From: CLOSE Dave @ 2016-07-20 21:46 UTC (permalink / raw
  To: git@vger.kernel.org; +Cc: Jakub Narębski

On 07/20/16 02:20 PM, Jakub Narębski wrote:

> See e.g. http://repo.or.cz/?p=git/zerocommit.git;a=tree;hb=master;f=t

Ah! You have the branch in the hb= parameter whereas I had HEAD in that 
one. Since HEAD is the default, I suppose I don't really need it.

Indeed, if I use a URL like 
"http://site/gitweb/?p=repo;a=blob;f=file;hb=branch", I get my file.

Thanks for the clue.
-- 
	Dave Close

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Complex gitweb URL
  2016-07-20 21:35   ` CLOSE Dave
@ 2016-07-20 21:50     ` Jakub Narębski
  0 siblings, 0 replies; 7+ messages in thread
From: Jakub Narębski @ 2016-07-20 21:50 UTC (permalink / raw
  To: CLOSE Dave; +Cc: git@vger.kernel.org

On 20 July 2016 at 23:35, CLOSE Dave <Dave.Close@us.thalesgroup.com> wrote:
> Thanks, Jakub, for the quick response.
>
> On 07/20/16 02:20 PM, Jakub Narębski wrote:
>
>>> If I replace the hb=SHA argument with hb=HEAD, the URL still works. But
>>> I have no idea what I can use to replace the h=SHA argument.
>>
>> You can remove it.  'hb' (hash_base) and 'f' (filename) identify target
>> file in a repository unambiguously.
>
> If I do, leaving everything else present, I get "404 cannot find file".

Which gitweb version are you using? For 'a=blob' (i.e. displaying
contents of the file), if 'h' (hash) parameter is not set, then gitweb
finds it by using `git ls-tree <hash_base> -- <filename>` in
git_get_hash_by_path() subroutine. No 'hb' is equivalent to 'hb=HEAD'

What does `git ls-tree <hash_base> -- <filename>` results in your
repository?

>>> A complication is that the target file is not in the master branch.
>>> Somehow I need to be able to specify the branch. I've tried putting it
>>> as the h= argument but that results in "Reading blob failed". If I leave
>>> out the h= argument entirely, gitweb responds, "404 cannot find file".
>>
>> Did you forgot to set 'hb' parameter?  Is said file present in revision
>> given by the 'hb' parameter?
>
> The file is present in both master and develop branches. If I include
> hb=HEAD and leave out h=, gitweb doesn't find either of them.

It works for repo.or.cz (which uses gitweb as web interface). So we
have WORKSFORME situation. Now we need to find out what is
different in your case...

>                                                                                            Using
> hb=HEAD and h=develop or h=master results in "Reading blob failed".

'h' must be hash of the blob as an abject (of its contents at given revision).

-- 
Jakub Narebski

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Complex gitweb URL
  2016-07-20 19:24 Complex gitweb URL CLOSE Dave
  2016-07-20 21:20 ` Jakub Narębski
@ 2016-07-23 17:47 ` Jakub Narębski
  2016-07-25 16:34   ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Narębski @ 2016-07-23 17:47 UTC (permalink / raw
  To: CLOSE Dave, git@vger.kernel.org

W dniu 2016-07-20 o 21:24, CLOSE Dave pisze:

> I'm trying to create a URL that will always refer to the latest version 
> of a file stored under Gerrit. gitweb access is available. The man page 
> specification doesn't seem to work for me. Instead, I seem to need to 
> put most of the information into arguments (after the '?').
[...]
> 
> Are these arguments documented somewhere? What is the recommended way to 
> construct a URL like I need?

Actually it turns out that gitweb URLs are described in gitweb(1) manpage
https://git.github.io/htmldocs/gitweb.html#_actions_and_urls in the
"Actions, and URLs" section.

What was missing was explanation of available query parameters (the URL
arguments after the '?').  Would the following patch help, or is it still
missing something (NOTE: not tested)?:

----- >8 ------------------------------------------------------ >8 -----
Subject: [PATCH] gitweb(1): Document query parameters

The gitweb manpage includes description of gitweb URL structure,
but it was limited to passing parameters in the path part of URL
('path info'), and it didn't include explanation of query parameters.
---
 Documentation/gitweb.txt | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt
index 96156e5..301003f 100644
--- a/Documentation/gitweb.txt
+++ b/Documentation/gitweb.txt
@@ -395,6 +395,43 @@ atom::
 	Generates an RSS (or Atom) feed of changes to repository.
 
 
+Query parameters:
+~~~~~~~~~~~~~~~~~
+In some cases gitweb cannot pass a parameter in path part of URL, for
+example if a filename contains double dots ('..') inside.  All parameters
+that cannot be passed in that way are put as a query parameter, that is
+after '?'.
+
+By default gitweb would generate links using query parameters, unless
+the original URL was using path part, or gitweb was configured to use
+pathinfo with the 'pathinfo' feature. All gitweb installations recognize
+URL in either format, so you can use one that is better for you when
+interacting with gitweb (handcrafting or editing URLs, or creating
+a program interacting with gitweb installation).
+
+Here is the list of some of query parameters, together with their
+long names (which should help remembering the short name of
+each parameter):
+
+'a' (action)::
+	The action that will be run.
+
+'p' (project)::
+	The project repository that will be displayed.
+
+'h' (hash)::
+	The object id of displayed object (commit, tag, tree, blob).
+	In case of files 'hb' (hash_base) and 'f' (filename) might be
+	used instead.
+
+'hp' (hash_parent)::
+'fp' (file_parent)::
+'hpb' (hash_parent_base)::
+      Those parameters define the second object for diff-like actions,
+      the object gitweb is comparing againts.
+
+
+
 WEBSERVER CONFIGURATION
 -----------------------
 This section explains how to configure some common webservers to run gitweb. In
-- 
2.6.3




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Complex gitweb URL
  2016-07-23 17:47 ` Jakub Narębski
@ 2016-07-25 16:34   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2016-07-25 16:34 UTC (permalink / raw
  To: Jakub Narębski; +Cc: CLOSE Dave, git@vger.kernel.org

Jakub Narębski <jnareb@gmail.com> writes:

> Subject: [PATCH] gitweb(1): Document query parameters
>
> The gitweb manpage includes description of gitweb URL structure,
> but it was limited to passing parameters in the path part of URL
> ('path info'), and it didn't include explanation of query parameters.
> ---

I think this weather-balloon patch adds the missing info at the most
natural place in the flow of the document.  An earlier part talks
about a GitWeb URL having <repo>, <action>, <revision>, <path> and
followed by what is called <arguments> after a question mark '?',
but what <arguments> part means and how to formulate it are left
unsaid.

By the way, the title of the section 'Actions, and URLs' needs to
lose the comma, I would think.

>  Documentation/gitweb.txt | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt
> index 96156e5..301003f 100644
> --- a/Documentation/gitweb.txt
> +++ b/Documentation/gitweb.txt
> @@ -395,6 +395,43 @@ atom::
>  	Generates an RSS (or Atom) feed of changes to repository.
>  
>  
> +Query parameters:
> +~~~~~~~~~~~~~~~~~
> +In some cases gitweb cannot pass a parameter in path part of URL, for
> +example if a filename contains double dots ('..') inside.  All parameters
> +that cannot be passed in that way are put as a query parameter, that is
> +after '?'.

Until this point, the reader hasn't even been told about "filename"
is one of the potential things that can be given to "control the
behaviour of the action", and is left wondering if she has a
filename that does not have double-dots, how it can be passed "in
path part of URL" after reading the first sentence.  Then the second
sentence adds more to the mystery by starting with "All parameters
that cannot be passed" "in that way": what are the possible things
that the users may want to pass?  what exactly is "in that way",
which probably means "encoded as part of the <path>", but it is
unclear how that encoding works (is it just to "concatenate"?).

Or is "filename in the revision" the ONLY thing the above paragraph
talks about, and is the ONLY purpose of the "<path> part" to
represent that "filename in the revision" in the URL?

    .../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments>

The above syntax (taken from the first paragraph of the section)
suggests that <path> cannot be used to hold filename with a colon,
too.  Perhaps "for example if a filename contains double-dots" needs
to become an exhaustive description somewhere, i.e. "(see below for
the exact rules)" added to that sentence?

> +By default gitweb would generate links using query parameters, unless
> +the original URL was using path part, or gitweb was configured to use
> +pathinfo with the 'pathinfo' feature. All gitweb installations recognize
> +URL in either format, so you can use one that is better for you when
> +interacting with gitweb (handcrafting or editing URLs, or creating
> +a program interacting with gitweb installation).
> +
> +Here is the list of some of query parameters, together with their
> +long names (which should help remembering the short name of
> +each parameter):
> +
> +'a' (action)::
> +	The action that will be run.
> +
> +'p' (project)::
> +	The project repository that will be displayed.
> +
> +'h' (hash)::
> +	The object id of displayed object (commit, tag, tree, blob).
> +	In case of files 'hb' (hash_base) and 'f' (filename) might be
> +	used instead.
> +
> +'hp' (hash_parent)::
> +'fp' (file_parent)::
> +'hpb' (hash_parent_base)::
> +      Those parameters define the second object for diff-like actions,
> +      the object gitweb is comparing againts.

There is no mention of "filename" or "path" here, which further
confuses a reader who was told in the first paragraph that these
query-parameters are used when <path> part cannot hold a certain
filename.  Also it is unclear if <revision> corresponds to 'h'ash
in the above.

> +
> +
> +
>  WEBSERVER CONFIGURATION
>  -----------------------
>  This section explains how to configure some common webservers to run gitweb. In

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-07-25 16:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-20 19:24 Complex gitweb URL CLOSE Dave
2016-07-20 21:20 ` Jakub Narębski
2016-07-20 21:35   ` CLOSE Dave
2016-07-20 21:50     ` Jakub Narębski
2016-07-20 21:46   ` CLOSE Dave
2016-07-23 17:47 ` Jakub Narębski
2016-07-25 16:34   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).