diff --git a/update-cache.c b/update-cache.c
index 16e1bb9aea..5dda89a93e 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -111,7 +111,7 @@ static int add_file_to_cache(char *path)
 
 	fd = open(path, O_RDONLY);
 	if (fd < 0) {
-		if (errno == ENOENT) {
+		if (errno == ENOENT || errno == ENOTDIR) {
 			if (allow_remove)
 				return remove_file_from_cache(path);
 		}