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

[PATCH 10 (amended)] gitweb: Add support for hash_parent_base parameter for blobdiffs

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 24, 2006, 21:53 UTC
Message-ID
<200608242353.54869.jnareb@gmail.com>
In-Reply-To
<200608240015.15071.jnareb@gmail.com>

Add support for hash_parent_base in input validation part and in href() function. Add proper hash_parent_base to all calls to blobdiff and blobdiff_plain action URLs. Use hash_parent_base as hash_base for blobs of hash_parent.

To be used in future rewrite of git_blobdiff and git_blobdiff_plain.

While at it, move project before action in ordering CGI parameters in href().

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b2e8259..a3553ad 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -211,6 +211,13 @@ if (defined $hash_base) {
 	}
 }
 
+our $hash_parent_base = $cgi->param('hpb');
+if (defined $hash_parent_base) {
+	if (!validate_input($hash_parent_base)) {
+		die_error(undef, "Invalid hash parent base parameter");
+	}
+}
+
 our $page = $cgi->param('pg');
 if (defined $page) {
 	if ($page =~ m/[^0-9]$/) {
@@ -270,13 +277,14 @@ sub href(%) {
 	my %params = @_;
 
 	my @mapping = (
-		action => "a",
 		project => "p",
+		action => "a",
 		file_name => "f",
 		file_parent => "fp",
 		hash => "h",
 		hash_parent => "hp",
 		hash_base => "hb",
+		hash_parent_base => "hpb",
 		page => "pg",
 		searchtext => "s",
 	);
@@ -1543,8 +1551,10 @@ sub git_difftree_body {
 			}
 			print "<td>";
 			if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
-				print $cgi->a({-href => href(action=>"blobdiff", hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
-				                             hash_base=>$hash, file_name=>$diff{'file'}),
+				print $cgi->a({-href => href(action=>"blobdiff",
+				                             hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
+				                             hash_base=>$hash, hash_parent_base=>$parent,
+				                             file_name=>$diff{'file'}),
 				              -class => "list"}, esc_html($diff{'file'}));
 			} else { # only mode changed
 				print $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'},
@@ -1559,8 +1569,10 @@ sub git_difftree_body {
 				        "blob");
 			if ($diff{'to_id'} ne $diff{'from_id'}) { # modified
 				print " | " .
-					$cgi->a({-href => href(action=>"blobdiff", hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
-					                       hash_base=>$hash, file_name=>$diff{'file'})},
+					$cgi->a({-href => href(action=>"blobdiff",
+					                       hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
+					                       hash_base=>$hash, hash_parent_base=>$parent,
+					                       file_name=>$diff{'file'})},
 					        "diff");
 			}
 			print " | " .
@@ -1592,8 +1604,9 @@ sub git_difftree_body {
 			              "blob");
 			if ($diff{'to_id'} ne $diff{'from_id'}) {
 				print " | " .
-					$cgi->a({-href => href(action=>"blobdiff", hash_base=>$hash,
+					$cgi->a({-href => href(action=>"blobdiff",
 					                       hash=>$diff{'to_id'}, hash_parent=>$diff{'from_id'},
+					                       hash_base=>$hash, hash_parent_base=>$parent,
 					                       file_name=>$diff{'to_file'}, file_parent=>$diff{'from_file'})},
 					        "diff");
 			}
@@ -1793,8 +1806,10 @@ sub git_history_body {
 			if (defined $blob_current && defined $blob_parent &&
 					$blob_current ne $blob_parent) {
 				print " | " .
-					$cgi->a({-href => href(action=>"blobdiff", hash=>$blob_current, hash_parent=>$blob_parent,
-					                       hash_base=>$commit, file_name=>$file_name)},
+					$cgi->a({-href => href(action=>"blobdiff",
+					                       hash=>$blob_current, hash_parent=>$blob_parent,
+					                       hash_base=>$hash_base, hash_parent_base=>$commit,
+					                       file_name=>$file_name)},
 					        "diff to current");
 			}
 		}
@@ -2751,7 +2766,9 @@ sub git_blobdiff {
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
 		my $formats_nav =
 			$cgi->a({-href => href(action=>"blobdiff_plain",
-			                       hash=>$hash, hash_parent=>$hash_parent)},
+			                       hash=>$hash, hash_parent=>$hash_parent,
+			                       hash_base=>$hash_base, hash_parent_base=>$hash_parent_base,
+			                       file_name=>$file_name, file_parent=>$file_parent)},
 			        "plain");
 		git_print_page_nav('','', $hash_base,$co{'tree'},$hash_base, $formats_nav);
 		git_print_header_div('commit', esc_html($co{'title'}), $hash_base);
@@ -2765,7 +2782,7 @@ HTML
 	print "<div class=\"page_body\">\n" .
 	      "<div class=\"diff_info\">blob:" .
 	      $cgi->a({-href => href(action=>"blob", hash=>$hash_parent,
-	                             hash_base=>$hash_base, file_name=>($file_parent || $file_name))},
+	                             hash_base=>$hash_parent_base, file_name=>($file_parent || $file_name))},
 	              $hash_parent) .
 	      " -> blob:" .
 	      $cgi->a({-href => href(action=>"blob", hash=>$hash,
-- 
1.4.1.1
Previous: Jakub NarebskiNext: Jakub Narebski
Message 19 of 53 in “gitweb: Use git-diff-tree patch output for commitdiff”
  1. gitweb: Use git-diff-tree patch output for commitdiffJakub Narebski, Aug 23, 2006
  2. gitweb: Replace git_commitdiff_plain by anonymous subroutineJakub Narebski, Aug 23, 2006
  3. gitweb: Show information about incomplete lines in commitdiffJakub Narebski, Aug 23, 2006
  4. Junio C HamanoAug 24, 2006
  5. Jakub NarebskiAug 24, 2006
  6. Junio C HamanoAug 24, 2006
  7. Jakub NarebskiAug 24, 2006
  8. Junio C HamanoAug 24, 2006
  9. Jakub NarebskiAug 24, 2006
  10. Marco CostalbaAug 25, 2006
  11. Jakub NarebskiAug 25, 2006
  12. gitweb: Remove invalid comment in format_diff_lineJakub Narebski, Aug 24, 2006
  13. gitweb: Streamify patch output in git_commitdiffJakub Narebski, Aug 24, 2006
  14. gitweb: Add git_get_{following,preceding}_references functionsJakub Narebski, Aug 24, 2006
  15. gitweb: Faster return from git_get_preceding_references if possibleJakub Narebski, Aug 24, 2006
  16. gitweb: Add git_get_rev_name_tags functionJakub Narebski, Aug 24, 2006
  17. gitweb: Use git_get_name_rev_tags for commitdiff_plain X-Git-Tag: headerJakub Narebski, Aug 24, 2006
  18. gitweb: Add support for hash_parent_base parameter for blobdiffsJakub Narebski, Aug 24, 2006
  19. gitweb: Add support for hash_parent_base parameter for blobdiffsJakub Narebski, Aug 24, 2006
  20. 11/19 gitweb: Allow for pre-parsed difftree info in git_patchset_bodyJakub Narebski, Aug 25, 2006
  21. 12/19 gitweb: Parse two-line from-file/to-file diff header in git_patchset_bodyJakub Narebski, Aug 25, 2006
  22. 13/19 gitweb: Add invisible hyperlink to from-file/to-file diff headerJakub Narebski, Aug 25, 2006
  23. Linus TorvaldsAug 27, 2006
  24. 14/19 gitweb: Always display link to blobdiff_plain in git_blobdiffJakub Narebski, Aug 25, 2006
  25. 15/19 gitweb: Change here-doc back for style consistency in git_blobdiffJakub Narebski, Aug 25, 2006
  26. 16/19 gitweb: Use git-diff-tree or git-diff patch output for blobdiffJakub Narebski, Aug 25, 2006
  27. Jakub NarebskiAug 26, 2006
  28. Junio C HamanoAug 26, 2006
  29. Jakub NarebskiAug 26, 2006
  30. gitweb: Remove workaround for git-diff bug fixed in f82cd3cJakub Narebski, Aug 26, 2006
  31. 17/19 gitweb: git_blobdiff_plain is git_blobdiff('plain')Jakub Narebski, Aug 25, 2006
  32. 18/19 gitweb: Remove git_diff_print subroutineJakub Narebski, Aug 25, 2006
  33. 19/19 gitweb: Remove creating directory for temporary filesJakub Narebski, Aug 25, 2006
  34. Marco CostalbaAug 25, 2006
  35. Jakub NarebskiAug 25, 2006
  36. Junio C HamanoAug 26, 2006
  37. Marco CostalbaAug 26, 2006
  38. Junio C HamanoAug 26, 2006
  39. Marco CostalbaAug 26, 2006
  40. Marco CostalbaAug 26, 2006
  41. Shawn PearceAug 26, 2006
  42. Josef WeidendorferAug 26, 2006
  43. Jakub NarebskiAug 26, 2006
  44. Junio C HamanoAug 26, 2006
  45. Jakub NarebskiAug 26, 2006
  46. Junio C HamanoAug 27, 2006
  47. Junio C HamanoAug 27, 2006
  48. Jakub NarebskiAug 27, 2006
  49. 00/19 gitweb: Remove dependency on external diff and need for temporary filesJakub Narebski, Aug 25, 2006
  50. Linus TorvaldsAug 27, 2006
  51. David MillerAug 27, 2006
  52. Linus TorvaldsAug 27, 2006
  53. Jakub NarebskiAug 27, 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.