git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH 6/6] gitweb: Show combined diff for merge commits in 'commit' view
Date: Mon,  7 May 2007 01:10:08 +0200	[thread overview]
Message-ID: <11784930133424-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <11784930091585-git-send-email-jnareb@gmail.com>

When commit shown is a merge commit (has more than one parent),
display combined difftree output (result of git-diff-tree -c).
Earlier (since commit 549ab4a30703012ff3a12b5455d319216805a8db)
difftree output (against first parent) was not printed for merges.

Examples of non-trivial merges:
  5bac4a671907604b5fb4e24ff682d5b0e8431931 (includes rename)
  addafaf92eeb86033da91323d0d3ad7a496dae83 (five parents)
  95f97567c1887d77f3a46b42d8622c76414d964d (evil merge)

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
The same note as for the patch before apply: for trivial merges there
is no difftree output. But for 'commit' view it doesn't matter much
because there was no difftree output at all for merges.

I plan to add HTML diffstat (using divs with set background color and
set width for bar graph for diff stats) for merges for 'commit' view
(diffstat to first parent, aka. "damages"), and text diffstat for
'commitdiff_plain' view. It would be controlled by new %feature.
But if somebody else want to implement this, feel free.


Examples are included to make it possible to check combined diff
output in gitweb: the sha1 of commits should be turned into
hyperlinks (committags support), and you can click on them to go to
'commit' view.

 gitweb/gitweb.perl |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index c0e2473..53e6dce 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -4026,14 +4026,13 @@ sub git_commit {
 		$parent = "--root";
 	}
 	my @difftree;
-	if (@$parents <= 1) {
-		# difftree output is not printed for merges
-		open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
-			@diff_opts, $parent, $hash, "--"
-			or die_error(undef, "Open git-diff-tree failed");
-		@difftree = map { chomp; $_ } <$fd>;
-		close $fd or die_error(undef, "Reading git-diff-tree failed");
-	}
+	open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
+		@diff_opts, 
+		(@$parents <= 1 ? $parent : '-c'),
+		$hash, "--"
+		or die_error(undef, "Open git-diff-tree failed");
+	@difftree = map { chomp; $_ } <$fd>;
+	close $fd or die_error(undef, "Reading git-diff-tree failed");
 
 	# non-textual hash id's can be cached
 	my $expires;
@@ -4111,10 +4110,7 @@ sub git_commit {
 	git_print_log($co{'comment'});
 	print "</div>\n";
 
-	if (@$parents <= 1) {
-		# do not output difftree/whatchanged for merges
-		git_difftree_body(\@difftree, $hash, $parent);
-	}
+	git_difftree_body(\@difftree, $hash, @$parents);
 
 	git_footer_html();
 }
-- 
1.5.1.3

  parent reply	other threads:[~2007-05-06 23:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-06 23:10 [PATCH 0/6] gitweb: Add combined diff support Jakub Narebski
2007-05-06 23:10 ` [PATCH 1/6] gitweb: Add parsing of raw combined diff format to parse_difftree_raw_line Jakub Narebski
2007-05-06 23:10 ` [PATCH 2/6] gitweb: Add combined diff support to git_difftree_body Jakub Narebski
2007-05-06 23:10 ` [PATCH 3/6] gitweb: Add combined diff support to git_patchset_body Jakub Narebski
2007-05-06 23:10 ` [PATCH 4/6] gitweb: Make it possible to use pre-parsed info in git_difftree_body Jakub Narebski
2007-05-06 23:10 ` [PATCH 5/6] gitweb: Show combined diff for merge commits in 'commitdiff' view Jakub Narebski
2007-05-06 23:10 ` Jakub Narebski [this message]
2007-05-06 23:10 ` [PATCH 7/6] todo: Remove "Gitweb diff on merge commits" entry Jakub Narebski
2007-05-08  1:31 ` [PATCH 0/6] gitweb: Add combined diff support Junio C Hamano
2007-05-08  1:50   ` Jakub Narebski
2007-05-16 22:05 ` [PATCH 7/6] gitweb: Empty patch for merge means trivial merge, not no differences Jakub Narebski
2007-05-16 22:08   ` Junio C Hamano

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=11784930133424-git-send-email-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).