Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- May 13, 2007, 00:32 UTC
- Message-ID
- <f25m2b$1b1$1@sea.gmane.org>
- In-Reply-To
- <20070510073207.21562.qmail@25d0c789693af2.315fe32.mid.smarden.org>
<opublikowany i wysłany>
[Cc: Gerrit Pape <pape@smarden.org>, Junio C Hamano <junkio@cox.net>, git@vger.kernel.org]
Gerrit Pape wrote:
Show 7 quoted lines
> 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.
Show 14 quoted lines
> -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