From: Junio C Hamano Date: Fri, 7 Sep 2012 18:08:56 +0000 (-0700) Subject: Merge branch 'jk/config-warn-on-inaccessible-paths' X-Git-Tag: v1.8.0-rc0~97 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/7fe136d78f5db3317ebf60115c1d7faa87412d6a?ds=inline;hp=-c Merge branch 'jk/config-warn-on-inaccessible-paths' When looking for $HOME/.gitconfig etc., it is OK if we cannot read them because they do not exist, but we did not diagnose existing files that we cannot read. * jk/config-warn-on-inaccessible-paths: warn_on_inaccessible(): a helper to warn on inaccessible paths attr: warn on inaccessible attribute files gitignore: report access errors of exclude files config: warn on inaccessible files --- 7fe136d78f5db3317ebf60115c1d7faa87412d6a diff --combined builtin/config.c index ada6e12114,b0394efac9..442ccc2497 --- a/builtin/config.c +++ b/builtin/config.c @@@ -160,7 -160,7 +160,7 @@@ static int show_config(const char *key_ static int get_value(const char *key_, const char *regex_) { - int ret = -1; + int ret = CONFIG_GENERIC_ERROR; char *global = NULL, *xdg = NULL, *repo_config = NULL; const char *system_wide = NULL, *local; struct config_include_data inc = CONFIG_INCLUDE_INIT; @@@ -196,14 -196,11 +196,14 @@@ if (regcomp(key_regexp, key, REG_EXTENDED)) { fprintf(stderr, "Invalid key pattern: %s\n", key_); free(key); + ret = CONFIG_INVALID_PATTERN; goto free_strings; } } else { - if (git_config_parse_key(key_, &key, NULL)) + if (git_config_parse_key(key_, &key, NULL)) { + ret = CONFIG_INVALID_KEY; goto free_strings; + } } if (regex_) { @@@ -215,7 -212,6 +215,7 @@@ regexp = (regex_t*)xmalloc(sizeof(regex_t)); if (regcomp(regexp, regex_, REG_EXTENDED)) { fprintf(stderr, "Invalid pattern: %s\n", regex_); + ret = CONFIG_INVALID_PATTERN; goto free_strings; } } @@@ -400,8 -396,8 +400,8 @@@ int cmd_config(int argc, const char **a */ 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; diff --combined git-compat-util.h index 34f040f595,000042d793..fd732d7243 --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -162,11 -162,6 +162,11 @@@ #define probe_utf8_pathname_composition(a,b) #endif +#ifdef MKDIR_WO_TRAILING_SLASH +#define mkdir(a,b) compat_mkdir_wo_trailing_slash((a),(b)) +extern int compat_mkdir_wo_trailing_slash(const char*, mode_t); +#endif + #ifndef NO_LIBGEN_H #include #else @@@ -609,6 -604,12 +609,12 @@@ int rmdir_or_warn(const char *path) */ int remove_or_warn(unsigned int mode, const char *path); + /* Call access(2), but warn for any error besides ENOENT. */ + int access_or_warn(const char *path, int mode); + + /* Warn on an inaccessible file that ought to be accessible */ + void warn_on_inaccessible(const char *path); + /* Get the passwd entry for the UID of the current process. */ struct passwd *xgetpwuid_self(void);