From 55b38a48e2a7ccfaaa7897a5fccb98327fa0e3c0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 21 Aug 2012 14:52:07 -0700 Subject: warn_on_inaccessible(): a helper to warn on inaccessible paths The previous series introduced warnings to multiple places, but it could become tiring to see the warning on the same path over and over again during a single run of Git. Making just one function responsible for issuing this warning, we could later choose to keep track of which paths we issued a warning (it would involve a hash table of paths after running them through real_path() or something) in order to reduce noise. Right now we do not know if the noise reduction is necessary, but it still would be a good code reduction/sharing anyway. Signed-off-by: Junio C Hamano --- wrapper.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'wrapper.c') diff --git a/wrapper.c b/wrapper.c index b40c7e73da..68739aaa3b 100644 --- a/wrapper.c +++ b/wrapper.c @@ -403,11 +403,16 @@ int remove_or_warn(unsigned int mode, const char *file) return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file); } +void warn_on_inaccessible(const char *path) +{ + warning(_("unable to access '%s': %s"), path, strerror(errno)); +} + int access_or_warn(const char *path, int mode) { int ret = access(path, mode); if (ret && errno != ENOENT) - warning(_("unable to access '%s': %s"), path, strerror(errno)); + warn_on_inaccessible(path); return ret; } -- cgit v1.2.3