Merge branch 'lh/svn-first-parent'
authorJunio C Hamano <gitster@pobox.com>
Sat, 15 Sep 2007 05:37:43 +0000 (22:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 15 Sep 2007 05:37:43 +0000 (22:37 -0700)
* lh/svn-first-parent:
git-svn: always use --first-parent
git-svn: add support for --first-parent

1  2 
git-svn.perl
diff --combined git-svn.perl
index f8181609f942b22dc95992740326e8b5788feba5,badcd33c2cd48c29f4a6662508953f732f9aaba0..288d32cb160fcf1b7fdb8bbce9d800d971ced345
@@@ -124,7 -124,8 +124,8 @@@ my %cmd = 
                        "Set an SVN repository to a git tree-ish",
                        { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
        'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
-                       { 'revision|r=i' => \$_revision } ],
+                       { 'revision|r=i' => \$_revision
+                       } ],
        'multi-fetch' => [ \&cmd_multi_fetch,
                           "Deprecated alias for $0 fetch --all",
                           { 'revision|r=s' => \$_revision, %fc_opts } ],
                          'non-recursive' => \$Git::SVN::Log::non_recursive,
                          'authors-file|A=s' => \$_authors,
                          'color' => \$Git::SVN::Log::color,
-                         'pager=s' => \$Git::SVN::Log::pager,
+                         '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,
@@@ -811,7 -812,8 +812,8 @@@ sub cmt_metadata 
  
  sub working_head_info {
        my ($head, $refs) = @_;
-       my ($fh, $ctx) = command_output_pipe('log', '--no-color', $head);
+       my @args = ('log', '--no-color', '--first-parent');
+       my ($fh, $ctx) = command_output_pipe(@args, $head);
        my $hash;
        my %max;
        while (<$fh>) {
  
  sub read_commit_parents {
        my ($parents, $c) = @_;
 -      my ($fh, $ctx) = command_output_pipe(qw/cat-file commit/, $c);
 -      while (<$fh>) {
 -              chomp;
 -              last if '';
 -              /^parent ($sha1)/ or next;
 -              push @{$parents->{$c}}, $1;
 -      }
 -      close $fh; # break the pipe
 +      chomp(my $p = command_oneline(qw/rev-list --parents -1/, $c));
 +      $p =~ s/^($c)\s*// or die "rev-list --parents -1 $c failed!\n";
 +      @{$parents->{$c}} = split(/ /, $p);
  }
  
  sub linearize_history {
@@@ -3008,7 -3015,7 +3010,7 @@@ package Git::SVN::Ra
  use vars qw/@ISA $config_dir $_log_window_size/;
  use strict;
  use warnings;
 -my ($can_do_switch, %ignored_err, $RA);
 +my ($ra_invalid, $can_do_switch, %ignored_err, $RA);
  
  BEGIN {
        # enforce temporary pool usage for some simple functions
@@@ -3169,11 -3176,7 +3171,11 @@@ sub gs_do_switch 
                        $self->{url} = $full_url;
                        $reparented = 1;
                } else {
 +                      $_[0] = undef;
 +                      $self = undef;
 +                      $RA = undef;
                        $ra = Git::SVN::Ra->new($full_url);
 +                      $ra_invalid = 1;
                }
        }
        $ra ||= $self;
@@@ -3233,7 -3236,6 +3235,7 @@@ sub gs_fetch_loop_common 
        my $inc = $_log_window_size;
        my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc);
        my $longest_path = longest_common_path($gsv, $globs);
 +      my $ra_url = $self->{url};
        while (1) {
                my %revs;
                my $err;
                                        "$g->{t}-maxRev";
                                Git::SVN::tmp_config($k, $r);
                        }
 +                      if ($ra_invalid) {
 +                              $_[0] = undef;
 +                              $self = undef;
 +                              $RA = undef;
 +                              $self = Git::SVN::Ra->new($ra_url);
 +                              $ra_invalid = undef;
 +                      }
                }
                # pre-fill the .rev_db since it'll eventually get filled in
                # with '0' x40 if something new gets committed