git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C Hamano
Message 5 of 5 in “gitweb: choose appropriate view for file type if a= parameter missing.”
  1. gitweb: choose appropriate view for file type if a= parameter missing.Gerrit Pape, May 9, 2007
  2. Junio C HamanoMay 10, 2007
  3. gitweb: choose appropriate view for file type if a= parameter missingGerrit Pape, May 10, 2007
  4. Junio C HamanoMay 10, 2007
  5. Jakub NarebskiMay 13, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.