Subject: Re: [PATCH] gitweb: choose appropriate view for file type if a= parameter missing

From: Jakub Narebski <[email-masked]>
Date: Sun, 13 May 2007 02:32:36 +0200

<opublikowany i wysłany>

[Cc: Gerrit Pape <[email-masked]>, Junio C Hamano <[email-masked]>,
 [email-masked]]

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