{"thread":{"id":"12003","subject":"[PATCH] [svn] Add `git svn blame' command","startedAt":"2008-02-10T04:51:08Z","lastAt":"2008-02-11T02:37:59Z","messageCount":2,"participants":["Tim Stoakes","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"68170","messageId":"1202619068-1404-1-git-send-email-tim@stoakes.net","threadId":"12003","inReplyTo":null,"subject":"[PATCH] [svn] Add `git svn blame' command","fromName":"Tim Stoakes","fromEmail":"tim@stoakes.net","sentAt":"2008-02-10T04:51:08Z","receivedAt":"2008-02-10T04:51:08Z","isPatch":true,"sender":{"key":"tim@stoakes.net","avatar":null},"body":"This command is identical to `git blame', but it shows SVN revision\nnumbers instead of git commit hashes.\n\nSigned-off-by: Tim Stoakes <tim@stoakes.net>\n---\n Documentation/git-svn.txt |    7 +++++++\n git-svn.perl              |   21 +++++++++++++++++++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex b1d527f..340f1be 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -161,6 +161,13 @@ New features:\n +\n Any other arguments are passed directly to `git log'\n \n+'blame'::\n+       Show what revision and author last modified each line of a file. This is\n+       identical to `git blame', but SVN revision numbers are shown instead of git\n+       commit hashes.\n++\n+All arguments are passed directly to `git blame'.\n+\n --\n 'find-rev'::\n \tWhen given an SVN revision number of the form 'rN', returns the\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7889cce..4437ed5 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -186,6 +186,9 @@ my %cmd = (\n \t\t    \"Show info about the latest SVN revision\n \t\t     on the current branch\",\n \t\t    { 'url' => \\$_url, } ],\n+\t'blame' => [ \\&Git::SVN::Log::cmd_blame,\n+\t            \"Show what revision and author last modified each line of a file\",\n+\t            {} ],\n );\n \n my $cmd;\n@@ -4448,6 +4451,24 @@ out:\n \tprint commit_log_separator unless $incremental || $oneline;\n }\n \n+sub cmd_blame {\n+\tmy $path = shift;\n+\n+\tconfig_pager();\n+\trun_pager();\n+\n+\tmy ($fh, $ctx) = command_output_pipe('blame', @_, $path);\n+\twhile (my $line = <$fh>) {\n+\t\tif ($line=~/^([[:xdigit:]]+)\\s/) {\n+\t\t\tmy (undef, $rev, undef) = ::cmt_metadata($1);\n+\t\t\t$rev = sprintf('%-10s', $rev);\n+\t\t\t$line=~s/^[[:xdigit:]]+(\\s)/$rev$1/;\n+\t\t}\n+\t\tprint $line;\n+\t}\n+\tcommand_close_pipe($fh, $ctx);\n+}\n+\n package Git::SVN::Migration;\n # these version numbers do NOT correspond to actual version numbers\n # of git nor git-svn.  They are just relative.\n-- \n1.5.4\n"},{"id":"68316","messageId":"20080211023712.GA18370@soma","threadId":"12003","inReplyTo":"1202619068-1404-1-git-send-email-tim@stoakes.net","subject":"Re: [PATCH] [svn] Add `git svn blame' command","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-02-11T02:37:59Z","receivedAt":"2008-02-11T02:37:59Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Thanks Tim,\n\nMinor fixes below:\n\n>From 1209255c50d5437da0b88796519bc2ab1b907c0a Mon Sep 17 00:00:00 2001\nFrom: Tim Stoakes <tim@stoakes.net>\nDate: Sun, 10 Feb 2008 15:21:08 +1030\nSubject: [PATCH] Add `git svn blame' command\n\nThis command is identical to `git blame', but it shows SVN revision\nnumbers instead of git commit hashes.\n\n[ew: support \"^initial commit\" and minor formatting fixes]\n\nSigned-off-by: Tim Stoakes <tim@stoakes.net>\nAcked-by: Eric Wong <normalperson@yhbt.net>\n---\n Documentation/git-svn.txt |    7 +++++++\n git-svn.perl              |   21 +++++++++++++++++++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex b1d527f..340f1be 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -161,6 +161,13 @@ New features:\n +\n Any other arguments are passed directly to `git log'\n \n+'blame'::\n+       Show what revision and author last modified each line of a file. This is\n+       identical to `git blame', but SVN revision numbers are shown instead of git\n+       commit hashes.\n++\n+All arguments are passed directly to `git blame'.\n+\n --\n 'find-rev'::\n \tWhen given an SVN revision number of the form 'rN', returns the\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 7889cce..05fb358 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -186,6 +186,9 @@ my %cmd = (\n \t\t    \"Show info about the latest SVN revision\n \t\t     on the current branch\",\n \t\t    { 'url' => \\$_url, } ],\n+\t'blame' => [ \\&Git::SVN::Log::cmd_blame,\n+\t            \"Show what revision and author last modified each line of a file\",\n+\t            {} ],\n );\n \n my $cmd;\n@@ -4448,6 +4451,24 @@ out:\n \tprint commit_log_separator unless $incremental || $oneline;\n }\n \n+sub cmd_blame {\n+\tmy $path = shift;\n+\n+\tconfig_pager();\n+\trun_pager();\n+\n+\tmy ($fh, $ctx) = command_output_pipe('blame', @_, $path);\n+\twhile (my $line = <$fh>) {\n+\t\tif ($line =~ /^\\^?([[:xdigit:]]+)\\s/) {\n+\t\t\tmy (undef, $rev, undef) = ::cmt_metadata($1);\n+\t\t\t$rev = sprintf('%-10s', $rev);\n+\t\t\t$line =~ s/^\\^?[[:xdigit:]]+(\\s)/$rev$1/;\n+\t\t}\n+\t\tprint $line;\n+\t}\n+\tcommand_close_pipe($fh, $ctx);\n+}\n+\n package Git::SVN::Migration;\n # these version numbers do NOT correspond to actual version numbers\n # of git nor git-svn.  They are just relative.\n-- \nEric Wong\n"}]}