login
Header Space

 
 

[PATCH] file_exists(): dangling symlinks do exist

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Date: Sunday, November 18, 2007 - 6:21 am

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>
---
 dir.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/dir.c b/dir.c
index 01790ab..87e5dec 100644
--- a/dir.c
+++ b/dir.c
@@ -688,11 +688,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;
 }
 
 /*
-- 
1.5.3.5.1815.g9445b

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] file_exists(): dangling symlinks do exist, Junio C Hamano, (Sun Nov 18, 6:21 am)
[PATCH] Export three helper functions from ls-files, Junio C Hamano, (Sun Nov 18, 6:21 am)
[PATCH] builtin-commit: fix partial-commit support, Junio C Hamano, (Sun Nov 18, 6:21 am)
Re: [PATCH] builtin-commit: fix partial-commit support, Junio C Hamano, (Sun Nov 18, 6:57 am)
Re: [PATCH] builtin-commit: fix partial-commit support, Junio C Hamano, (Sun Nov 18, 2:44 pm)
Re: [PATCH] builtin-commit: fix partial-commit support, Junio C Hamano, (Sun Nov 18, 6:26 am)
speck-geostationary