chiark / gitweb /
dgit: unrepres. changes: Prepare to tolerate symlinks
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 51975965deb49aad24c205848e0ca5170983185b..8b9934b807c020233bc9f90d76487988460e2b30 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -4910,14 +4910,15 @@ sub quiltify_trees_differ ($$;$$$) {
 
        if ($unrepres) {
            eval {
-               die "not a plain file\n"
-                   unless $newmode =~ m/^10\d{4}$/ ||
-                          $oldmode =~ m/^10\d{4}$/;
+               die "not a plain file or symlink\n"
+                   unless $newmode =~ m/^(?:10|12)\d{4}$/ ||
+                          $oldmode =~ m/^(?:10|12)\d{4}$/;
                if ($oldmode =~ m/[^0]/ &&
                    $newmode =~ m/[^0]/) {
-                   die "mode changed\n" if $oldmode ne $newmode;
+                   die "mode or type changed\n" if $oldmode ne $newmode;
+                   die "modified symlink\n" unless $newmode =~ m/^10/;
                } else {
-                   die "non-default mode\n"
+                   die "non-default mode or type\n"
                        unless $newmode =~ m/^100644$/ ||
                               $oldmode =~ m/^100644$/;
                }
@@ -6349,7 +6350,10 @@ END
     foreach my $fi (@dfi) {
        my $f = $fi->{Filename};
        my $here = "../$f";
-       next if lstat $here;
+       if (lstat $here) {
+           next if stat $here;
+           fail "lstat $here works but stat gives $! !";
+       }
        fail "stat $here: $!" unless $! == ENOENT;
        my $there = $dscfn;
        if ($dscfn =~ m#^(?:\./+)?\.\./+#) {
@@ -6360,8 +6364,10 @@ END
            fail "cannot import $dscfn which seems to be inside working tree!";
        }
        $there =~ s#/+[^/]+$## or
-           fail "cannot import $dscfn which seems to not have a basename";
+           fail "import $dscfn requires ../$f, but it does not exist";
        $there .= "/$f";
+       my $test = $there =~ m{^/} ? $there : "../$there";
+       stat $test or fail "import $dscfn requires $test, but: $!";
        symlink $there, $here or fail "symlink $there to $here: $!";
        progress "made symlink $here -> $there";
 #      print STDERR Dumper($fi);