Commit 2185fde56 (config: handle conditional include when $GIT_DIR is
not set up) added a 'git_dir' field to the config_options struct. Let's
use this option field explicitly all the time instead of occasionally
falling back to calling 'git_pathdup("config")' to get the path to the
local repository configuration. This allows 'do_git_config_sequence()'
to not implicitly rely on global repository state.
Signed-off-by: Brandon Williams <[email protected]>
---
builtin/config.c | 2 ++
config.c | 6 ++----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index 753c40a5c..90f49a6ee 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -539,6 +539,8 @@ int cmd_config(int argc, const char **argv, const char
*prefix)
config_options.respect_includes = !given_config_source.file;
else
config_options.respect_includes = respect_includes_opt;
+ if (have_git_dir())
+ config_options.git_dir = get_git_common_dir();
if (end_null) {
term = '\0';
diff --git a/config.c b/config.c
index 2390f98e3..4e2842689 100644
--- a/config.c
+++ b/config.c
@@ -219,8 +219,6 @@ static int include_by_gitdir(const struct config_options
*opts,
if (opts->git_dir)
git_dir = opts->git_dir;
- else if (have_git_dir())
- git_dir = get_git_dir();
else
goto done;
@@ -1548,8 +1546,6 @@ static int do_git_config_sequence(const struct
config_options *opts,
if (opts->git_dir)
repo_config = mkpathdup("%s/config", opts->git_dir);
- else if (have_git_dir())
- repo_config = git_pathdup("config");
else
repo_config = NULL;
@@ -1613,6 +1609,8 @@ static void git_config_raw(config_fn_t fn, void *data)
struct config_options opts = {0};
opts.respect_includes = 1;
+ if (have_git_dir())
+ opts.git_dir = get_git_common_dir();
if (git_config_with_options(fn, data, NULL, &opts) < 0)
/*
* git_config_with_options() normally returns only
--
2.13.1.518.g3df882009-goog