git-svn: handle our top-level path being deleted and later re-added
[gitweb.git] / git-svn.perl
index 55484f70e26886f9de9cd2d576f58beae8cc334b..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 {
@@ -2363,11 +2366,20 @@ sub make_log_entry {
 
        my ($commit_name, $commit_email) = ($name, $email);
        if ($_use_log_author) {
-               if ($log_entry{log} =~ /From:\s+(.*?)\s+<(.*)>\s*\n/) {
-                       ($name, $email) = ($1, $2);
-               } elsif ($log_entry{log} =~
-                                     /Signed-off-by:\s+(.*?)\s+<(.*)>\s*\n/) {
+               my $name_field;
+               if ($log_entry{log} =~ /From:\s+(.*\S)\s*\n/i) {
+                       $name_field = $1;
+               } elsif ($log_entry{log} =~ /Signed-off-by:\s+(.*\S)\s*\n/i) {
+                       $name_field = $1;
+               }
+               if (!defined $name_field) {
+                       #
+               } elsif ($name_field =~ /(.*?)\s+<(.*)>/) {
                        ($name, $email) = ($1, $2);
+               } elsif ($name_field =~ /(.*)@/) {
+                       ($name, $email) = ($1, $name_field);
+               } else {
+                       ($name, $email) = ($name_field, 'unknown');
                }
        }
        if (defined $headrev && $self->use_svm_props) {
@@ -3033,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;
@@ -4080,39 +4106,7 @@ sub cmt_showable {
 }
 
 sub log_use_color {
-       return 1 if $color;
-       my ($dc, $dcvar);
-       $dcvar = 'color.diff';
-       $dc = `git-config --get $dcvar`;
-       if ($dc eq '') {
-               # nothing at all; fallback to "diff.color"
-               $dcvar = 'diff.color';
-               $dc = `git-config --get $dcvar`;
-       }
-       chomp($dc);
-       if ($dc eq 'auto') {
-               my $pc;
-               $pc = `git-config --get color.pager`;
-               if ($pc eq '') {
-                       # does not have it -- fallback to pager.color
-                       $pc = `git-config --bool --get pager.color`;
-               }
-               else {
-                       $pc = `git-config --bool --get color.pager`;
-                       if ($?) {
-                               $pc = 'false';
-                       }
-               }
-               chomp($pc);
-               if (-t *STDOUT || (defined $pager && $pc eq 'true')) {
-                       return ($ENV{TERM} && $ENV{TERM} ne 'dumb');
-               }
-               return 0;
-       }
-       return 0 if $dc eq 'never';
-       return 1 if $dc eq 'always';
-       chomp($dc = `git-config --bool --get $dcvar`);
-       return ($dc eq 'true');
+       return $color || Git->repository->get_colorbool('color.diff');
 }
 
 sub git_svn_log_cmd {
@@ -4171,6 +4165,7 @@ sub config_pager {
        } elsif (length $pager == 0 || $pager eq 'cat') {
                $pager = undef;
        }
+       $ENV{GIT_PAGER_IN_USE} = defined($pager);
 }
 
 sub run_pager {