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

[PATCH 3/3] gitweb: Make 'object' action implicit by using no action URL

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

In format_log_line_html() subroutine gitweb makes (shortened) SHA-1 of an object into hyperlink, as a very simple comittags support. Usually, but not always this link is to 'commit' object.

In git_print_tree_entry() subroutine gitweb provides link to the target of symbolic link, for easier navigation, if it looks like it leads inside tree. Gitweb doesn't know if it leads to directory ('tree' object), or an ordinary file ('blob' object), or if it is broken. (It cn also in rare cases lead to submodule, which now will result in the 'commit' view).

Both of those cases used generic 'object' action to find correct view on request, only when link were followed. Now we make use of the fact that gitweb tries to find correct action if none provided; it uses 'object' action if action is not provided, but project and either hash or hash_base and filename are.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Hmmmm... isn't this commit message too long for such a simple change?
 gitweb/gitweb.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f507a5a..a5df2fe 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1072,7 +1072,7 @@ sub format_log_line_html {
 	if ($line =~ m/([0-9a-fA-F]{8,40})/) {
 		my $hash_text = $1;
 		my $link =
-			$cgi->a({-href => href(action=>"object", hash=>$hash_text),
+			$cgi->a({-href => href(hash=>$hash_text),
 			        -class => "text"}, $hash_text);
 		$line =~ s/$hash_text/$link/;
 	}
@@ -2912,7 +2912,7 @@ sub git_print_tree_entry {
 				my $norm_target = normalize_link_target($link_target, $basedir, $hash_base);
 				if (defined $norm_target) {
 					print " -> " .
-					      $cgi->a({-href => href(action=>"object", hash_base=>$hash_base,
+					      $cgi->a({-href => href(hash_base=>$hash_base,
 					                             file_name=>$norm_target),
 					               -title => $norm_target}, esc_path($link_target));
 				} else {
-- 
1.5.4.3.453.gc1ad83
Previous: Jakub Narebski
Message 4 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.