git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: choose appropriate view for file type if a= parameter missing.
@ 2007-05-09 22:19 Gerrit Pape
  2007-05-10  2:04 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Gerrit Pape @ 2007-05-09 22:19 UTC (permalink / raw)
  To: git; +Cc: 410465

See http://bugs.debian.org/410465

gitweb URLs use the a= parameter for the view to use on the given path, such
as "blob" or "tree".  Currently, if a gitweb URL omits the a= parameter,
gitweb just shows the top-level repository summary, regardless of the path
given.  gitweb could instead choose an appropriate view based on the file
type: blob for blobs (files), tree for trees (directories), and summary if no
path given (the URL included no f= parameter, or an empty f= parameter).

Apart from making gitweb more robust and supporting URL editing more easily,
this change would aid the creation of shortcuts to git repositories using
simple substitution, such as:
http://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s

- Josh Triplett

Signed-off-by: Gerrit Pape <pape@smarden.org>
---
 gitweb/gitweb.perl |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 90243fd..21864c6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -458,10 +458,16 @@ my %actions = (
 	"project_index" => \&git_project_index,
 );
 
-if (defined $project) {
-	$action ||= 'summary';
-} else {
-	$action ||= 'project_list';
+if (!defined $action) {
+	if (defined $hash) {
+		$action = git_get_type($hash);
+	} elsif (defined $hash_base && defined $file_name) {
+		$action = git_get_type("$hash_base:$file_name");
+	} elsif (defined $project) {
+		$action = 'summary';
+	} else {
+		$action = 'project_list';
+	}
 }
 if (!defined($actions{$action})) {
 	die_error(undef, "Unknown action");
-- 
1.5.1.3

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

* Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing.
  2007-05-09 22:19 [PATCH] gitweb: choose appropriate view for file type if a= parameter missing Gerrit Pape
@ 2007-05-10  2:04 ` Junio C Hamano
  2007-05-10  7:32   ` Gerrit Pape
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2007-05-10  2:04 UTC (permalink / raw)
  To: Gerrit Pape; +Cc: git

Gerrit Pape <pape@smarden.org> writes:

> See http://bugs.debian.org/410465
>
> gitweb URLs use the a= parameter for the view to use on the given path, such
> as "blob" or "tree".  Currently, if a gitweb URL omits the a= parameter,
> gitweb just shows the top-level repository summary, regardless of the path
> given.  gitweb could instead choose an appropriate view based on the file
> type: blob for blobs (files), tree for trees (directories), and summary if no
> path given (the URL included no f= parameter, or an empty f= parameter).
>
> Apart from making gitweb more robust and supporting URL editing more easily,
> this change would aid the creation of shortcuts to git repositories using
> simple substitution, such as:
> http://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s
>
> - Josh Triplett
>
> Signed-off-by: Gerrit Pape <pape@smarden.org>

I am not sure if this is a "good" feature or just "because we
can" feature, but I am slightly in favor.  I do not know about
others.

I'd however request a few changes to the proposed commit log
message:

 * "See http://..." is not the primary information, but "see
   ... for further details"; please have it at the end, not at
   the beginning.

 * Was the patch authored by you, or Josh?  If the former,
   what's his name doing here?  Perhaps you wanted to say
   "Reported by Josh Triplett"?

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

* [PATCH] gitweb: choose appropriate view for file type if a= parameter missing
  2007-05-10  2:04 ` Junio C Hamano
@ 2007-05-10  7:32   ` Gerrit Pape
  2007-05-10  7:43     ` Junio C Hamano
  2007-05-13  0:32     ` Jakub Narebski
  0 siblings, 2 replies; 5+ messages in thread
From: Gerrit Pape @ 2007-05-10  7:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

gitweb URLs use the a= parameter for the view to use on the given path, such
as "blob" or "tree".  Currently, if a gitweb URL omits the a= parameter,
gitweb just shows the top-level repository summary, regardless of the path
given.  gitweb could instead choose an appropriate view based on the file
type: blob for blobs (files), tree for trees (directories), and summary if
no path given (the URL included no f= parameter, or an empty f= parameter).

Apart from making gitweb more robust and supporting URL editing more easily,
this change would aid the creation of shortcuts to git repositories using
simple substitution, such as:
http://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s

With this patch, if given the hash through the h= parameter, or the hash
base (hb=) and a filename (f=), gitweb uses cat-file -t to automatically set
the a= parameter.

This feature was requested by Josh Triplett through
 http://bugs.debian.org/410465

Signed-off-by: Gerrit Pape <pape@smarden.org>
---

On Wed, May 09, 2007 at 07:04:01PM -0700, Junio C Hamano wrote:
> I'd however request a few changes to the proposed commit log
> message:
>
>  * "See http://..." is not the primary information, but "see
>    ... for further details"; please have it at the end, not at
>    the beginning.

Okay.

>  * Was the patch authored by you, or Josh?  If the former,
>    what's his name doing here?  Perhaps you wanted to say
>    "Reported by Josh Triplett"?

Sometimes I'm lazy, it was just a copy&paste from the Debian bug report
submitted by Josh.

Regards, Gerrit.

 gitweb/gitweb.perl |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 90243fd..21864c6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -458,10 +458,16 @@ my %actions = (
 	"project_index" => \&git_project_index,
 );
 
-if (defined $project) {
-	$action ||= 'summary';
-} else {
-	$action ||= 'project_list';
+if (!defined $action) {
+	if (defined $hash) {
+		$action = git_get_type($hash);
+	} elsif (defined $hash_base && defined $file_name) {
+		$action = git_get_type("$hash_base:$file_name");
+	} elsif (defined $project) {
+		$action = 'summary';
+	} else {
+		$action = 'project_list';
+	}
 }
 if (!defined($actions{$action})) {
 	die_error(undef, "Unknown action");
-- 
1.5.1.3

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

* Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing
  2007-05-10  7:32   ` Gerrit Pape
@ 2007-05-10  7:43     ` Junio C Hamano
  2007-05-13  0:32     ` Jakub Narebski
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2007-05-10  7:43 UTC (permalink / raw)
  To: Gerrit Pape; +Cc: git

Thanks.

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

* Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing
  2007-05-10  7:32   ` Gerrit Pape
  2007-05-10  7:43     ` Junio C Hamano
@ 2007-05-13  0:32     ` Jakub Narebski
  1 sibling, 0 replies; 5+ messages in thread
From: Jakub Narebski @ 2007-05-13  0:32 UTC (permalink / raw)
  To: git

<opublikowany i wysłany>

[Cc: Gerrit Pape <pape@smarden.org>, Junio C Hamano <junkio@cox.net>,
 git@vger.kernel.org]

Gerrit Pape wrote:

> this change would aid the creation of shortcuts to git repositories using
> simple substitution, such as:
> http://example.org/git/?p=path/to/repo.git;hb=HEAD;f=%s
> 
> With this patch, if given the hash through the h= parameter, or the hash
> base (hb=) and a filename (f=), gitweb uses cat-file -t to automatically set
> the a= parameter.

> -if (defined $project) {
> -     $action ||= 'summary';
> -} else {
> -     $action ||= 'project_list';
> +if (!defined $action) {
> +     if (defined $hash) {
> +             $action = git_get_type($hash);
> +     } elsif (defined $hash_base && defined $file_name) {
> +             $action = git_get_type("$hash_base:$file_name");
> +     } elsif (defined $project) {
> +             $action = 'summary';
> +     } else {
> +             $action = 'project_list';
> +     }

NOTE:

We have something similar for the only committag we support, namely
the shortened sha1 of object, which leads to an "object", which chooses
appropriate view using git_get_type / git-cat-file -t.

But contrary to the above solution it does it by creating a _redirect_
to a proper view, instead of silently selecting proper view like in
a patch above. Creating a redirect allows price for invoking 
git-cat-file -t to be paid only once. User would bookmark correct view.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

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

end of thread, other threads:[~2007-05-13  0:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-09 22:19 [PATCH] gitweb: choose appropriate view for file type if a= parameter missing Gerrit Pape
2007-05-10  2:04 ` Junio C Hamano
2007-05-10  7:32   ` Gerrit Pape
2007-05-10  7:43     ` Junio C Hamano
2007-05-13  0:32     ` Jakub Narebski

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 NNTP newsgroup(s).