file_exists(): dangling symlinks do exist
This function is used to see if a path given by the user does exist on the filesystem. A symbolic link that does not point anywhere does exist but running stat() on it would yield an error, and it incorrectly said it does not exist. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 18, 2007 at 01:58 UTC
a50f9fc5feb0a8b8afe51e75ae7c7a87446113e3
1 file changed
+3
-4
dir.c
+3
-4
@@ -690,11 +690,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
690
return dir->nr;
691
}
692
693
-int
694
-file_exists(const char *f)
693
+int file_exists(const char *f)
694
{
696
- struct stat sb;
697
- return stat(f, &sb) == 0;
695
+ struct stat sb;
696
+ return lstat(f, &sb) == 0;
697
}
698
699
/*