Skip to content

Commit

Permalink
gitweb: Provide links to commitdiff to each parent in 'commitdiff' view
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Jun 10, 2007
1 parent c85d4f1 commit 47598d7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gitweb/gitweb.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
21 changes: 21 additions & 0 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,26 @@ sub git_difftree_body {
print "<table class=\"" .
(@parents > 1 ? "combined " : "") .
"diff_tree\">\n";

# header only for combined diff in 'commitdiff' view
my $has_header = @parents > 1 && $action eq 'commitdiff';
if ($has_header) {
# table header
print "<thead><tr>\n" .
"<th></th><th></th>\n"; # filename, patchN link
for (my $i = 0; $i < @parents; $i++) {
my $par = $parents[$i];
print "<th>" .
$cgi->a({-href => href(action=>"commitdiff",
hash=>$hash, hash_parent=>$par),
-title => 'commitdiff to parent number ' .
($i+1) . ': ' . substr($par,0,7)},
$i+1) .
"&nbsp;</th>\n";
}
print "</tr></thead>\n<tbody>\n";
}

my $alternate = 1;
my $patchno = 0;
foreach my $line (@{$difftree}) {
Expand Down Expand Up @@ -2673,6 +2693,7 @@ sub git_difftree_body {
} # we should not encounter Unmerged (U) or Unknown (X) status
print "</tr>\n";
}
print "</tbody>" if $has_header;
print "</table>\n";
}

Expand Down

0 comments on commit 47598d7

Please sign in to comment.