All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 2/4] gitweb: Separate printing of git_tree row into git_print_tree_entry
Date: Thu, 31 Aug 2006 00:35:07 +0200	[thread overview]
Message-ID: <200608310035.07585.jnareb@gmail.com> (raw)
In-Reply-To: <200608310030.33512.jnareb@gmail.com>

This is preparation for "tree blame" (similar to what ViewVC shows)
output, i.e. for each entry give commit where it was changed.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This could be applied even though it is proof-of-concept series,
but I think it would be better to separate git_tree_body rather,
although perhaps something like git_print_tree_entry subroutine
is a good idea.

 gitweb/gitweb.perl |  103 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 59 insertions(+), 44 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 84a13fd..d8b94a1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1462,6 +1462,62 @@ sub git_print_simplified_log {
 		-remove_title => $remove_title);
 }
 
+# print tree entry (row of git_tree), but without encompassing <tr> element
+sub git_print_tree_entry {
+	my ($t, $basedir, $hash_base, $have_blame) = @_;
+
+	my %base_key = ();
+	$base_key{hash_base} = $hash_base if defined $hash_base;
+
+	print "<td class=\"mode\">" . mode_str($t->{'mode'}) . "</td>\n";
+	if ($t->{'type'} eq "blob") {
+		print "<td class=\"list\">" .
+		      $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
+		                             file_name=>"$basedir$t->{'name'}", %base_key),
+		              -class => "list"}, esc_html($t->{'name'})) .
+		      "</td>\n" .
+		      "<td class=\"link\">" .
+		      $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
+		                             file_name=>"$basedir$t->{'name'}", %base_key)},
+		              "blob");
+		if ($have_blame) {
+			print " | " .
+				$cgi->a({-href => href(action=>"blame", hash=>$t->{'hash'},
+				                       file_name=>"$basedir$t->{'name'}", %base_key)},
+				        "blame");
+		}
+		if (defined $hash_base) {
+			print " | " .
+			      $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
+			                             hash=>$t->{'hash'}, file_name=>"$basedir$t->{'name'}")},
+			              "history");
+		}
+		print " | " .
+		      $cgi->a({-href => href(action=>"blob_plain",
+		                             hash=>$t->{'hash'}, file_name=>"$basedir$t->{'name'}")},
+		              "raw") .
+		      "</td>\n";
+
+	} elsif ($t->{'type'} eq "tree") {
+		print "<td class=\"list\">" .
+		      $cgi->a({-href => href(action=>"tree", hash=>$t->{'hash'},
+		                             file_name=>"$basedir$t->{'name'}", %base_key)},
+		              esc_html($t->{'name'})) .
+		      "</td>\n" .
+		      "<td class=\"link\">" .
+		      $cgi->a({-href => href(action=>"tree", hash=>$t->{'hash'},
+		                             file_name=>"$basedir$t->{'name'}", %base_key)},
+		              "tree");
+		if (defined $hash_base) {
+			print " | " .
+			      $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
+			                             file_name=>"$basedir$t->{'name'}")},
+			              "history");
+		}
+		print "</td>\n";
+	}
+}
+
 ## ......................................................................
 ## functions printing large fragments of HTML
 
@@ -2499,14 +2555,13 @@ sub git_tree {
 	my $refs = git_get_references();
 	my $ref = format_ref_marker($refs, $hash_base);
 	git_header_html();
-	my %base_key = ();
 	my $base = "";
 	my $have_blame = gitweb_check_feature('blame');
 	if (defined $hash_base && (my %co = parse_commit($hash_base))) {
-		$base_key{hash_base} = $hash_base;
 		git_print_page_nav('tree','', $hash_base);
 		git_print_header_div('commit', esc_html($co{'title'}) . $ref, $hash_base);
 	} else {
+		undef $hash_base;
 		print "<div class=\"page_nav\">\n";
 		print "<br/><br/></div>\n";
 		print "<div class=\"title\">$hash</div>\n";
@@ -2528,48 +2583,8 @@ sub git_tree {
 		}
 		$alternate ^= 1;
 
-		print "<td class=\"mode\">" . mode_str($t{'mode'}) . "</td>\n";
-		if ($t{'type'} eq "blob") {
-			print "<td class=\"list\">" .
-			      $cgi->a({-href => href(action=>"blob", hash=>$t{'hash'},
-			                             file_name=>"$base$t{'name'}", %base_key),
-			              -class => "list"}, esc_html($t{'name'})) .
-			      "</td>\n" .
-			      "<td class=\"link\">" .
-			      $cgi->a({-href => href(action=>"blob", hash=>$t{'hash'},
-			                             file_name=>"$base$t{'name'}", %base_key)},
-			              "blob");
-			if ($have_blame) {
-				print " | " .
-					$cgi->a({-href => href(action=>"blame", hash=>$t{'hash'},
-					                       file_name=>"$base$t{'name'}", %base_key)},
-					        "blame");
-			}
-			print " | " .
-			      $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
-			                             hash=>$t{'hash'}, file_name=>"$base$t{'name'}")},
-			              "history") .
-			      " | " .
-			      $cgi->a({-href => href(action=>"blob_plain",
-			                             hash=>$t{'hash'}, file_name=>"$base$t{'name'}")},
-			              "raw") .
-			      "</td>\n";
-		} elsif ($t{'type'} eq "tree") {
-			print "<td class=\"list\">" .
-			      $cgi->a({-href => href(action=>"tree", hash=>$t{'hash'},
-			                             file_name=>"$base$t{'name'}", %base_key)},
-			              esc_html($t{'name'})) .
-			      "</td>\n" .
-			      "<td class=\"link\">" .
-			      $cgi->a({-href => href(action=>"tree", hash=>$t{'hash'},
-			                             file_name=>"$base$t{'name'}", %base_key)},
-			              "tree") .
-			      " | " .
-			      $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
-			                             file_name=>"$base$t{'name'}")},
-			              "history") .
-			      "</td>\n";
-		}
+		git_print_tree_entry(\%t, $base, $hash_base, $have_blame);
+
 		print "</tr>\n";
 	}
 	print "</table>\n" .
-- 
1.4.1.1

  parent reply	other threads:[~2006-08-30 22:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200608310030.33512.jnareb@gmail.com>
2006-08-30 22:32 ` [PATCH 1/4] gitweb: Move git-ls-tree output parsing to parse_ls_tree_line Jakub Narebski
2006-08-30 22:35 ` Jakub Narebski [this message]
2006-08-30 22:36 ` [PATCH 3/4] gitweb: Extend parse_difftree_raw_line to save commit info Jakub Narebski
2006-08-30 22:36 ` [PATCH 4/4] gitweb: Add "tree_blame" view (WIP) 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=200608310035.07585.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.