@matheusbsbs / matheus-bagliano / commits / 6fb5375ede
Fork 0

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tim Stoakes committed Feb 10, 2008 at 15:21 UTC 6fb5375ede25629c23ba2129b48f143e1942e755
2 files changed +28
Documentation/git-svn.txt
+7
@@ -161,6 +161,13 @@ New features:
161 +
162 Any other arguments are passed directly to `git log'
163
164 +'blame'::
165 + Show what revision and author last modified each line of a file. This is
166 + identical to `git blame', but SVN revision numbers are shown instead of git
167 + commit hashes.
168 ++
169 +All arguments are passed directly to `git blame'.
170 +
171 --
172 'find-rev'::
173 When given an SVN revision number of the form 'rN', returns the
git-svn.perl
+21
@@ -186,6 +186,9 @@ my %cmd = (
186 "Show info about the latest SVN revision
187 on the current branch",
188 { 'url' => \$_url, } ],
189 + 'blame' => [ \&Git::SVN::Log::cmd_blame,
190 + "Show what revision and author last modified each line of a file",
191 + {} ],
192 );
193
194 my $cmd;
@@ -4448,6 +4451,24 @@ out:
4451 print commit_log_separator unless $incremental || $oneline;
4452 }
4453
4454 +sub cmd_blame {
4455 + my $path = shift;
4456 +
4457 + config_pager();
4458 + run_pager();
4459 +
4460 + my ($fh, $ctx) = command_output_pipe('blame', @_, $path);
4461 + while (my $line = <$fh>) {
4462 + if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
4463 + my (undef, $rev, undef) = ::cmt_metadata($1);
4464 + $rev = sprintf('%-10s', $rev);
4465 + $line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
4466 + }
4467 + print $line;
4468 + }
4469 + command_close_pipe($fh, $ctx);
4470 +}
4471 +
4472 package Git::SVN::Migration;
4473 # these version numbers do NOT correspond to actual version numbers
4474 # of git nor git-svn. They are just relative.