Skip to content

Commit

Permalink
Add `git svn blame' command
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Eric Wong <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Tim Stoakes authored and gitster committed Feb 11, 2008
1 parent 04f32cf commit 6fb5375
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ BEGIN
"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;
Expand Down Expand Up @@ -4448,6 +4451,24 @@ sub cmd_show_log {
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.
Expand Down

0 comments on commit 6fb5375

Please sign in to comment.