]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-svn.perl
"git-apply --check" should not report "fixed"
[thirdparty/git.git] / git-svn.perl
index 7cd62fc5c48acc5bdeeb261b46b9c0df955db678..3308fe1e3f86b5e96c3af66e6cd092a7e9d50980 100755 (executable)
@@ -197,8 +197,8 @@ for (my $i = 0; $i < @ARGV; $i++) {
        }
 };
 
-# make sure we're always running
-unless ($cmd =~ /(?:clone|init|multi-init)$/) {
+# make sure we're always running at the top-level working directory
+unless ($cmd && $cmd =~ /(?:clone|init|multi-init)$/) {
        unless (-d $ENV{GIT_DIR}) {
                if ($git_dir_user_set) {
                        die "GIT_DIR=$ENV{GIT_DIR} explicitly set, ",
@@ -418,7 +418,7 @@ sub cmd_dcommit {
                warn "Attempting to commit more than one change while ",
                     "--no-rebase is enabled.\n",
                     "If these changes depend on each other, re-running ",
-                    "without --no-rebase will be required."
+                    "without --no-rebase may be required."
        }
        while (1) {
                my $d = shift @$linear_refs or last;
@@ -453,6 +453,7 @@ sub cmd_dcommit {
                                                               $parents->{$d};
                        }
                        $_fetch_all ? $gs->fetch_all : $gs->fetch;
+                       $last_rev = $cmt_rev;
                        next if $_no_rebase;
 
                        # we always want to rebase against the current HEAD,
@@ -512,7 +513,6 @@ sub cmd_dcommit {
                                $parents = \%p;
                                $linear_refs = \@l;
                        }
-                       $last_rev = $cmt_rev;
                }
        }
        unlink $gs->{index};
@@ -1283,8 +1283,11 @@ BEGIN {
        }
 }
 
-my %LOCKFILES;
-END { unlink keys %LOCKFILES if %LOCKFILES }
+my (%LOCKFILES, %INDEX_FILES);
+END {
+       unlink keys %LOCKFILES if %LOCKFILES;
+       unlink keys %INDEX_FILES if %INDEX_FILES;
+}
 
 sub resolve_local_globs {
        my ($url, $fetch, $glob_spec) = @_;
@@ -1376,7 +1379,6 @@ 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 {
@@ -3177,9 +3179,15 @@ sub close_file {
                }
                sysseek($fh, 0, 0) or croak $!;
                if ($fb->{mode_b} == 120000) {
-                       sysread($fh, my $buf, 5) == 5 or croak $!;
-                       $buf eq 'link ' or die "$path has mode 120000",
-                                              "but is not a link\n";
+                       eval {
+                               sysread($fh, my $buf, 5) == 5 or croak $!;
+                               $buf eq 'link ' or die "$path has mode 120000",
+                                                      " but is not a link";
+                       };
+                       if ($@) {
+                               warn "$@\n";
+                               sysseek($fh, 0, 0) or croak $!;
+                       }
                }
                defined(my $pid = open my $out,'-|') or die "Can't fork: $!\n";
                if (!$pid) {
@@ -3939,6 +3947,7 @@ sub gs_fetch_loop_common {
                                if ($log_entry) {
                                        $gs->do_git_commit($log_entry);
                                }
+                               $INDEX_FILES{$gs->{index}} = 1;
                        }
                        foreach my $g (@$globs) {
                                my $k = "svn-remote.$g->{remote}." .
@@ -4076,6 +4085,10 @@ sub skip_unknown_revs {
                        warn "W: Ignoring error from SVN, path probably ",
                             "does not exist: ($errno): ",
                             $err->expanded_message,"\n";
+                       warn "W: Do not be alarmed at the above message ",
+                            "git-svn is just searching aggressively for ",
+                            "old history.\n",
+                            "This may take a while on large repositories\n";
                        $ignored_err{$err_key} = 1;
                }
                return;