@matheusbsbs / matheus-bagliano / commits / 47598d7a49
Fork 0

gitweb: Provide links to commitdiff to each parent in 'commitdiff' view

Since commit-fb1dde4a we show combined diff for merges in 'commitdiff' view, and since commit-208ecb2e also in 'commit' view. Sometimes though one would want to see diff to one of merge commit parents. It is easy in 'commit' view: in the commit header part there are "diff" links for each of parent header. This commit adds such links also for 'commitdiff' view. 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 only in 'comitdiff' view, and only for a merge commit (comit with more than one 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 discover what links is for, each link has 'title' attribute explaining the link. Note that one would need to remember that difftree table in 'commit' view has one less column (it doesn't have "patch" link column), if one would want to add such table header also in 'commit' view. Example output: 1 2 3 Makefile patch | diff1 | diff2 | diff3 | blob | history cache.h patch | diff1 | diff2 | diff3 | blob | history Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jakub Narebski committed Jun 8, 2007 at 13:24 UTC 47598d7a4920f02c60d7091e7186c50468d83aab
2 files changed +26
gitweb/gitweb.css
+5
@@ -181,10 +181,15 @@ table.diff_tree {
181 font-family: monospace;
182 }
183
184 +table.combined.diff_tree th {
185 + text-align: center;
186 +}
187 +
188 table.combined.diff_tree td {
189 padding-right: 24px;
190 }
191
192 +table.combined.diff_tree th.link,
193 table.combined.diff_tree td.link {
194 padding: 0px 2px;
195 }
gitweb/gitweb.perl
+21
@@ -2401,6 +2401,26 @@ sub git_difftree_body {
2401 print "<table class=\"" .
2402 (@parents > 1 ? "combined " : "") .
2403 "diff_tree\">\n";
2404 +
2405 + # header only for combined diff in 'commitdiff' view
2406 + my $has_header = @parents > 1 && $action eq 'commitdiff';
2407 + if ($has_header) {
2408 + # table header
2409 + print "<thead><tr>\n" .
2410 + "<th></th><th></th>\n"; # filename, patchN link
2411 + for (my $i = 0; $i < @parents; $i++) {
2412 + my $par = $parents[$i];
2413 + print "<th>" .
2414 + $cgi->a({-href => href(action=>"commitdiff",
2415 + hash=>$hash, hash_parent=>$par),
2416 + -title => 'commitdiff to parent number ' .
2417 + ($i+1) . ': ' . substr($par,0,7)},
2418 + $i+1) .
2419 + "&nbsp;</th>\n";
2420 + }
2421 + print "</tr></thead>\n<tbody>\n";
2422 + }
2423 +
2424 my $alternate = 1;
2425 my $patchno = 0;
2426 foreach my $line (@{$difftree}) {
@@ -2673,6 +2693,7 @@ sub git_difftree_body {
2693 } # we should not encounter Unmerged (U) or Unknown (X) status
2694 print "</tr>\n";
2695 }
2696 + print "</tbody>" if $has_header;
2697 print "</table>\n";
2698 }
2699