summaryrefslogtreecommitdiff
path: root/builtin/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-08-21 02:10:59 -0400
committerJunio C Hamano <gitster@pobox.com>2012-08-21 14:46:11 -0700
commitba8bd8300a544959159f6bd3a7e03ac54f85ea3a (patch)
tree2b1437e903b77276e6b1cde6d94ec0f61ff472ba /builtin/config.c
parent889d35899ba64640e47798681ecb34a4be043bad (diff)
downloadgit-ba8bd8300a544959159f6bd3a7e03ac54f85ea3a.tar.gz
config: warn on inaccessible files
Before reading a config file, we check "!access(path, R_OK)" to make sure that the file exists and is readable. If it's not, then we silently ignore it. For the case of ENOENT, this is fine, as the presence of the file is optional. For other cases, though, it may indicate a configuration error (e.g., not having permissions to read the file). Let's print a warning in these cases to let the user know. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/config.c')
-rw-r--r--builtin/config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/config.c b/builtin/config.c
index 8cd08da991..b0394efac9 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -396,8 +396,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
*/
die("$HOME not set");
- if (access(user_config, R_OK) &&
- xdg_config && !access(xdg_config, R_OK))
+ if (access_or_warn(user_config, R_OK) &&
+ xdg_config && !access_or_warn(xdg_config, R_OK))
given_config_file = xdg_config;
else
given_config_file = user_config;