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>
This commit is contained in:

committed by
Junio C Hamano

parent
889d35899b
commit
ba8bd8300a
@ -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;
|
||||
|
Reference in New Issue
Block a user