From: Junio C Hamano Date: Sun, 18 Nov 2007 09:58:16 +0000 (-0800) Subject: file_exists(): dangling symlinks do exist X-Git-Tag: v1.5.4-rc0~78^2~17 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a50f9fc5feb0a8b8afe51e75ae7c7a87446113e3;p=git.git 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 --- diff --git a/dir.c b/dir.c index 225fdfb52..11a4cf3e1 100644 --- a/dir.c +++ b/dir.c @@ -690,11 +690,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i return dir->nr; } -int -file_exists(const char *f) +int file_exists(const char *f) { - struct stat sb; - return stat(f, &sb) == 0; + struct stat sb; + return lstat(f, &sb) == 0; } /*