This patch is based on Pasky's, with three notable differences:
- I did not yet update the documentation
- I named it .gitconfig, not .gitrc
- git-repo-config does not barf when a unique key is overridden locally
The last means that if you have something like
[alias]
l = log --stat -M
in ~/.gitconfig, and
[alias]
l = log --stat -M next..
in $GIT_DIR/config, then
git-repo-config alias.l
returns only one value, namely the value from $GIT_DIR/config.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
int git_config(config_fn_t fn)
{
- return git_config_from_file(fn, git_path("config"));
+ int ret = 0;
+ const char *home = getenv("HOME");
+
+ if (home) {
+ ret = git_config_from_file(fn, mkpath("%s/.gitconfig", home));
+ /* ignore if global config does not exist */
+ if (ret < 0)
+ ret = 0;
+ }
+
+ ret += git_config_from_file(fn, git_path("config"));
+ return ret;
}
/*
static int get_value(const char* key_, const char* regex_)
{
char *tl;
+ const char *home = getenv("HOME");
+ const char *global = (home ? mkpath("%s/.gitconfig", home) : NULL);
key = strdup(key_);
for (tl=key+strlen(key)-1; tl >= key && *tl != '.'; --tl)
}
}
- git_config(show_config);
+ if (do_all && global)
+ git_config_from_file(show_config, global);
+ git_config_from_file(show_config, git_path("config"));
+ if (!do_all && !seen)
+ git_config_from_file(show_config, global);
+
free(key);
if (regexp) {
regfree(regexp);
version.1.2.3eX.alpha=beta
EOF
+# "HOME=." is there to avoid reading ~/.gitconfig
test_expect_success 'working --list' \
- 'git-repo-config --list > output && cmp output expect'
+ 'HOME=. git-repo-config --list > output && cmp output expect'
cat > expect << EOF
beta.noindent sillyValue