]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-svn.perl
git-svn: correctly handle boolean options via git-config
[thirdparty/git.git] / git-svn.perl
index 4288a05c166b0b75bba387c099daa8622fea487a..d792a62d7ca400145d57189b5ca8af97978fef4d 100755 (executable)
@@ -69,8 +69,8 @@ my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
        $_limit, $_verbose, $_incremental, $_oneline, $_l_fmt, $_show_commit,
        $_version, $_upgrade, $_authors, $_branch_all_refs, @_opt_m,
        $_merge, $_strategy, $_dry_run, $_ignore_nodate, $_non_recursive,
-       $_username, $_config_dir, $_no_auth_cache, $_xfer_delta,
-       $_pager, $_color);
+       $_username, $_config_dir, $_no_auth_cache,
+       $_pager, $_color, $_prefix);
 my (@_branch_from, %tree_map, %users, %rusers, %equiv);
 my ($_svn_can_do_switch);
 my @repo_path_split_cache;
@@ -102,7 +102,7 @@ my %cmt_opts = ( 'edit|e' => \$_edit,
 );
 
 my %cmd = (
-       fetch => [ \&fetch, "Download new revisions from SVN",
+       fetch => [ \&cmd_fetch, "Download new revisions from SVN",
                        { 'revision|r=s' => \$_revision, %fc_opts } ],
        init => [ \&init, "Initialize a repo for tracking" .
                          " (requires URL argument)",
@@ -134,6 +134,7 @@ my %cmd = (
                         'username=s' => \$_username,
                         'config-dir=s' => \$_config_dir,
                         'no-auth-cache' => \$_no_auth_cache,
+                        'prefix=s' => \$_prefix,
                        } ],
        'multi-fetch' => [ \&multi_fetch,
                        'Fetch multiple trees (like git-svnimport)',
@@ -216,7 +217,7 @@ information.
 }
 
 sub version {
-       print "git-svn version $VERSION\n";
+       print "git-svn version $VERSION (svn $SVN::Core::VERSION)\n";
        exit 0;
 }
 
@@ -285,7 +286,7 @@ sub init {
 
        $SVN_URL = $url;
        unless (-d $GIT_DIR) {
-               my @init_db = ('init-db');
+               my @init_db = ('init');
                push @init_db, "--template=$_template" if defined $_template;
                push @init_db, "--shared" if defined $_shared;
                command_noisy(@init_db);
@@ -293,6 +294,10 @@ sub init {
        setup_git_svn();
 }
 
+sub cmd_fetch {
+       fetch_child_id($GIT_SVN, @_);
+}
+
 sub fetch {
        check_upgrade_needed();
        $SVN_URL ||= file_to_s("$GIT_SVN_DIR/info/url");
@@ -512,15 +517,15 @@ sub dcommit {
        }
        return if $_dry_run;
        fetch();
-       my @diff = command('diff-tree', $head, $gs, '--');
+       my @diff = command('diff-tree', 'HEAD', $gs, '--');
        my @finish;
        if (@diff) {
                @finish = qw/rebase/;
                push @finish, qw/--merge/ if $_merge;
                push @finish, "--strategy=$_strategy" if $_strategy;
-               print STDERR "W: $head and $gs differ, using @finish:\n", @diff;
+               print STDERR "W: HEAD and $gs differ, using @finish:\n", @diff;
        } else {
-               print "No changes between current $head and $gs\n",
+               print "No changes between current HEAD and $gs\n",
                      "Resetting to the latest $gs\n";
                @finish = qw/reset --mixed/;
        }
@@ -532,7 +537,7 @@ sub show_ignore {
        my $repo;
        $SVN ||= libsvn_connect($SVN_URL);
        my $r = defined $_revision ? $_revision : $SVN->get_latest_revnum;
-       libsvn_traverse_ignore(\*STDOUT, $SVN->{svn_path}, $r);
+       libsvn_traverse_ignore(\*STDOUT, '', $r);
 }
 
 sub graft_branches {
@@ -571,31 +576,29 @@ sub graft_branches {
 
 sub multi_init {
        my $url = shift;
-       $_trunk ||= 'trunk';
-       $_trunk =~ s#/+$##;
-       $url =~ s#/+$## if $url;
-       if ($_trunk !~ m#^[a-z\+]+://#) {
-               $_trunk = '/' . $_trunk if ($_trunk !~ m#^/#);
-               unless ($url) {
-                       print STDERR "E: '$_trunk' is not a complete URL ",
-                               "and a separate URL is not specified\n";
-                       exit 1;
-               }
-               $_trunk = $url . $_trunk;
-       }
-       my $ch_id;
-       if ($GIT_SVN eq 'git-svn') {
-               $ch_id = 1;
-               $GIT_SVN = $ENV{GIT_SVN_ID} = 'trunk';
+       unless (defined $_trunk || defined $_branches || defined $_tags) {
+               usage(1);
        }
-       init_vars();
-       unless (-d $GIT_SVN_DIR) {
-               print "GIT_SVN_ID set to 'trunk' for $_trunk\n" if $ch_id;
-               init($_trunk);
-               command_noisy('repo-config', 'svn.trunk', $_trunk);
+       if (defined $_trunk) {
+               my $trunk_url = complete_svn_url($url, $_trunk);
+               my $ch_id;
+               if ($GIT_SVN eq 'git-svn') {
+                       $ch_id = 1;
+                       $GIT_SVN = $ENV{GIT_SVN_ID} = 'trunk';
+               }
+               init_vars();
+               unless (-d $GIT_SVN_DIR) {
+                       if ($ch_id) {
+                               print "GIT_SVN_ID set to 'trunk' for ",
+                                     "$trunk_url ($_trunk)\n";
+                       }
+                       init($trunk_url);
+                       command_noisy('config', 'svn.trunk', $trunk_url);
+               }
        }
-       complete_url_ls_init($url, $_branches, '--branches/-b', '');
-       complete_url_ls_init($url, $_tags, '--tags/-t', 'tags/');
+       $_prefix = '' unless defined $_prefix;
+       complete_url_ls_init($url, $_branches, '--branches/-b', $_prefix);
+       complete_url_ls_init($url, $_tags, '--tags/-t', $_prefix . 'tags/');
 }
 
 sub multi_fetch {
@@ -678,7 +681,7 @@ sub show_log {
                process_commit($_, $r_min, $r_max) foreach reverse @k;
        }
 out:
-       eval { command_close_pipe($log) };
+       close $log;
        print '-' x72,"\n" unless $_incremental || $_oneline;
 }
 
@@ -769,22 +772,22 @@ sub log_use_color {
        return 1 if $_color;
        my ($dc, $dcvar);
        $dcvar = 'color.diff';
-       $dc = `git-repo-config --get $dcvar`;
+       $dc = `git-config --get $dcvar`;
        if ($dc eq '') {
                # nothing at all; fallback to "diff.color"
                $dcvar = 'diff.color';
-               $dc = `git-repo-config --get $dcvar`;
+               $dc = `git-config --get $dcvar`;
        }
        chomp($dc);
        if ($dc eq 'auto') {
                my $pc;
-               $pc = `git-repo-config --get color.pager`;
+               $pc = `git-config --get color.pager`;
                if ($pc eq '') {
                        # does not have it -- fallback to pager.color
-                       $pc = `git-repo-config --bool --get pager.color`;
+                       $pc = `git-config --bool --get pager.color`;
                }
                else {
-                       $pc = `git-repo-config --bool --get color.pager`;
+                       $pc = `git-config --bool --get color.pager`;
                        if ($?) {
                                $pc = 'false';
                        }
@@ -797,7 +800,7 @@ sub log_use_color {
        }
        return 0 if $dc eq 'never';
        return 1 if $dc eq 'always';
-       chomp($dc = `git-repo-config --bool --get $dcvar`);
+       chomp($dc = `git-config --bool --get $dcvar`);
        return ($dc eq 'true');
 }
 
@@ -839,7 +842,6 @@ sub fetch_child_id {
        my $ref = "$GIT_DIR/refs/remotes/$id";
        defined(my $pid = open my $fh, '-|') or croak $!;
        if (!$pid) {
-               $_repack = undef;
                $GIT_SVN = $ENV{GIT_SVN_ID} = $id;
                init_vars();
                fetch(@_);
@@ -847,7 +849,7 @@ sub fetch_child_id {
        }
        while (<$fh>) {
                print $_;
-               check_repack() if (/^r\d+ = $sha1/);
+               check_repack() if (/^r\d+ = $sha1/o);
        }
        close $fh or croak $?;
 }
@@ -872,29 +874,34 @@ sub rec_fetch {
        }
 }
 
+sub complete_svn_url {
+       my ($url, $path) = @_;
+       $path =~ s#/+$##;
+       $url =~ s#/+$## if $url;
+       if ($path !~ m#^[a-z\+]+://#) {
+               $path = '/' . $path if ($path !~ m#^/#);
+               if (!defined $url || $url !~ m#^[a-z\+]+://#) {
+                       fatal("E: '$path' is not a complete URL ",
+                             "and a separate URL is not specified\n");
+               }
+               $path = $url . $path;
+       }
+       return $path;
+}
+
 sub complete_url_ls_init {
-       my ($url, $var, $switch, $pfx) = @_;
-       unless ($var) {
+       my ($url, $path, $switch, $pfx) = @_;
+       unless ($path) {
                print STDERR "W: $switch not specified\n";
                return;
        }
-       $var =~ s#/+$##;
-       if ($var !~ m#^[a-z\+]+://#) {
-               $var = '/' . $var if ($var !~ m#^/#);
-               unless ($url) {
-                       print STDERR "E: '$var' is not a complete URL ",
-                               "and a separate URL is not specified\n";
-                       exit 1;
-               }
-               $var = $url . $var;
-       }
-       my @ls = libsvn_ls_fullurl($var);
-       my $old = $GIT_SVN;
+       my $full_url = complete_svn_url($url, $path);
+       my @ls = libsvn_ls_fullurl($full_url);
        defined(my $pid = fork) or croak $!;
        if (!$pid) {
-               foreach my $u (map { "$var/$_" } (grep m!/$!, @ls)) {
+               foreach my $u (map { "$full_url/$_" } (grep m!/$!, @ls)) {
                        $u =~ s#/+$##;
-                       if ($u !~ m!\Q$var\E/(.+)$!) {
+                       if ($u !~ m!\Q$full_url\E/(.+)$!) {
                                print STDERR "W: Unrecognized URL: $u\n";
                                die "This should never happen\n";
                        }
@@ -912,7 +919,7 @@ sub complete_url_ls_init {
        waitpid $pid, 0;
        croak $? if $?;
        my ($n) = ($switch =~ /^--(\w+)/);
-       command_noisy('repo-config', "svn.$n", $var);
+       command_noisy('config', "svn.$n", $full_url);
 }
 
 sub common_prefix {
@@ -1079,7 +1086,7 @@ sub graft_merge_msg {
        my ($grafts, $l_map, $u, $p, @re) = @_;
 
        my $x = $l_map->{$u}->{$p};
-       my $rl = rev_list_raw($x);
+       my $rl = rev_list_raw("refs/remotes/$x");
        while (my $c = next_rev_list_entry($rl)) {
                foreach my $re (@re) {
                        my (@br) = ($c->{m} =~ /$re/g);
@@ -1098,7 +1105,8 @@ sub read_uuid {
 
 sub verify_ref {
        my ($ref) = @_;
-       eval { command_oneline([ 'rev-parse', $ref ], { STDERR => 0 }) };
+       eval { command_oneline([ 'rev-parse', '--verify', $ref ],
+                              { STDERR => 0 }); };
 }
 
 sub repo_path_split {
@@ -1404,7 +1412,6 @@ sub git_commit {
 
        # this output is read via pipe, do not change:
        print "r$log_msg->{revision} = $commit\n";
-       check_repack();
        return $commit;
 }
 
@@ -1468,7 +1475,7 @@ sub map_tree_joins {
                                $seen{$commit} = 1;
                        }
                }
-               eval { command_close_pipe($pipe) };
+               close $pipe;
        }
 }
 
@@ -1587,7 +1594,7 @@ sub init_vars {
        %tree_map = ();
 }
 
-# convert GetOpt::Long specs for use by git-repo-config
+# convert GetOpt::Long specs for use by git-config
 sub read_repo_config {
        return unless -d $GIT_DIR;
        my $opts = shift;
@@ -1595,7 +1602,7 @@ sub read_repo_config {
                my $v = $opts->{$o};
                my ($key) = ($o =~ /^([a-z\-]+)/);
                $key =~ s/-//g;
-               my $arg = 'git-repo-config';
+               my $arg = 'git-config';
                $arg .= ' --int' if ($o =~ /[:=]i$/);
                $arg .= ' --bool' if ($o !~ /[:=][sfi]$/);
                if (ref $v eq 'ARRAY') {
@@ -1603,7 +1610,7 @@ sub read_repo_config {
                        @$v = @tmp if @tmp;
                } else {
                        chomp(my $tmp = `$arg --get svn.$key`);
-                       if ($tmp && !($arg =~ / --bool / && $tmp eq 'false')) {
+                       if ($tmp && !($arg =~ / --bool/ && $tmp eq 'false')) {
                                $$v = $tmp;
                        }
                }
@@ -1662,7 +1669,7 @@ sub write_grafts {
                                last unless /^\S/;
                        }
                }
-               eval { command_close_pipe($ch) }; # breaking the pipe
+               close $ch; # breaking the pipe
 
                # if real parents are the only ones in the grafts, drop it
                next if join(' ',sort keys %$p) eq join(' ',sort keys %x);
@@ -1759,7 +1766,7 @@ sub get_commit_time {
                } elsif ($tz =~ s/^\-//) {
                        $s -= tz_to_s_offset($tz);
                }
-               eval { command_close_pipe($fh) };
+               close $fh;
                return $s;
        }
        die "Can't get commit time for commit: $cmt\n";
@@ -1911,7 +1918,8 @@ sub _simple_prompt {
        $default_username = $_username if defined $_username;
        if (defined $default_username && length $default_username) {
                if (defined $realm && length $realm) {
-                       print "Authentication realm: $realm\n";
+                       print STDERR "Authentication realm: $realm\n";
+                       STDERR->flush;
                }
                $cred->username($default_username);
        } else {
@@ -1926,36 +1934,38 @@ sub _simple_prompt {
 sub _ssl_server_trust_prompt {
        my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
        $may_save = undef if $_no_auth_cache;
-       print "Error validating server certificate for '$realm':\n";
+       print STDERR "Error validating server certificate for '$realm':\n";
        if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
-               print " - The certificate is not issued by a trusted ",
+               print STDERR " - The certificate is not issued by a trusted ",
                      "authority. Use the\n",
                      "   fingerprint to validate the certificate manually!\n";
        }
        if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
-               print " - The certificate hostname does not match.\n";
+               print STDERR " - The certificate hostname does not match.\n";
        }
        if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
-               print " - The certificate is not yet valid.\n";
+               print STDERR " - The certificate is not yet valid.\n";
        }
        if ($failures & $SVN::Auth::SSL::EXPIRED) {
-               print " - The certificate has expired.\n";
+               print STDERR " - The certificate has expired.\n";
        }
        if ($failures & $SVN::Auth::SSL::OTHER) {
-               print " - The certificate has an unknown error.\n";
+               print STDERR " - The certificate has an unknown error.\n";
        }
-       printf( "Certificate information:\n".
+       printf STDERR
+               "Certificate information:\n".
                " - Hostname: %s\n".
                " - Valid: from %s until %s\n".
                " - Issuer: %s\n".
                " - Fingerprint: %s\n",
                map $cert_info->$_, qw(hostname valid_from valid_until
-                                      issuer_dname fingerprint) );
+                                      issuer_dname fingerprint);
        my $choice;
 prompt:
-       print $may_save ?
+       print STDERR $may_save ?
              "(R)eject, accept (t)emporarily or accept (p)ermanently? " :
              "(R)eject or accept (t)emporarily? ";
+       STDERR->flush;
        $choice = lc(substr(<STDIN> || 'R', 0, 1));
        if ($choice =~ /^t$/i) {
                $cred->may_save(undef);
@@ -1973,7 +1983,8 @@ prompt:
 sub _ssl_client_cert_prompt {
        my ($cred, $realm, $may_save, $pool) = @_;
        $may_save = undef if $_no_auth_cache;
-       print "Client certificate filename: ";
+       print STDERR "Client certificate filename: ";
+       STDERR->flush;
        chomp(my $filename = <STDIN>);
        $cred->cert_file($filename);
        $cred->may_save($may_save);
@@ -1992,13 +2003,14 @@ sub _username_prompt {
        my ($cred, $realm, $may_save, $pool) = @_;
        $may_save = undef if $_no_auth_cache;
        if (defined $realm && length $realm) {
-               print "Authentication realm: $realm\n";
+               print STDERR "Authentication realm: $realm\n";
        }
        my $username;
        if (defined $_username) {
                $username = $_username;
        } else {
-               print "Username: ";
+               print STDERR "Username: ";
+               STDERR->flush;
                chomp($username = <STDIN>);
        }
        $cred->username($username);
@@ -2008,7 +2020,8 @@ sub _username_prompt {
 
 sub _read_password {
        my ($prompt, $realm) = @_;
-       print $prompt;
+       print STDERR $prompt;
+       STDERR->flush;
        require Term::ReadKey;
        Term::ReadKey::ReadMode('noecho');
        my $password = '';
@@ -2017,7 +2030,8 @@ sub _read_password {
                $password .= $key;
        }
        Term::ReadKey::ReadMode('restore');
-       print "\n";
+       print STDERR "\n";
+       STDERR->flush;
        $password;
 }
 
@@ -2044,13 +2058,6 @@ sub libsvn_connect {
                              config => $config,
                              pool => SVN::Pool->new,
                              auth_provider_callbacks => $callbacks);
-
-       my $df = $ENV{GIT_SVN_DELTA_FETCH};
-       if (defined $df) {
-               $_xfer_delta = $df;
-       } else {
-               $_xfer_delta = ($url =~ m#^file://#) ? undef : 1;
-       }
        $ra->{svn_path} = $url;
        $ra->{repos_root} = $ra->get_repos_root;
        $ra->{svn_path} =~ s#^\Q$ra->{repos_root}\E/*##;
@@ -2082,49 +2089,6 @@ sub libsvn_dup_ra {
                     auth auth_provider_callbacks repos_root svn_path/);
 }
 
-sub libsvn_get_file {
-       my ($gui, $f, $rev, $chg, $untracked) = @_;
-       $f =~ s#^/##;
-       print "\t$chg\t$f\n" unless $_q;
-
-       my ($hash, $pid, $in, $out);
-       my $pool = SVN::Pool->new;
-       defined($pid = open3($in, $out, '>&STDERR',
-                               qw/git-hash-object -w --stdin/)) or croak $!;
-       # redirect STDOUT for SVN 1.1.x compatibility
-       open my $stdout, '>&', \*STDOUT or croak $!;
-       open STDOUT, '>&', $in or croak $!;
-       my ($r, $props) = $SVN->get_file($f, $rev, \*STDOUT, $pool);
-       $in->flush == 0 or croak $!;
-       open STDOUT, '>&', $stdout or croak $!;
-       close $in or croak $!;
-       close $stdout or croak $!;
-       $pool->clear;
-       chomp($hash = do { local $/; <$out> });
-       close $out or croak $!;
-       waitpid $pid, 0;
-       $hash =~ /^$sha1$/o or die "not a sha1: $hash\n";
-
-       my $mode = exists $props->{'svn:executable'} ? '100755' : '100644';
-       if (exists $props->{'svn:special'}) {
-               $mode = '120000';
-               my $link = `git-cat-file blob $hash`; # no chomping symlinks
-               $link =~ s/^link // or die "svn:special file with contents: <",
-                                               $link, "> is not understood\n";
-               defined($pid = open3($in, $out, '>&STDERR',
-                               qw/git-hash-object -w --stdin/)) or croak $!;
-               print $in $link;
-               $in->flush == 0 or croak $!;
-               close $in or croak $!;
-               chomp($hash = do { local $/; <$out> });
-               close $out or croak $!;
-               waitpid $pid, 0;
-               $hash =~ /^$sha1$/o or die "not a sha1: $hash\n";
-       }
-       %{$untracked->{file_prop}->{$f}} = %$props;
-       print $gui $mode,' ',$hash,"\t",$f,"\0" or croak $!;
-}
-
 sub uri_encode {
        my ($f) = @_;
        $f =~ s#([^a-zA-Z0-9\*!\:_\./\-])#uc sprintf("%%%02x",ord($1))#eg;
@@ -2232,10 +2196,6 @@ sub process_rm {
 }
 
 sub libsvn_fetch {
-       $_xfer_delta ? libsvn_fetch_delta(@_) : libsvn_fetch_full(@_);
-}
-
-sub libsvn_fetch_delta {
        my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
        my $pool = SVN::Pool->new;
        my $ed = SVN::Git::Fetcher->new({ c => $last_commit, q => $_q });
@@ -2251,66 +2211,6 @@ sub libsvn_fetch_delta {
        libsvn_log_entry($rev, $author, $date, $msg, [$last_commit], $ed);
 }
 
-sub libsvn_fetch_full {
-       my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
-       my ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/);
-       my %amr;
-       my $ut = { empty => {}, dir_prop => {}, file_prop => {} };
-       my $p = $SVN->{svn_path};
-       foreach my $f (keys %$paths) {
-               my $m = $paths->{$f}->action();
-               if (length $p) {
-                       $f =~ s#^/\Q$p\E/##;
-                       next if $f =~ m#^/#;
-               } else {
-                       $f =~ s#^/##;
-               }
-               if ($m =~ /^[DR]$/) {
-                       my $t = process_rm($gui, $last_commit, $f, $_q);
-                       if ($m eq 'D') {
-                               $ut->{empty}->{$f} = 0 if $t == $SVN::Node::dir;
-                               next;
-                       }
-                       # 'R' can be file replacements, too, right?
-               }
-               my $pool = SVN::Pool->new;
-               my $t = $SVN->check_path($f, $rev, $pool);
-               if ($t == $SVN::Node::file) {
-                       if ($m =~ /^[AMR]$/) {
-                               $amr{$f} = $m;
-                       } else {
-                               die "Unrecognized action: $m, ($f r$rev)\n";
-                       }
-               } elsif ($t == $SVN::Node::dir && $m =~ /^[AR]$/) {
-                       my @traversed = ();
-                       libsvn_traverse($gui, '', $f, $rev, \@traversed, $ut);
-                       if (@traversed) {
-                               foreach (@traversed) {
-                                       $amr{$_} = $m;
-                               }
-                       } else {
-                               my ($dir, $file) = ($f =~ m#^(.*?)/?([^/]+)$#);
-                               delete $ut->{empty}->{$dir};
-                               $ut->{empty}->{$f} = 1;
-                       }
-               }
-               $pool->clear;
-       }
-       foreach (keys %amr) {
-               libsvn_get_file($gui, $_, $rev, $amr{$_}, $ut);
-               my ($d) = ($_ =~ m#^(.*?)/?(?:[^/]+)$#);
-               delete $ut->{empty}->{$d};
-       }
-       unless (exists $ut->{dir_prop}->{''}) {
-               my $pool = SVN::Pool->new;
-               my (undef, undef, $props) = $SVN->get_dir('', $rev, $pool);
-               %{$ut->{dir_prop}->{''}} = %$props;
-               $pool->clear;
-       }
-       command_close_pipe($gui, $ctx);
-       libsvn_log_entry($rev, $author, $date, $msg, [$last_commit], $ut);
-}
-
 sub svn_grab_base_rev {
        my $c = eval { command_oneline([qw/rev-parse --verify/,
                                        "refs/remotes/$GIT_SVN^0"],
@@ -2362,41 +2262,6 @@ sub libsvn_parse_revision {
                "Try using the command-line svn client instead\n";
 }
 
-sub libsvn_traverse {
-       my ($gui, $pfx, $path, $rev, $files, $untracked) = @_;
-       my $cwd = length $pfx ? "$pfx/$path" : $path;
-       my $pool = SVN::Pool->new;
-       $cwd =~ s#^\Q$SVN->{svn_path}\E##;
-       my $nr = 0;
-       my ($dirent, $r, $props) = $SVN->get_dir($cwd, $rev, $pool);
-       %{$untracked->{dir_prop}->{$cwd}} = %$props;
-       foreach my $d (keys %$dirent) {
-               my $t = $dirent->{$d}->kind;
-               if ($t == $SVN::Node::dir) {
-                       my $i = libsvn_traverse($gui, $cwd, $d, $rev,
-                                               $files, $untracked);
-                       if ($i) {
-                               $nr += $i;
-                       } else {
-                               $untracked->{empty}->{"$cwd/$d"} = 1;
-                       }
-               } elsif ($t == $SVN::Node::file) {
-                       $nr++;
-                       my $file = "$cwd/$d";
-                       if (defined $files) {
-                               push @$files, $file;
-                       } else {
-                               libsvn_get_file($gui, $file, $rev, 'A',
-                                               $untracked);
-                               my ($dir) = ($file =~ m#^(.*?)/?(?:[^/]+)$#);
-                               delete $untracked->{empty}->{$dir};
-                       }
-               }
-       }
-       $pool->clear;
-       $nr;
-}
-
 sub libsvn_traverse_ignore {
        my ($fh, $path, $r) = @_;
        $path =~ s#^/+##g;
@@ -2488,8 +2353,8 @@ sub libsvn_find_parent_branch {
                print STDERR "Found branch parent: ($GIT_SVN) $parent\n";
                command_noisy('read-tree', $parent);
                unless (libsvn_can_do_switch()) {
-                       return libsvn_fetch_full($parent, $paths, $rev,
-                                               $author, $date, $msg);
+                       return _libsvn_new_tree($paths, $rev, $author, $date,
+                                               $msg, [$parent]);
                }
                # do_switch works with svn/trunk >= r22312, but that is not
                # included with SVN 1.4.2 (the latest version at the moment),
@@ -2514,7 +2379,7 @@ sub libsvn_find_parent_branch {
 
 sub libsvn_get_log {
        my ($ra, @args) = @_;
-       $args[4]-- if $args[4] && $_xfer_delta && ! $_follow_parent;
+       $args[4]-- if $args[4] && ! $_follow_parent;
        if ($SVN::Core::VERSION le '1.2.0') {
                splice(@args, 3, 1);
        }
@@ -2525,28 +2390,23 @@ sub libsvn_new_tree {
        if (my $log_entry = libsvn_find_parent_branch(@_)) {
                return $log_entry;
        }
-       my ($paths, $rev, $author, $date, $msg) = @_;
-       my $ut;
-       if ($_xfer_delta) {
-               my $pool = SVN::Pool->new;
-               my $ed = SVN::Git::Fetcher->new({q => $_q});
-               my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool);
-               my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
-               $reporter->set_path('', $rev, 1, @lock, $pool);
-               $reporter->finish_report($pool);
-               $pool->clear;
-               unless ($ed->{git_commit_ok}) {
-                       die "SVN connection failed somewhere...\n";
-               }
-               $ut = $ed;
-       } else {
-               $ut = { empty => {}, dir_prop => {}, file_prop => {} };
-               my ($gui, $ctx) = command_input_pipe(qw/update-index
-                                                    -z --index-info/);
-               libsvn_traverse($gui, '', $SVN->{svn_path}, $rev, undef, $ut);
-               command_close_pipe($gui, $ctx);
+       my ($paths, $rev, $author, $date, $msg) = @_; # $pool is last
+       _libsvn_new_tree($paths, $rev, $author, $date, $msg, []);
+}
+
+sub _libsvn_new_tree {
+       my ($paths, $rev, $author, $date, $msg, $parents) = @_;
+       my $pool = SVN::Pool->new;
+       my $ed = SVN::Git::Fetcher->new({q => $_q});
+       my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool);
+       my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
+       $reporter->set_path('', $rev, 1, @lock, $pool);
+       $reporter->finish_report($pool);
+       $pool->clear;
+       unless ($ed->{git_commit_ok}) {
+               die "SVN connection failed somewhere...\n";
        }
-       libsvn_log_entry($rev, $author, $date, $msg, [], $ut);
+       libsvn_log_entry($rev, $author, $date, $msg, $parents, $ed);
 }
 
 sub find_graft_path_commit {
@@ -2634,7 +2494,7 @@ sub libsvn_ls_fullurl {
        my $pool = SVN::Pool->new;
        my $r = defined $_revision ? $_revision : $ra->get_latest_revnum;
        my ($dirent, undef, undef) = $ra->get_dir('', $r, $pool);
-       foreach my $d (keys %$dirent) {
+       foreach my $d (sort keys %$dirent) {
                if ($dirent->{$d}->kind == $SVN::Node::dir) {
                        push @ret, "$d/"; # add '/' for compat with cli svn
                }
@@ -2986,7 +2846,7 @@ sub rmdirs {
                        delete $rm->{join '/', @dn};
                }
                unless (%$rm) {
-                       eval { command_close_pipe($fh) };
+                       close $fh;
                        return;
                }
        }
@@ -2996,7 +2856,7 @@ sub rmdirs {
        foreach my $d (sort { $b =~ tr#/#/# <=> $a =~ tr#/#/# } keys %$rm) {
                $self->close_directory($bat->{$d}, $p);
                my ($dn) = ($d =~ m#^(.*?)/?(?:[^/]+)$#);
-               print "\tD+\t/$d/\n" unless $q;
+               print "\tD+\t$d/\n" unless $q;
                $self->SUPER::delete_entry($d, $r, $bat->{$dn}, $p);
                delete $bat->{$d};
        }