git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Tim Stoakes <tim@stoakes.net>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] [svn] Add `git svn blame' command
Date: Sun, 10 Feb 2008 18:37:59 -0800	[thread overview]
Message-ID: <20080211023712.GA18370@soma> (raw)
In-Reply-To: <1202619068-1404-1-git-send-email-tim@stoakes.net>

Thanks Tim,

Minor fixes below:

>From 1209255c50d5437da0b88796519bc2ab1b907c0a Mon Sep 17 00:00:00 2001
From: Tim Stoakes <tim@stoakes.net>
Date: Sun, 10 Feb 2008 15:21:08 +1030
Subject: [PATCH] Add `git svn blame' command

This command is identical to `git blame', but it shows SVN revision
numbers instead of git commit hashes.

[ew: support "^initial commit" and minor formatting fixes]

Signed-off-by: Tim Stoakes <tim@stoakes.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
---
 Documentation/git-svn.txt |    7 +++++++
 git-svn.perl              |   21 +++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index b1d527f..340f1be 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -161,6 +161,13 @@ New features:
 +
 Any other arguments are passed directly to `git log'
 
+'blame'::
+       Show what revision and author last modified each line of a file. This is
+       identical to `git blame', but SVN revision numbers are shown instead of git
+       commit hashes.
++
+All arguments are passed directly to `git blame'.
+
 --
 'find-rev'::
 	When given an SVN revision number of the form 'rN', returns the
diff --git a/git-svn.perl b/git-svn.perl
index 7889cce..05fb358 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -186,6 +186,9 @@ my %cmd = (
 		    "Show info about the latest SVN revision
 		     on the current branch",
 		    { 'url' => \$_url, } ],
+	'blame' => [ \&Git::SVN::Log::cmd_blame,
+	            "Show what revision and author last modified each line of a file",
+	            {} ],
 );
 
 my $cmd;
@@ -4448,6 +4451,24 @@ out:
 	print commit_log_separator unless $incremental || $oneline;
 }
 
+sub cmd_blame {
+	my $path = shift;
+
+	config_pager();
+	run_pager();
+
+	my ($fh, $ctx) = command_output_pipe('blame', @_, $path);
+	while (my $line = <$fh>) {
+		if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
+			my (undef, $rev, undef) = ::cmt_metadata($1);
+			$rev = sprintf('%-10s', $rev);
+			$line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
+		}
+		print $line;
+	}
+	command_close_pipe($fh, $ctx);
+}
+
 package Git::SVN::Migration;
 # these version numbers do NOT correspond to actual version numbers
 # of git nor git-svn.  They are just relative.
-- 
Eric Wong

      reply	other threads:[~2008-02-11  2:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10  4:51 [PATCH] [svn] Add `git svn blame' command Tim Stoakes
2008-02-11  2:37 ` Eric Wong [this message]

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=20080211023712.GA18370@soma \
    --to=normalperson@yhbt.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tim@stoakes.net \
    /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).