diff options
author | Tim Stoakes <tim@stoakes.net> | 2008-02-10 15:21:08 +1030 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-11 13:23:14 -0800 |
commit | 6fb5375ede25629c23ba2129b48f143e1942e755 (patch) | |
tree | c3ddbcd8399db069cfe40d7c33759e8c6f70f8d2 /git-svn.perl | |
parent | 04f32cf1b31717bf0b7cbbc00783a4107cc19cfd (diff) | |
download | git-6fb5375ede25629c23ba2129b48f143e1942e755.tar.gz |
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>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-x | git-svn.perl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/git-svn.perl b/git-svn.perl index 7889ccea7a..05fb3582d9 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. |