Code

lost-found: use fsck-objects --full
[git.git] / git-svn.perl
index 145eaa865a3bc44da2f3bc028c462cefd924f9c6..6453771f9c2ce27dcecb7bf208cd60feb4881aa3 100755 (executable)
@@ -147,7 +147,7 @@ init_vars();
 load_authors() if $_authors;
 load_all_refs() if $_branch_all_refs;
 svn_compat_check() unless $_use_lib;
-migration_check() unless $cmd =~ /^(?:init|rebuild|multi-init)$/;
+migration_check() unless $cmd =~ /^(?:init|rebuild|multi-init|commit-diff)$/;
 $cmd{$cmd}->[0]->(@ARGV);
 exit 0;
 
@@ -760,7 +760,7 @@ sub commit_diff {
                exit 1;
        }
        if (defined $_file) {
-               $_message = file_to_s($_message);
+               $_message = file_to_s($_file);
        } else {
                $_message ||= get_commit_message($tb,
                                        "$GIT_DIR/.svn-commit.tmp.$$")->{msg};
@@ -1518,12 +1518,12 @@ sub get_commit_message {
        open my $msg, '>', $commit_msg or croak $!;
 
        chomp(my $type = `git-cat-file -t $commit`);
-       if ($type eq 'commit') {
+       if ($type eq 'commit' || $type eq 'tag') {
                my $pid = open my $msg_fh, '-|';
                defined $pid or croak $!;
 
                if ($pid == 0) {
-                       exec(qw(git-cat-file commit), $commit) or croak $!;
+                       exec('git-cat-file', $type, $commit) or croak $!;
                }
                my $in_msg = 0;
                while (<$msg_fh>) {
@@ -2429,7 +2429,7 @@ sub extract_metadata {
                                                        \s([a-f\d\-]+)$/x);
        if (!$rev || !$uuid || !$url) {
                # some of the original repositories I made had
-               # indentifiers like this:
+               # identifiers like this:
                ($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/);
        }
        return ($url, $rev, $uuid);
@@ -2709,6 +2709,12 @@ sub libsvn_fetch {
                        } else {
                                die "Unrecognized action: $m, ($f r$rev)\n";
                        }
+               } elsif ($t == $SVN::Node::dir && $m =~ /^[AR]$/) {
+                       my @traversed = ();
+                       libsvn_traverse($gui, '', $f, $rev, \@traversed);
+                       foreach (@traversed) {
+                               push @amr, [ $m, $_ ]
+                       }
                }
                $pool->clear;
        }
@@ -2778,7 +2784,7 @@ sub libsvn_parse_revision {
 }
 
 sub libsvn_traverse {
-       my ($gui, $pfx, $path, $rev) = @_;
+       my ($gui, $pfx, $path, $rev, $files) = @_;
        my $cwd = "$pfx/$path";
        my $pool = SVN::Pool->new;
        $cwd =~ s#^/+##g;
@@ -2786,10 +2792,15 @@ sub libsvn_traverse {
        foreach my $d (keys %$dirent) {
                my $t = $dirent->{$d}->kind;
                if ($t == $SVN::Node::dir) {
-                       libsvn_traverse($gui, $cwd, $d, $rev);
+                       libsvn_traverse($gui, $cwd, $d, $rev, $files);
                } elsif ($t == $SVN::Node::file) {
-                       print "\tA\t$cwd/$d\n" unless $_q;
-                       libsvn_get_file($gui, "$cwd/$d", $rev);
+                       my $file = "$cwd/$d";
+                       if (defined $files) {
+                               push @$files, $file;
+                       } else {
+                               print "\tA\t$file\n" unless $_q;
+                               libsvn_get_file($gui, $file, $rev);
+                       }
                }
        }
        $pool->clear;
@@ -2913,9 +2924,7 @@ sub libsvn_new_tree {
        }
        my ($paths, $rev, $author, $date, $msg) = @_;
        open my $gui, '| git-update-index -z --index-info' or croak $!;
-       my $pool = SVN::Pool->new;
-       libsvn_traverse($gui, '', $SVN_PATH, $rev, $pool);
-       $pool->clear;
+       libsvn_traverse($gui, '', $SVN_PATH, $rev);
        close $gui or croak $?;
        return libsvn_log_entry($rev, $author, $date, $msg);
 }