chiark / gitweb /
When cleaning up after failed clone, stat the to-be-cleaned-up directory before runni...
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 9edc6577a4feb3a46129321570bac783ade70c11..91f43af087372c02b0f6ad719f93a60b07a94002 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2131,7 +2131,13 @@ sub cmd_clone {
                return if $!==&ENOENT;
                die "chdir $cwd_remove: $!";
            }
-           rmtree($dstdir) or die "remove $dstdir: $!\n";
+           if (stat $dstdir) {
+               rmtree($dstdir) or die "remove $dstdir: $!\n";
+           } elsif (!grep { $! == $_ }
+                    (ENOENT, ENOTDIR, EACCES, EPERM, ELOOP)) {
+           } else {
+               print STDERR "check whether to remove $dstdir: $!\n";
+           }
        };
     }