Merge branch 'db/no-git-config'
* db/no-git-config: Only use GIT_CONFIG in "git config", not other programs Conflicts: Documentation/RelNotes-1.6.0.txt
This commit is contained in:
commit
5e97f464df
@ -23,6 +23,11 @@ encoding introduced in v1.4.4. Pack idx files are using version 2 that
|
|||||||
allows larger packs and added robustness thanks to its CRC checking,
|
allows larger packs and added robustness thanks to its CRC checking,
|
||||||
introduced in v1.5.2.
|
introduced in v1.5.2.
|
||||||
|
|
||||||
|
GIT_CONFIG, which was only documented as affecting "git config", but
|
||||||
|
actually affected all git commands, now only affects "git config".
|
||||||
|
GIT_LOCAL_CONFIG, also only documented as affecting "git config" and
|
||||||
|
not different from GIT_CONFIG in a useful way, is removed.
|
||||||
|
|
||||||
|
|
||||||
Updates since v1.5.6
|
Updates since v1.5.6
|
||||||
--------------------
|
--------------------
|
||||||
|
@ -191,11 +191,6 @@ variables. The '--global' and the '--system' options will limit the file used
|
|||||||
to the global or system-wide file respectively. The GIT_CONFIG environment
|
to the global or system-wide file respectively. The GIT_CONFIG environment
|
||||||
variable has a similar effect, but you can specify any filename you want.
|
variable has a similar effect, but you can specify any filename you want.
|
||||||
|
|
||||||
The GIT_CONFIG_LOCAL environment variable on the other hand only changes
|
|
||||||
the name used instead of the repository configuration file. The global and
|
|
||||||
the system-wide configuration files will still be read. (For writing options
|
|
||||||
this will obviously result in the same behavior as using GIT_CONFIG.)
|
|
||||||
|
|
||||||
|
|
||||||
ENVIRONMENT
|
ENVIRONMENT
|
||||||
-----------
|
-----------
|
||||||
@ -205,10 +200,6 @@ GIT_CONFIG::
|
|||||||
Using the "--global" option forces this to ~/.gitconfig. Using the
|
Using the "--global" option forces this to ~/.gitconfig. Using the
|
||||||
"--system" option forces this to $(prefix)/etc/gitconfig.
|
"--system" option forces this to $(prefix)/etc/gitconfig.
|
||||||
|
|
||||||
GIT_CONFIG_LOCAL::
|
|
||||||
Take the configuration from the given file instead if .git/config.
|
|
||||||
Still read the global and the system-wide configuration files, though.
|
|
||||||
|
|
||||||
See also <<FILES>>.
|
See also <<FILES>>.
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,12 +81,10 @@ static int get_value(const char* key_, const char* regex_)
|
|||||||
char *global = NULL, *repo_config = NULL;
|
char *global = NULL, *repo_config = NULL;
|
||||||
const char *system_wide = NULL, *local;
|
const char *system_wide = NULL, *local;
|
||||||
|
|
||||||
local = getenv(CONFIG_ENVIRONMENT);
|
local = config_exclusive_filename;
|
||||||
if (!local) {
|
if (!local) {
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
local = getenv(CONFIG_LOCAL_ENVIRONMENT);
|
local = repo_config = xstrdup(git_path("config"));
|
||||||
if (!local)
|
|
||||||
local = repo_config = xstrdup(git_path("config"));
|
|
||||||
if (git_config_global() && home)
|
if (git_config_global() && home)
|
||||||
global = xstrdup(mkpath("%s/.gitconfig", home));
|
global = xstrdup(mkpath("%s/.gitconfig", home));
|
||||||
if (git_config_system())
|
if (git_config_system())
|
||||||
@ -289,6 +287,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||||||
char* value;
|
char* value;
|
||||||
const char *file = setup_git_directory_gently(&nongit);
|
const char *file = setup_git_directory_gently(&nongit);
|
||||||
|
|
||||||
|
config_exclusive_filename = getenv(CONFIG_ENVIRONMENT);
|
||||||
|
|
||||||
while (1 < argc) {
|
while (1 < argc) {
|
||||||
if (!strcmp(argv[1], "--int"))
|
if (!strcmp(argv[1], "--int"))
|
||||||
type = T_INT;
|
type = T_INT;
|
||||||
@ -309,14 +309,13 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||||||
char *home = getenv("HOME");
|
char *home = getenv("HOME");
|
||||||
if (home) {
|
if (home) {
|
||||||
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
|
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
|
||||||
setenv(CONFIG_ENVIRONMENT, user_config, 1);
|
config_exclusive_filename = user_config;
|
||||||
free(user_config);
|
|
||||||
} else {
|
} else {
|
||||||
die("$HOME not set");
|
die("$HOME not set");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[1], "--system"))
|
else if (!strcmp(argv[1], "--system"))
|
||||||
setenv(CONFIG_ENVIRONMENT, git_etc_gitconfig(), 1);
|
config_exclusive_filename = git_etc_gitconfig();
|
||||||
else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
|
else if (!strcmp(argv[1], "--file") || !strcmp(argv[1], "-f")) {
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
usage(git_config_set_usage);
|
usage(git_config_set_usage);
|
||||||
@ -325,7 +324,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
|||||||
argv[2]);
|
argv[2]);
|
||||||
else
|
else
|
||||||
file = argv[2];
|
file = argv[2];
|
||||||
setenv(CONFIG_ENVIRONMENT, file, 1);
|
config_exclusive_filename = file;
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
|
2
cache.h
2
cache.h
@ -298,7 +298,6 @@ static inline enum object_type object_type(unsigned int mode)
|
|||||||
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
|
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
|
||||||
#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
|
#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
|
||||||
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
|
#define CONFIG_ENVIRONMENT "GIT_CONFIG"
|
||||||
#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
|
|
||||||
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
|
#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
|
||||||
#define GITATTRIBUTES_FILE ".gitattributes"
|
#define GITATTRIBUTES_FILE ".gitattributes"
|
||||||
#define INFOATTRIBUTES_FILE "info/attributes"
|
#define INFOATTRIBUTES_FILE "info/attributes"
|
||||||
@ -743,6 +742,7 @@ extern int check_repository_format_version(const char *var, const char *value, v
|
|||||||
extern int git_config_system(void);
|
extern int git_config_system(void);
|
||||||
extern int git_config_global(void);
|
extern int git_config_global(void);
|
||||||
extern int config_error_nonbool(const char *);
|
extern int config_error_nonbool(const char *);
|
||||||
|
extern const char *config_exclusive_filename;
|
||||||
|
|
||||||
#define MAX_GITNAME (1000)
|
#define MAX_GITNAME (1000)
|
||||||
extern char git_default_email[MAX_GITNAME];
|
extern char git_default_email[MAX_GITNAME];
|
||||||
|
47
config.c
47
config.c
@ -16,6 +16,8 @@ static int config_linenr;
|
|||||||
static int config_file_eof;
|
static int config_file_eof;
|
||||||
static int zlib_compression_seen;
|
static int zlib_compression_seen;
|
||||||
|
|
||||||
|
const char *config_exclusive_filename = NULL;
|
||||||
|
|
||||||
static int get_next_char(void)
|
static int get_next_char(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
@ -611,31 +613,28 @@ int git_config(config_fn_t fn, void *data)
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *repo_config = NULL;
|
char *repo_config = NULL;
|
||||||
const char *home = NULL, *filename;
|
const char *home = NULL;
|
||||||
|
|
||||||
/* $GIT_CONFIG makes git read _only_ the given config file,
|
/* $GIT_CONFIG makes git read _only_ the given config file,
|
||||||
* $GIT_CONFIG_LOCAL will make it process it in addition to the
|
* $GIT_CONFIG_LOCAL will make it process it in addition to the
|
||||||
* global config file, the same way it would the per-repository
|
* global config file, the same way it would the per-repository
|
||||||
* config file otherwise. */
|
* config file otherwise. */
|
||||||
filename = getenv(CONFIG_ENVIRONMENT);
|
if (config_exclusive_filename)
|
||||||
if (!filename) {
|
return git_config_from_file(fn, config_exclusive_filename, data);
|
||||||
if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
|
if (git_config_system() && !access(git_etc_gitconfig(), R_OK))
|
||||||
ret += git_config_from_file(fn, git_etc_gitconfig(),
|
ret += git_config_from_file(fn, git_etc_gitconfig(),
|
||||||
data);
|
data);
|
||||||
home = getenv("HOME");
|
|
||||||
filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
|
|
||||||
if (!filename)
|
|
||||||
filename = repo_config = xstrdup(git_path("config"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
home = getenv("HOME");
|
||||||
if (git_config_global() && home) {
|
if (git_config_global() && home) {
|
||||||
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
|
char *user_config = xstrdup(mkpath("%s/.gitconfig", home));
|
||||||
if (!access(user_config, R_OK))
|
if (!access(user_config, R_OK))
|
||||||
ret = git_config_from_file(fn, user_config, data);
|
ret += git_config_from_file(fn, user_config, data);
|
||||||
free(user_config);
|
free(user_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += git_config_from_file(fn, filename, data);
|
repo_config = xstrdup(git_path("config"));
|
||||||
|
ret += git_config_from_file(fn, repo_config, data);
|
||||||
free(repo_config);
|
free(repo_config);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -873,13 +872,10 @@ int git_config_set_multivar(const char* key, const char* value,
|
|||||||
struct lock_file *lock = NULL;
|
struct lock_file *lock = NULL;
|
||||||
const char* last_dot = strrchr(key, '.');
|
const char* last_dot = strrchr(key, '.');
|
||||||
|
|
||||||
config_filename = getenv(CONFIG_ENVIRONMENT);
|
if (config_exclusive_filename)
|
||||||
if (!config_filename) {
|
config_filename = xstrdup(config_exclusive_filename);
|
||||||
config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
|
else
|
||||||
if (!config_filename)
|
config_filename = xstrdup(git_path("config"));
|
||||||
config_filename = git_path("config");
|
|
||||||
}
|
|
||||||
config_filename = xstrdup(config_filename);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since "key" actually contains the section name and the real
|
* Since "key" actually contains the section name and the real
|
||||||
@ -1136,13 +1132,10 @@ int git_config_rename_section(const char *old_name, const char *new_name)
|
|||||||
int out_fd;
|
int out_fd;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
config_filename = getenv(CONFIG_ENVIRONMENT);
|
if (config_exclusive_filename)
|
||||||
if (!config_filename) {
|
config_filename = xstrdup(config_exclusive_filename);
|
||||||
config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
|
else
|
||||||
if (!config_filename)
|
config_filename = xstrdup(git_path("config"));
|
||||||
config_filename = git_path("config");
|
|
||||||
}
|
|
||||||
config_filename = xstrdup(config_filename);
|
|
||||||
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
|
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
|
||||||
if (out_fd < 0) {
|
if (out_fd < 0) {
|
||||||
ret = error("could not lock config file %s", config_filename);
|
ret = error("could not lock config file %s", config_filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user