Skip to content

Commit 6fb5375

Browse files
Tim Stoakesgitster
authored andcommitted
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 <[email protected]> Acked-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04f32cf commit 6fb5375

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Documentation/git-svn.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ New features:
161161
+
162162
Any other arguments are passed directly to `git log'
163163

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+
164171
--
165172
'find-rev'::
166173
When given an SVN revision number of the form 'rN', returns the

git-svn.perl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ BEGIN
186186
"Show info about the latest SVN revision
187187
on the current branch",
188188
{ 'url' => \$_url, } ],
189+
'blame' => [ \&Git::SVN::Log::cmd_blame,
190+
"Show what revision and author last modified each line of a file",
191+
{} ],
189192
);
190193

191194
my $cmd;
@@ -4448,6 +4451,24 @@ sub cmd_show_log {
44484451
print commit_log_separator unless $incremental || $oneline;
44494452
}
44504453

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+
44514472
package Git::SVN::Migration;
44524473
# these version numbers do NOT correspond to actual version numbers
44534474
# of git nor git-svn. They are just relative.

0 commit comments

Comments
 (0)