git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] file_exists(): dangling symlinks do exist
@ 2007-11-18 10:21 Junio C Hamano
  2007-11-18 10:21 ` [PATCH] Export three helper functions from ls-files Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2007-11-18 10:21 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-11-19 16:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-18 10:21 [PATCH] file_exists(): dangling symlinks do exist Junio C Hamano
2007-11-18 10:21 ` [PATCH] Export three helper functions from ls-files Junio C Hamano
2007-11-18 10:21   ` [PATCH] Fix add_files_to_cache() to take pathspec, not user specified list of files Junio C Hamano
2007-11-18 10:21     ` [PATCH] builtin-commit: fix partial-commit support Junio C Hamano
2007-11-18 10:26       ` Junio C Hamano
2007-11-18 10:57       ` Junio C Hamano
2007-11-18 18:44         ` Junio C Hamano
2007-11-19 16:47       ` Kristian Høgsberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).