git-svn: handle our top-level path being deleted and later re-added
[gitweb.git] / git-svn.perl
index 34c5e3d2e4246aeed42d1be89f86c3c20839d509..d411a343170cf8dce9d968b84f123855b03e53d3 100755 (executable)
@@ -396,6 +396,7 @@ sub cmd_set_tree {
        }
        $gs->set_tree($_) foreach @revs;
        print "Done committing ",scalar @revs," revisions to SVN\n";
+       unlink $gs->{index};
 }
 
 sub cmd_dcommit {
@@ -514,6 +515,7 @@ sub cmd_dcommit {
                        $last_rev = $cmt_rev;
                }
        }
+       unlink $gs->{index};
 }
 
 sub cmd_find_rev {
@@ -1374,6 +1376,7 @@ sub fetch_all {
 
        ($base, $head) = parse_revision_argument($base, $head);
        $ra->gs_fetch_loop_common($base, $head, \@gs, \@globs);
+       unlink $_->{index} foreach @gs;
 }
 
 sub read_all_remotes {
@@ -3042,6 +3045,20 @@ sub add_file {
 
 sub add_directory {
        my ($self, $path, $cp_path, $cp_rev) = @_;
+       my $gpath = $self->git_path($path);
+       if ($gpath eq '') {
+               my ($ls, $ctx) = command_output_pipe(qw/ls-tree
+                                                    -r --name-only -z/,
+                                                    $self->{c});
+               local $/ = "\0";
+               while (<$ls>) {
+                       chomp;
+                       $self->{gii}->remove($_);
+                       print "\tD\t$_\n" unless $::_q;
+               }
+               command_close_pipe($ls, $ctx);
+               $self->{empty}->{$path} = 0;
+       }
        my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
        delete $self->{empty}->{$dir};
        $self->{empty}->{$path} = 1;