Skip to content

Commit

Permalink
Support for extracting configuration from different files
Browse files Browse the repository at this point in the history
Add $GIT_CONFIG environment variable whose content is used instead
of .git/config if set. Also add $GIT_CONFIG_LOCAL as a
forward-compatibility cue for whenever we will finally come to support]
global configuration files (properly).

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Petr Baudis authored and Junio C Hamano committed Jun 19, 2006
1 parent 64e86c5 commit 7f29f7a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Documentation/git-repo-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ OPTIONS
List all variables set in .git/config.


ENVIRONMENT
-----------

GIT_CONFIG::
Take the configuration from the given file instead of .git/config.

GIT_CONFIG_LOCAL::
Currently the same as $GIT_CONFIG; when Git will support global
configuration files, this will cause it to take the configuration
from the global configuration file in addition to the given file.


EXAMPLE
-------

Expand Down
12 changes: 11 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,17 @@ int git_config_from_file(config_fn_t fn, const char *filename)

int git_config(config_fn_t fn)
{
return git_config_from_file(fn, git_path("config"));
const char *filename = git_path("config");
/* Forward-compatibility cue: $GIT_CONFIG makes git read _only_
* the given config file, $GIT_CONFIG_LOCAL will make it process
* it in addition to the global config file, the same way it would
* the per-repository config file otherwise. */
if (getenv("GIT_CONFIG")) {
filename = getenv("GIT_CONFIG");
} else if (getenv("GIT_CONFIG_LOCAL")) {
filename = getenv("GIT_CONFIG_LOCAL");
}
return git_config_from_file(fn, filename);
}

/*
Expand Down

0 comments on commit 7f29f7a

Please sign in to comment.