Contribute a fairly paranoid update hook
[gitweb.git] / builtin-apply.c
index fd92ef7174dae1586921ebd34233c93b381106de..94311e7af47f856c0ecfad08bebfde83a80938a2 100644 (file)
@@ -2416,8 +2416,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;
        }