diff options
author | Adam Roben <aroben@apple.com> | 2007-04-27 11:57:53 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-04-27 23:18:15 -0700 |
commit | 26e60160a074747fbe8866ddac4e0c7660c17ff6 (patch) | |
tree | 98b7553a7bd84994e1ad6839245fffa4791f5036 /git-svn.perl | |
parent | bb924cb331c143eaf92ba8d86b65caff15252543 (diff) | |
download | git-26e60160a074747fbe8866ddac4e0c7660c17ff6.tar.gz |
git-svn: Added 'find-rev' command
This patch adds a new 'find-rev' command to git-svn that lets you easily
translate between SVN revision numbers and git tree-ish.
Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-x | git-svn.perl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/git-svn.perl b/git-svn.perl index 7b5f8ab3be..4be8576894 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -141,6 +141,8 @@ my %cmd = ( 'color' => \$Git::SVN::Log::color, 'pager=s' => \$Git::SVN::Log::pager, } ], + 'find-rev' => [ \&cmd_find_rev, "Translate between SVN revision numbers and tree-ish", + { } ], 'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory", { 'merge|m|M' => \$_merge, 'verbose|v' => \$_verbose, @@ -428,6 +430,28 @@ sub cmd_dcommit { command_noisy(@finish, $gs->refname); } +sub cmd_find_rev { + my $revision_or_hash = shift; + my $result; + if ($revision_or_hash =~ /^r\d+$/) { + my $desired_revision = substr($revision_or_hash, 1); + my ($fh, $ctx) = command_output_pipe('rev-list', 'HEAD'); + while (my $hash = <$fh>) { + chomp($hash); + my (undef, $rev, undef) = cmt_metadata($hash); + if ($rev && $rev eq $desired_revision) { + $result = $hash; + last; + } + } + command_close_pipe($fh, $ctx); + } else { + my (undef, $rev, undef) = cmt_metadata($revision_or_hash); + $result = $rev; + } + print "$result\n" if $result; +} + sub cmd_rebase { command_noisy(qw/update-index --refresh/); my ($url, $rev, $uuid, $gs) = working_head_info('HEAD'); |