git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 10 (amended)] gitweb: Add support for hash_parent_base parameter for blobdiffs
Date: Thu, 24 Aug 2006 23:53:54 +0200	[thread overview]
Message-ID: <200608242353.54869.jnareb@gmail.com> (raw)
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

  parent reply	other threads:[~2006-08-24 21:54 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-23 22:15 [PATCH/RFC 1/x] gitweb: Use git-diff-tree patch output for commitdiff Jakub Narebski
2006-08-23 23:58 ` [PATCH 2] gitweb: Replace git_commitdiff_plain by anonymous subroutine Jakub Narebski
2006-08-23 23:58 ` [PATCH 3] gitweb: Show information about incomplete lines in commitdiff Jakub Narebski
2006-08-24  2:21   ` Junio C Hamano
2006-08-24 11:12     ` Jakub Narebski
2006-08-24  2:15 ` [PATCH/RFC 1/x] gitweb: Use git-diff-tree patch output for commitdiff Junio C Hamano
2006-08-24 11:10   ` Jakub Narebski
2006-08-24 18:45     ` Junio C Hamano
2006-08-24 18:56       ` Jakub Narebski
2006-08-25 17:32     ` Marco Costalba
2006-08-25 18:18       ` Jakub Narebski
2006-08-24 17:32 ` [PATCH 4] gitweb: Remove invalid comment in format_diff_line Jakub Narebski
2006-08-24 17:34 ` [PATCH 5] gitweb: Streamify patch output in git_commitdiff Jakub Narebski
2006-08-24 17:37 ` [PATCH 6] gitweb: Add git_get_{following,preceding}_references functions Jakub Narebski
2006-08-24 17:39 ` [PATCH 7] gitweb: Faster return from git_get_preceding_references if possible Jakub Narebski
2006-08-24 17:41 ` [PATCH 8] gitweb: Add git_get_rev_name_tags function Jakub Narebski
2006-08-24 17:45 ` [PATCH 9] gitweb: Use git_get_name_rev_tags for commitdiff_plain X-Git-Tag: header Jakub Narebski
2006-08-24 18:50 ` [PATCH 10] gitweb: Add support for hash_parent_base parameter for blobdiffs Jakub Narebski
2006-08-24 21:53 ` Jakub Narebski [this message]
2006-08-25 18:59 ` [PATCH 11/19] gitweb: Allow for pre-parsed difftree info in git_patchset_body Jakub Narebski
2006-08-25 19:04 ` [PATCH 12/19] gitweb: Parse two-line from-file/to-file diff header " Jakub Narebski
2006-08-25 19:05 ` [PATCH 13/19] gitweb: Add invisible hyperlink to from-file/to-file diff header Jakub Narebski
2006-08-27  3:38   ` Linus Torvalds
2006-08-25 19:05 ` [PATCH 14/19] gitweb: Always display link to blobdiff_plain in git_blobdiff Jakub Narebski
2006-08-25 19:06 ` [PATCH 15/19] gitweb: Change here-doc back for style consistency " Jakub Narebski
2006-08-25 19:13 ` [PATCH 16/19] gitweb: Use git-diff-tree or git-diff patch output for blobdiff Jakub Narebski
2006-08-26  9:23   ` Jakub Narebski
2006-08-26 10:14     ` Junio C Hamano
2006-08-26 10:17       ` Jakub Narebski
2006-08-26 10:33   ` [PATCH 16a/19] gitweb: Remove workaround for git-diff bug fixed in f82cd3c Jakub Narebski
2006-08-25 19:14 ` [PATCH 17/19] gitweb: git_blobdiff_plain is git_blobdiff('plain') Jakub Narebski
2006-08-25 19:15 ` [PATCH 18/19] gitweb: Remove git_diff_print subroutine Jakub Narebski
2006-08-25 19:35 ` [PATCH 19/19] gitweb: Remove creating directory for temporary files Jakub Narebski
2006-08-25 21:33   ` Marco Costalba
2006-08-25 21:48     ` Jakub Narebski
2006-08-26  2:05     ` Junio C Hamano
2006-08-26  4:44       ` Marco Costalba
2006-08-26  5:13         ` Junio C Hamano
2006-08-26  5:34           ` Marco Costalba
2006-08-26  5:43             ` Marco Costalba
2006-08-26  5:40           ` Mozilla import and large history Shawn Pearce
2006-08-26  0:26   ` [PATCH 19/19] gitweb: Remove creating directory for temporary files Josef Weidendorfer
2006-08-26  0:46     ` Jakub Narebski
2006-08-26 19:25   ` Junio C Hamano
2006-08-26 20:18     ` Jakub Narebski
2006-08-27  2:51       ` Junio C Hamano
2006-08-27  0:24     ` Junio C Hamano
2006-08-27  0:38       ` Jakub Narebski
2006-08-25 21:15 ` [PATCH 00/19] gitweb: Remove dependency on external diff and need " Jakub Narebski
2006-08-27  3:30   ` Linus Torvalds
2006-08-27  3:42     ` David Miller
2006-08-27  3:54       ` Linus Torvalds
2006-08-27 15:37     ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200608242353.54869.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).