diff --git a/builtin-init-db.c b/builtin-init-db.c index 2a20737249..31427c571d 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -318,9 +318,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) /* * Set up the default .git directory contents */ - git_dir = getenv(GIT_DIR_ENVIRONMENT); - if (!git_dir) - git_dir = DEFAULT_GIT_DIR_ENVIRONMENT; + git_dir = get_git_dir(); safe_create_dir(git_dir, 0); /* Check to see if the repository version is right. diff --git a/git.c b/git.c index 1f7f595653..5fc277c895 100644 --- a/git.c +++ b/git.c @@ -67,14 +67,14 @@ static int handle_options(const char*** argv, int* argc, int* envchanged) fprintf(stderr, "No directory given for --git-dir.\n" ); usage(git_usage_string); } - setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1); + set_git_dir( (*argv)[1] ); if (envchanged) *envchanged = 1; (*argv)++; (*argc)--; handled++; } else if (!prefixcmp(cmd, "--git-dir=")) { - setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1); + set_git_dir(cmd + 10); if (envchanged) *envchanged = 1; } else if (!strcmp(cmd, "--work-tree")) { @@ -93,7 +93,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged) *envchanged = 1; } else if (!strcmp(cmd, "--bare")) { static char git_dir[PATH_MAX+1]; - setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1); + set_git_dir(getcwd(git_dir, sizeof(git_dir))); if (envchanged) *envchanged = 1; } else { diff --git a/path.c b/path.c index a1139d483b..7a5ac5b067 100644 --- a/path.c +++ b/path.c @@ -265,7 +265,7 @@ char *enter_repo(char *path, int strict) if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 && validate_headref("HEAD") == 0) { - setenv(GIT_DIR_ENVIRONMENT, ".", 1); + set_git_dir("."); check_repository_format(); return path; } diff --git a/setup.c b/setup.c index 5a8e7b6b52..0de8dcd61b 100644 --- a/setup.c +++ b/setup.c @@ -332,7 +332,7 @@ const char *setup_git_directory_gently(int *nongit_ok) inside_git_dir = 1; if (!work_tree_env) inside_work_tree = 0; - setenv(GIT_DIR_ENVIRONMENT, ".", 1); + set_git_dir("."); return NULL; } chdir("..");