summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-config.txt4
-rw-r--r--Documentation/git.txt8
-rw-r--r--config.c10
-rw-r--r--git-compat-util.h6
-rw-r--r--wrapper.c10
5 files changed, 31 insertions, 7 deletions
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index eaea079165..9ae2508f3f 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -240,6 +240,10 @@ GIT_CONFIG::
Using the "--global" option forces this to ~/.gitconfig. Using the
"--system" option forces this to $(prefix)/etc/gitconfig.
+GIT_CONFIG_NOSYSTEM::
+ Whether to skip reading settings from the system-wide
+ $(prefix)/etc/gitconfig file. See linkgit:git[1] for details.
+
See also <<FILES>>.
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 05c0b942be..c03b7adc97 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -777,6 +777,14 @@ for further details.
and read the password from its STDOUT. See also the 'core.askpass'
option in linkgit:git-config[1].
+'GIT_CONFIG_NOSYSTEM'::
+ Whether to skip reading settings from the system-wide
+ `$(prefix)/etc/gitconfig` file. This environment variable can
+ be used along with `$HOME` and `$XDG_CONFIG_HOME` to create a
+ predictable environment for a picky script, or you can set it
+ temporarily to avoid using a buggy `/etc/gitconfig` file while
+ waiting for someone with sufficient permissions to fix it.
+
'GIT_FLUSH'::
If this environment variable is set to "1", then commands such
as 'git blame' (in incremental mode), 'git rev-list', 'git log',
diff --git a/config.c b/config.c
index 053970f369..7b444b68ab 100644
--- a/config.c
+++ b/config.c
@@ -58,7 +58,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
path = buf.buf;
}
- if (!access_or_warn(path, R_OK)) {
+ if (!access_or_die(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");
@@ -940,23 +940,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_or_warn(git_etc_gitconfig(), R_OK)) {
+ if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK)) {
ret += git_config_from_file(fn, git_etc_gitconfig(),
data);
found += 1;
}
- if (xdg_config && !access_or_warn(xdg_config, R_OK)) {
+ if (xdg_config && !access_or_die(xdg_config, R_OK)) {
ret += git_config_from_file(fn, xdg_config, data);
found += 1;
}
- if (user_config && !access_or_warn(user_config, R_OK)) {
+ if (user_config && !access_or_die(user_config, R_OK)) {
ret += git_config_from_file(fn, user_config, data);
found += 1;
}
- if (repo_config && !access_or_warn(repo_config, R_OK)) {
+ if (repo_config && !access_or_die(repo_config, R_OK)) {
ret += git_config_from_file(fn, repo_config, data);
found += 1;
}
diff --git a/git-compat-util.h b/git-compat-util.h
index 9661bc9f73..2cecf56eb3 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -654,8 +654,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. */
+/*
+ * Call access(2), but warn for any error except "missing file"
+ * (ENOENT or ENOTDIR).
+ */
int access_or_warn(const char *path, int mode);
+int access_or_die(const char *path, int mode);
/* Warn on an inaccessible file that ought to be accessible */
void warn_on_inaccessible(const char *path);
diff --git a/wrapper.c b/wrapper.c
index a066e2ee9e..bac59d2c41 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -411,11 +411,19 @@ void warn_on_inaccessible(const char *path)
int access_or_warn(const char *path, int mode)
{
int ret = access(path, mode);
- if (ret && errno != ENOENT)
+ if (ret && errno != ENOENT && errno != ENOTDIR)
warn_on_inaccessible(path);
return ret;
}
+int access_or_die(const char *path, int mode)
+{
+ int ret = access(path, mode);
+ if (ret && errno != ENOENT && errno != ENOTDIR)
+ die_errno(_("unable to access '%s'"), path);
+ return ret;
+}
+
struct passwd *xgetpwuid_self(void)
{
struct passwd *pw;