getenv/setenv: use constants if available
There were places using "GIT_DIR" instead of GIT_DIR_ENVIRONMENT and "GIT_CONFIG" instead of CONFIG_ENVIRONMENT. This makes it easier to find all places touching an environment variable using git grep or similar tools. Signed-off-by: Matthias Lederhofer <matled@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
59c93929c8
commit
7627943a1b
@ -178,14 +178,14 @@ 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("GIT_CONFIG", user_config, 1);
|
setenv(CONFIG_ENVIRONMENT, user_config, 1);
|
||||||
free(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("GIT_CONFIG", ETC_GITCONFIG, 1);
|
setenv(CONFIG_ENVIRONMENT, ETC_GITCONFIG, 1);
|
||||||
else if (!strcmp(argv[1], "--null") || !strcmp(argv[1], "-z")) {
|
else if (!strcmp(argv[1], "--null") || !strcmp(argv[1], "-z")) {
|
||||||
term = '\0';
|
term = '\0';
|
||||||
delim = '\n';
|
delim = '\n';
|
||||||
|
2
path.c
2
path.c
@ -252,7 +252,7 @@ char *enter_repo(char *path, int strict)
|
|||||||
|
|
||||||
if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
|
if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
|
||||||
validate_headref("HEAD") == 0) {
|
validate_headref("HEAD") == 0) {
|
||||||
setenv("GIT_DIR", ".", 1);
|
setenv(GIT_DIR_ENVIRONMENT, ".", 1);
|
||||||
check_repository_format();
|
check_repository_format();
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user