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] gitweb: Create special from-file/to-file header for combined diff
Date: Mon, 28 May 2007 01:16:17 +0200	[thread overview]
Message-ID: <11803077803470-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <11803077792064-git-send-email-jnareb@gmail.com>

Instead of using default, diff(1) like from-file/to-file header for
combined diff (for a merge commit), which looks like:

  --- a/git-gui/git-gui.sh
  +++ b/_git-gui/git-gui.sh_

(where _link_ denotes [hidden] hyperlink), create from-file(n)/to-file
header, using n/file for each or parents, e.g.:

  --- 1/_git-gui/git-gui.sh_
  --- 2/_git-gui.sh_
  +++ b/_git-gui/git-gui.sh_

Test it on one of merge commits involving rename, e.g.
  95f97567c1887d77f3a46b42d8622c76414d964d (rename at top)
  5bac4a671907604b5fb4e24ff682d5b0e8431931 (file from one branch)

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 795af92..f73f184 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1045,17 +1045,33 @@ sub format_diff_from_to_header {
 	#assert($line =~ m/^---/) if DEBUG;
 	# no extra formatting "^--- /dev/null"
 	if ($line =~ m!^--- "?a/!) {
-		if (!$diffinfo->{'nparents'} && # multiple 'from'
-		    $from->{'href'}) {
-			$line = '--- a/' .
-			        $cgi->a({-href=>$from->{'href'}, -class=>"path"},
-			                esc_path($from->{'file'}));
+		if (!$diffinfo->{'nparents'}) {
+			if ($from->{'href'}) {
+				$line = '--- a/' .
+				        $cgi->a({-href=>$from->{'href'}, -class=>"path"},
+				                esc_path($from->{'file'}));
+			} else {
+				$line = '--- a/' .
+				        esc_path($from->{'file'});
+			}
+			$result .= qq!<div class="diff from_file">$line</div>\n!;
 		} else {
-			$line = '--- a/' .
-			        esc_path($from->{'file'});
+			for (my $i = 0; $i < $diffinfo->{'nparents'}; $i++) {
+				if ($from->{'href'}[$i]) {
+					$result .= qq!<div class="diff from_file">--- ! .
+					           ($i+1) . "/" .
+					           $cgi->a({-href=>$from->{'href'}[$i], -class=>"path"},
+					                   esc_path($from->{'file'}[$i])) .
+					           qq!</div>\n!;
+				} else {
+					$result .= qq!<div class="diff from_file">--- /dev/null</div>\n!;
+				}
+			}
 		}
+	} else {
+		$result .= qq!<div class="diff from_file">$line</div>\n!;
 	}
-	$result .= qq!<div class="diff from_file">$line</div>\n!;
+
 
 	$line = $to_line;
 	#assert($line =~ m/^\+\+\+/) if DEBUG;
-- 
1.5.2

  reply	other threads:[~2007-05-27 23:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 23:16 [PATCH] gitweb: Split git_patchset_body into separate subroutines Jakub Narebski
2007-05-27 23:16 ` [RFC/PATCH] gitweb: Create special from-file/to-file header for combined diff Jakub Narebski
2007-05-27 23:16   ` Jakub Narebski [this message]
2007-05-27 23:33     ` [PATCH] " Jakub Narebski
2007-05-28  1:43   ` [RFC/PATCH] " Junio C Hamano
2007-05-28  6:50     ` Jakub Narebski
2007-05-28 13:29       ` Petr Baudis
2007-05-28 14:22         ` Jakub Narebski

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=11803077803470-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).