git-svn: usability fixes for the 'git svn log' command
Similar in spirit to the recent dcommit change, we now look at 'HEAD' by default to look for a GIT_SVN_ID so the user won't have to pass -i <GIT_SVN_ID> argument. We are also more tolerant of of people passing bare remote names as a result (just $GIT_SVN_ID without the -i) Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Feb 13, 2007 at 17:09 UTC
3bc718ba66f8b101b4017e778138660d66829312
1 file changed
+20
-3
git-svn.perl
+20
-3
@@ -3033,8 +3033,25 @@ sub log_use_color {
3033
}
3034
3035
sub git_svn_log_cmd {
3036
- my ($r_min, $r_max) = @_;
3037
- my $gs = Git::SVN->_new;
3036
+ my ($r_min, $r_max, @args) = @_;
3037
+ my $head = 'HEAD';
3038
+ foreach my $x (@args) {
3039
+ last if $x eq '--';
3040
+ next unless ::verify_ref("$x^0");
3041
+ $head = $x;
3042
+ last;
3043
+ }
3044
+
3045
+ my $url;
3046
+ my ($fh, $ctx) = command_output_pipe('rev-list', $head);
3047
+ while (<$fh>) {
3048
+ chomp;
3049
+ $url = (::cmt_metadata($_))[0];
3050
+ last if defined $url;
3051
+ }
3052
+ close $fh; # break the pipe
3053
+
3054
+ my $gs = Git::SVN->find_by_url($url) || Git::SVN->_new;
3055
my @cmd = (qw/log --abbrev-commit --pretty=raw --default/,
3056
$gs->refname);
3057
push @cmd, '-r' unless $non_recursive;
@@ -3227,7 +3244,7 @@ sub cmd_show_log {
3244
}
3245
3246
config_pager();
3230
- @args = (git_svn_log_cmd($r_min, $r_max), @args);
3247
+ @args = (git_svn_log_cmd($r_min, $r_max, @args), @args);
3248
my $log = command_output_pipe(@args);
3249
run_pager();
3250
my (@k, $c, $d);