- if (mkdir_p(path, 0777))
- die("failed to create path %s: %s", path, strerror(errno));
- unlink(path);
+ int status;
+ const char *msg = "failed to create path '%s'%s";
+
+ status = mkdir_p(path, 0777);
+ if (status) {
+ if (status == -3) {
+ /* something else exists */
+ error(msg, path, ": perhaps a D/F conflict?");
+ update_wd = 0;
+ goto update_index;
+ }
+ die(msg, path, "");
+ }
+ if (unlink(path)) {
+ if (errno == EISDIR) {
+ /* something else exists */
+ error(msg, path, ": perhaps a D/F conflict?");
+ update_wd = 0;
+ goto update_index;
+ }
+ if (errno != ENOENT)
+ die("failed to unlink %s "
+ "in preparation to update: %s",
+ path, strerror(errno));
+ }