diff --git a/builtin-apply.c b/builtin-apply.c
index ccd342c1c46a7c7a1e346950f60f357426e58104..f94d0dbf488ff43ccc496939560c81daf05772cf 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2412,8 +2412,7 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
* used to be.
*/
struct stat st;
- errno = 0;
- if (!lstat(path, &st) && S_ISDIR(st.st_mode) && !rmdir(path))
+ if (!lstat(path, &st) && (!S_ISDIR(st.st_mode) || !rmdir(path)))
errno = EEXIST;
}