diff options
author | Brandon Williams <bmwill@google.com> | 2017-06-22 20:43:33 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-24 03:24:34 +0200 |
commit | c14c234f22e0656a61f5718baf155118e6e609c9 (patch) | |
tree | 7d3ed4c29cef99e9dfc1d2e043c93c2e1b8068c9 /setup.c | |
parent | repository: introduce the repository object (diff) | |
download | git-c14c234f22e0656a61f5718baf155118e6e609c9.tar.xz git-c14c234f22e0656a61f5718baf155118e6e609c9.zip |
environment: place key repository state in the_repository
Migrate 'git_dir', 'git_common_dir', 'git_object_dir', 'git_index_file',
'git_graft_file', and 'namespace' to be stored in 'the_repository'.
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rw-r--r-- | setup.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -1,4 +1,5 @@ #include "cache.h" +#include "repository.h" #include "config.h" #include "dir.h" #include "string-list.h" @@ -398,6 +399,11 @@ void setup_work_tree(void) if (getenv(GIT_WORK_TREE_ENVIRONMENT)) setenv(GIT_WORK_TREE_ENVIRONMENT, ".", 1); + /* + * NEEDSWORK: this call can essentially be set_git_dir(get_git_dir()) + * which can cause some problems when trying to free the old value of + * gitdir. + */ set_git_dir(remove_leading_path(git_dir, work_tree)); initialized = 1; } @@ -1108,8 +1114,15 @@ const char *setup_git_directory_gently(int *nongit_ok) * the user has set GIT_DIR. It may be beneficial to disallow bogus * GIT_DIR values at some point in the future. */ - if (startup_info->have_repository || getenv(GIT_DIR_ENVIRONMENT)) - setup_git_env(); + if (startup_info->have_repository || getenv(GIT_DIR_ENVIRONMENT)) { + if (!the_repository->gitdir) { + const char *gitdir = getenv(GIT_DIR_ENVIRONMENT); + if (!gitdir) + gitdir = DEFAULT_GIT_DIR_ENVIRONMENT; + repo_set_gitdir(the_repository, gitdir); + setup_git_env(); + } + } strbuf_release(&dir); strbuf_release(&gitdir); |