Code

Documentation/config.txt: Correct info about subsection name
[git.git] / git-svn.perl
index 1da31fdc7cf9c90e6ec3dfd815201e36b9650890..83ec03d4786a39f250f8f83c075c9dabf782b1db 100755 (executable)
@@ -70,7 +70,7 @@ my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
        $_version, $_upgrade, $_authors, $_branch_all_refs, @_opt_m,
        $_merge, $_strategy, $_dry_run, $_ignore_nodate, $_non_recursive,
        $_username, $_config_dir, $_no_auth_cache,
-       $_pager, $_color);
+       $_pager, $_color, $_prefix);
 my (@_branch_from, %tree_map, %users, %rusers, %equiv);
 my ($_svn_can_do_switch);
 my @repo_path_split_cache;
@@ -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)',
@@ -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);
@@ -595,8 +596,9 @@ sub multi_init {
                        command_noisy('repo-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 {
@@ -1084,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);
@@ -1916,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 {
@@ -1931,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);
@@ -1978,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);
@@ -1997,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);
@@ -2013,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 = '';
@@ -2022,7 +2030,8 @@ sub _read_password {
                $password .= $key;
        }
        Term::ReadKey::ReadMode('restore');
-       print "\n";
+       print STDERR "\n";
+       STDERR->flush;
        $password;
 }
 
@@ -2847,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};
        }