@matheusbsbs / matheus-bagliano / commits / 74a31a100a
Fork 0

git-svn: log command fixes

Change the --verbose flag to more closely match svn. I was somehow under the impression that --summary included --raw diff output, but I was wrong. We now pass -r --raw --name-status as arguments if passed -v/--verbose. -r (recursive) is passed by default, since users usually want it, and accepting it causes difficulty with the -r<revision> option used by svn users. A --non-recursive switch has been added to disable this. Of course, --summary, --raw, -p and any other git-log options can still be passed directly (without --name-status). Also, several warnings about referencing undefined variables have been fixed. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Oct 11, 2006 at 11:53 UTC 74a31a100ab96c37ebec5c04e1822bb2681bc345
1 file changed +25 -7
git-svn.perl
+25 -7
@@ -52,7 +52,7 @@ my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
52 $_template, $_shared, $_no_default_regex, $_no_graft_copy,
53 $_limit, $_verbose, $_incremental, $_oneline, $_l_fmt, $_show_commit,
54 $_version, $_upgrade, $_authors, $_branch_all_refs, @_opt_m,
55 - $_merge, $_strategy, $_dry_run, $_ignore_nodate);
55 + $_merge, $_strategy, $_dry_run, $_ignore_nodate, $_non_recursive);
56 my (@_branch_from, %tree_map, %users, %rusers, %equiv);
57 my ($_svn_co_url_revs, $_svn_pg_peg_revs);
58 my @repo_path_split_cache;
@@ -114,6 +114,7 @@ my %cmd = (
114 'incremental' => \$_incremental,
115 'oneline' => \$_oneline,
116 'show-commit' => \$_show_commit,
117 + 'non-recursive' => \$_non_recursive,
118 'authors-file|A=s' => \$_authors,
119 } ],
120 'commit-diff' => [ \&commit_diff, 'Commit a diff between two trees',
@@ -752,13 +753,18 @@ sub show_log {
753 # ignore
754 } elsif (/^:\d{6} \d{6} $sha1_short/o) {
755 push @{$c->{raw}}, $_;
756 + } elsif (/^[ACRMDT]\t/) {
757 + # we could add $SVN_PATH here, but that requires
758 + # remote access at the moment (repo_path_split)...
759 + s#^([ACRMDT])\t# $1 #;
760 + push @{$c->{changed}}, $_;
761 } elsif (/^diff /) {
762 $d = 1;
763 push @{$c->{diff}}, $_;
764 } elsif ($d) {
765 push @{$c->{diff}}, $_;
766 } elsif (/^ (git-svn-id:.+)$/) {
761 - (undef, $c->{r}, undef) = extract_metadata($1);
767 + ($c->{url}, $c->{r}, undef) = extract_metadata($1);
768 } elsif (s/^ //) {
769 push @{$c->{l}}, $_;
770 }
@@ -850,7 +856,8 @@ sub git_svn_log_cmd {
856 my ($r_min, $r_max) = @_;
857 my @cmd = (qw/git-log --abbrev-commit --pretty=raw
858 --default/, "refs/remotes/$GIT_SVN");
853 - push @cmd, '--summary' if $_verbose;
859 + push @cmd, '-r' unless $_non_recursive;
860 + push @cmd, qw/--raw --name-status/ if $_verbose;
861 return @cmd unless defined $r_max;
862 if ($r_max == $r_min) {
863 push @cmd, '--max-count=1';
@@ -861,7 +868,7 @@ sub git_svn_log_cmd {
868 my ($c_min, $c_max);
869 $c_max = revdb_get($REVDB, $r_max);
870 $c_min = revdb_get($REVDB, $r_min);
864 - if ($c_min && $c_max) {
871 + if (defined $c_min && defined $c_max) {
872 if ($r_max > $r_max) {
873 push @cmd, "$c_min..$c_max";
874 } else {
@@ -2561,6 +2568,12 @@ sub show_commit {
2568 }
2569 }
2570
2571 +sub show_commit_changed_paths {
2572 + my ($c) = @_;
2573 + return unless $c->{changed};
2574 + print "Changed paths:\n", @{$c->{changed}};
2575 +}
2576 +
2577 sub show_commit_normal {
2578 my ($c) = @_;
2579 print '-' x72, "\nr$c->{r} | ";
@@ -2570,7 +2583,8 @@ sub show_commit_normal {
2583 my $nr_line = 0;
2584
2585 if (my $l = $c->{l}) {
2573 - while ($l->[$#$l] eq "\n" && $l->[($#$l - 1)] eq "\n") {
2586 + while ($l->[$#$l] eq "\n" && $#$l > 0
2587 + && $l->[($#$l - 1)] eq "\n") {
2588 pop @$l;
2589 }
2590 $nr_line = scalar @$l;
@@ -2582,11 +2596,15 @@ sub show_commit_normal {
2596 } else {
2597 $nr_line .= ' lines';
2598 }
2585 - print $nr_line, "\n\n";
2599 + print $nr_line, "\n";
2600 + show_commit_changed_paths($c);
2601 + print "\n";
2602 print $_ foreach @$l;
2603 }
2604 } else {
2589 - print "1 line\n\n";
2605 + print "1 line\n";
2606 + show_commit_changed_paths($c);
2607 + print "\n";
2608
2609 }
2610 foreach my $x (qw/raw diff/) {