Skip to contentSkip to conversation

gitweb: Provide links to individual commitdiffs in difftree for merges

PATCH/RFC Jakub Narebski 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Add to difftree / whatchanged table row with "1", "2", ... links to 'commitdiff' view for diff with n-th parent for merge commits, as a table header. This is visible in 'commit' and 'comitdiff' views. It is more important for 'commitdiff' view, as in 'commit' view commit object header has 'diff' links to diff to n-th parent.

To save space links are shown as "n", where "n" is number of a parent, and not as for example shortened (to 7 characters) sha1 of a parent commit. To make it easier to doscover what links is for, encompassing <th> element has 'title' attribute explaining the link.

---
This is my proposal on how to provide links to diffs to individual parents in the 'commitdiff' view. This is RFC: please comment if you like the idea (or not), and what the layout should be, what this should look like. Should we add those links only for 'commitdiff' view, for example?

Some complications in creating layout stem from the fact that "|" is used as separator, instead of using table border, or cell borders to separate columns. And we use "|" because in most other places we use only one cell (column) for the whole series of links.

 gitweb/gitweb.css  |    5 +++++
 gitweb/gitweb.perl |   19 +++++++++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
gitweb/gitweb.css +5 -0
index 9f0822f..7908fe3 100644
@@ -181,10 +181,15 @@ table.diff_tree {
 	font-family: monospace;
 }
 
+table.combined.diff_tree th {
+	text-align: center;
+}
+
 table.combined.diff_tree td {
 	padding-right: 24px;
 }
 
+table.combined.diff_tree th.link,
 table.combined.diff_tree td.link {
 	padding: 0px 2px;
 }
gitweb/gitweb.perl +19 -0
index c3921cb..999353d 100755
@@ -2380,6 +2380,25 @@ sub git_difftree_body {
 	print "<table class=\"" .
 	      (@parents > 1 ? "combined " : "") .
 	      "diff_tree\">\n";
+
+	if (@parents > 1) { #combined diff
+		# table header for combined diff
+		print "<tr>\n" .
+		      ($action eq 'commitdiff' ? "<th></th><th></th>\n"
+		                               : "<th></th>\n");
+		for (my $i = 0; $i < @parents; $i++) {
+			my $par = $parents[$i];
+			print "<th title=\"commitdiff to parent number " .
+			      ($i+1) . ": " .
+			      substr($par,0,7) . "\">" .
+			      $cgi->a({-href => href(action=>"commitdiff",
+			                             hash=>$hash, hash_parent=>$par)},
+			              $i+1) .
+			      "&nbsp;</th>\n";
+		}
+		print "</tr>\n";
+	}
+
 	my $alternate = 1;
 	my $patchno = 0;
 	foreach my $line (@{$difftree}) {
Signature · 1 line
1.5.2