Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-07 22:08:56 +0400
committerJunio C Hamano <gitster@pobox.com>2012-09-07 22:08:56 +0400
commit7fe136d78f5db3317ebf60115c1d7faa87412d6a (patch)
treed9f4d19d5bd01254450e6d4b169f9e30952de79e
parent09827f2a55299cc8c09d30754c016378a15c4775 (diff)
parent55b38a48e2a7ccfaaa7897a5fccb98327fa0e3c0 (diff)
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
-rw-r--r--attr.c5
-rw-r--r--builtin/config.c4
-rw-r--r--config.c10
-rw-r--r--dir.c6
-rw-r--r--git-compat-util.h6
-rw-r--r--wrapper.c13
6 files changed, 34 insertions, 10 deletions
diff --git a/attr.c b/attr.c
index b52efb55a0..f12c83f80a 100644
--- a/attr.c
+++ b/attr.c
@@ -352,8 +352,11 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
char buf[2048];
int lineno = 0;
- if (!fp)
+ if (!fp) {
+ if (errno != ENOENT)
+ warn_on_inaccessible(path);
return NULL;
+ }
res = xcalloc(1, sizeof(*res));
while (fgets(buf, sizeof(buf), fp))
handle_attr_line(res, buf, path, ++lineno, macro_ok);
diff --git a/builtin/config.c b/builtin/config.c
index ada6e12114..442ccc2497 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -400,8 +400,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;
diff --git a/config.c b/config.c
index 2b706ea205..08e47e2e48 100644
--- a/config.c
+++ b/config.c
@@ -60,7 +60,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
path = buf.buf;
}
- if (!access(path, R_OK)) {
+ if (!access_or_warn(path, R_OK)) {
if (++inc->depth > MAX_INCLUDE_DEPTH)
die(include_depth_advice, MAX_INCLUDE_DEPTH, path,
cf && cf->name ? cf->name : "the command line");
@@ -939,23 +939,23 @@ int git_config_early(config_fn_t fn, void *data, const char *repo_config)
home_config_paths(&user_config, &xdg_config, "config");
- if (git_config_system() && !access(git_etc_gitconfig(), R_OK)) {
+ if (git_config_system() && !access_or_warn(git_etc_gitconfig(), R_OK)) {
ret += git_config_from_file(fn, git_etc_gitconfig(),
data);
found += 1;
}
- if (xdg_config && !access(xdg_config, R_OK)) {
+ if (xdg_config && !access_or_warn(xdg_config, R_OK)) {
ret += git_config_from_file(fn, xdg_config, data);
found += 1;
}
- if (user_config && !access(user_config, R_OK)) {
+ if (user_config && !access_or_warn(user_config, R_OK)) {
ret += git_config_from_file(fn, user_config, data);
found += 1;
}
- if (repo_config && !access(repo_config, R_OK)) {
+ if (repo_config && !access_or_warn(repo_config, R_OK)) {
ret += git_config_from_file(fn, repo_config, data);
found += 1;
}
diff --git a/dir.c b/dir.c
index 240bf0c49c..486833986e 100644
--- a/dir.c
+++ b/dir.c
@@ -397,6 +397,8 @@ int add_excludes_from_file_to_list(const char *fname,
fd = open(fname, O_RDONLY);
if (fd < 0 || fstat(fd, &st) < 0) {
+ if (errno != ENOENT)
+ warn_on_inaccessible(fname);
if (0 <= fd)
close(fd);
if (!check_index ||
@@ -1311,9 +1313,9 @@ void setup_standard_excludes(struct dir_struct *dir)
home_config_paths(NULL, &xdg_path, "ignore");
excludes_file = xdg_path;
}
- if (!access(path, R_OK))
+ if (!access_or_warn(path, R_OK))
add_excludes_from_file(dir, path);
- if (excludes_file && !access(excludes_file, R_OK))
+ if (excludes_file && !access_or_warn(excludes_file, R_OK))
add_excludes_from_file(dir, excludes_file);
}
diff --git a/git-compat-util.h b/git-compat-util.h
index 34f040f595..fd732d7243 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -609,6 +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);
diff --git a/wrapper.c b/wrapper.c
index b5e33e49c7..68739aaa3b 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -403,6 +403,19 @@ 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)
+ warn_on_inaccessible(path);
+ return ret;
+}
+
struct passwd *xgetpwuid_self(void)
{
struct passwd *pw;