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

[PATCH 1/3] gitweb: Redirect to appropriate view if 'a=' parameter is missing

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 7, 2008, 21:03 UTC
Message-ID
<1204923800-5923-2-git-send-email-jnareb@gmail.com>
In-Reply-To
<1204923800-5923-1-git-send-email-jnareb@gmail.com>

Instead of finding the type of object specified by 'h', or 'hb' and 'f' parameters and substituting it for action (view), as it was done since commit 7f9778b by Gerrit Pape, use 'object' view which would find type and REDIRECT to URL with 'a' parameter filled in.

This way user will have URL with action filled in the browser history, or when adding bookmark. This hopefully would make server get less requests without 'a' parameter set, thus reducing a bit load on server.

Note that the code to find object type in git_object() subroutine is a bit more complicated than was used for URL without 'a=' parameter.

Cc: Gerrit Pape <pape@smarden.org>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
The fact that using 'object' view changes a bit behavior is addressed
in second commit in this series, where git_commit() is made to do what
dispatch for URL without a=, but with h= or hb= and f= did before.
 gitweb/gitweb.perl |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ec73cb1..a76c4ac 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -564,10 +564,9 @@ my %actions = (
 );
 
 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");
+	if (defined $hash ||
+	    (defined $hash_base && defined $file_name)) {
+		$action = 'object';
 	} elsif (defined $project) {
 		$action = 'summary';
 	} else {
-- 
1.5.4.3.453.gc1ad83
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 4 in “gitweb: Improved treatment of links with unknown object type”
  1. 0/3 gitweb: Improved treatment of links with unknown object typeJakub Narebski, Mar 7, 2008
  2. 1/3 gitweb: Redirect to appropriate view if 'a=' parameter is missingJakub Narebski, Mar 7, 2008
  3. 2/3 gitweb: Simplify object type detection in git_object()Jakub Narebski, Mar 7, 2008
  4. 3/3 gitweb: Make 'object' action implicit by using no action URLJakub Narebski, Mar 7, 2008

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.