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

[PATCH 2/1 (amend)] gitweb: Use fixed string for "next" link in commitdiff view

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 24, 2006, 09:04 UTC
Message-ID
<200610241104.18517.jnareb@gmail.com>
In-Reply-To
<20061023232117.GV20017@pasky.or.cz>

Use fixed string instead of shortened SHA1 identifier of commit as a name for "mext" link in commitdiff view.

While at it make sure that we don't mistake option for a second commit.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4241d5c..9c81214 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3289,17 +3289,14 @@ sub git_commitdiff {
 			                       hash=>$hash, hash_parent=>$hash_parent)},
 			        "raw");
 
-		if (defined $hash_parent) {
+		if (defined $hash_parent && $hash_parent !~ m/^-/) {
 			# commitdiff with two commits given
-			my $hash_parent_short = $hash_parent;
-			if ($hash_parent =~ m/^[0-9a-fA-F]{40}$/) {
-				$hash_parent_short = substr($hash_parent, 0, 7);
-			}
+			# second "commit" is not in fact diff option
 			$formats_nav .=
-				' (from: ' .
+				' (' .
 				$cgi->a({-href => href(action=>"commitdiff",
 				                       hash=>$hash_parent)},
-				        esc_html($hash_parent_short)) .
+				        'from') .
 				')';
 		} elsif (!$co{'parent'}) {
 			# --root commitdiff
@@ -3307,10 +3304,10 @@ sub git_commitdiff {
 		} elsif (scalar @{$co{'parents'}} == 1) {
 			# single parent commit
 			$formats_nav .=
-				' (parent: ' .
+				' (' .
 				$cgi->a({-href => href(action=>"commitdiff",
 				                       hash=>$co{'parent'})},
-				        esc_html(substr($co{'parent'}, 0, 7))) .
+				        'parent') .
 				')';
 		} else {
 			# merge commit
@@ -3319,7 +3316,7 @@ sub git_commitdiff {
 				join(' ', map {
 					$cgi->a({-href => href(action=>"commitdiff",
 					                       hash=>$_)},
-					        esc_html(substr($_, 0, 7)));
+					        'parent');
 				} @{$co{'parents'}} ) .
 				')';
 		}
-- 
1.4.2.1
Previous: Petr BaudisNext: Junio C Hamano
Message 7 of 16 in “gitweb: Add "next" link to commitdiff view”
  1. gitweb: Add "next" link to commitdiff viewJakub Narebski, Oct 22, 2006
  2. Jakub NarebskiOct 22, 2006
  3. Junio C HamanoOct 22, 2006
  4. Jakub NarebskiOct 22, 2006
  5. 2/1 gitweb: Use fixed string for "next" link in commitdiff viewJakub Narebski, Oct 23, 2006
  6. Petr BaudisOct 23, 2006
  7. 2/1 gitweb: Use fixed string for "next" link in commitdiff viewJakub Narebski, Oct 24, 2006
  8. Junio C HamanoOct 24, 2006
  9. Jakub NarebskiOct 24, 2006
  10. Petr BaudisOct 24, 2006
  11. Jakub NarebskiOct 24, 2006
  12. Petr BaudisOct 24, 2006
  13. Junio C HamanoOct 24, 2006
  14. Petr BaudisOct 24, 2006
  15. Junio C HamanoOct 24, 2006
  16. Jakub NarebskiOct 24, 2006

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.