From b4657e7759fa5f3b1ef09d147c2fd0254f8fcb2d Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 28 Aug 2006 14:48:14 +0200 Subject: [PATCH] gitweb: Add diff tree, with links to patches, to commitdiff view Added/uncommented git_difftree_body invocation in git_commitdiff. Added anchors (via 'id' attribute) to patches in patchset. git_difftree_body is modified to link to patch anchor when called from git_commitdiff, instead of link to blobdiff. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 71 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 24c2fe2a1..1b352cbb2 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1460,6 +1460,7 @@ sub git_difftree_body { print "\n"; my $alternate = 0; + my $patchno = 0; foreach my $line (@{$difftree}) { my %diff = parse_difftree_raw_line($line); @@ -1500,8 +1501,14 @@ sub git_difftree_body { "\n"; + "blob"); + if ($action == "commitdiff") { + # link to patch + $patchno++; + print " | " . + $cgi->a({-href => "#patch$patchno"}, "patch"); + } + print "\n"; } elsif ($diff{'status'} eq "D") { # deleted my $mode_chng = "[deleted $from_file_type]"; @@ -1515,8 +1522,14 @@ sub git_difftree_body { $cgi->a({-href => href(action=>"blob", hash=>$diff{'from_id'}, hash_base=>$parent, file_name=>$diff{'file'})}, "blob") . - " | " . - $cgi->a({-href => href(action=>"history", hash_base=>$parent, + " | "; + if ($action == "commitdiff") { + # link to patch + $patchno++; + print " | " . + $cgi->a({-href => "#patch$patchno"}, "patch"); + } + print $cgi->a({-href => href(action=>"history", hash_base=>$parent, file_name=>$diff{'file'})}, "history") . "\n"; @@ -1552,16 +1565,23 @@ sub git_difftree_body { print "\n" . "\n" . "\n"; @@ -1629,7 +1656,7 @@ sub git_patchset_body { # first patch in patchset $patch_found = 1; } - print "
\n"; + print "
\n"; if (ref($difftree->[$patch_idx]) eq "HASH") { $diffinfo = $difftree->[$patch_idx]; @@ -2977,8 +3004,8 @@ TEXT # write patch if ($format eq 'html') { - #git_difftree_body(\@difftree, $hash, $hash_parent); - #print "
\n"; + git_difftree_body(\@difftree, $hash, $hash_parent); + print "
\n"; git_patchset_body($fd, \@difftree, $hash, $hash_parent); close $fd; -- 2.30.2
" . $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'}, hash_base=>$hash, file_name=>$diff{'file'})}, - "blob") . - "$mode_chnge" . - $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'}, - hash_base=>$hash, file_name=>$diff{'file'})}, - "blob"); + $cgi->a({-href => href(action=>"blob", hash=>$diff{'to_id'}, + hash_base=>$hash, file_name=>$diff{'file'})}, + "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, hash_parent_base=>$parent, - file_name=>$diff{'file'})}, - "diff"); + if ($action == "commitdiff") { + # link to patch + $patchno++; + print " | " . + $cgi->a({-href => "#patch$patchno"}, "patch"); + } else { + 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'})}, + "diff"); + } } print " | " . $cgi->a({-href => href(action=>"history", @@ -1591,12 +1611,19 @@ sub git_difftree_body { hash=>$diff{'to_id'}, file_name=>$diff{'to_file'})}, "blob"); if ($diff{'to_id'} ne $diff{'from_id'}) { - 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{'to_file'}, file_parent=>$diff{'from_file'})}, - "diff"); + if ($action == "commitdiff") { + # link to patch + $patchno++; + print " | " . + $cgi->a({-href => "#patch$patchno"}, "patch"); + } else { + 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{'to_file'}, file_parent=>$diff{'from_file'})}, + "diff"); + } } print "