aboutsummaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2017-06-22 11:43:33 -0700
committerJunio C Hamano <gitster@pobox.com>2017-06-23 18:24:34 -0700
commitc14c234f22e0656a61f5718baf155118e6e609c9 (patch)
tree7d3ed4c29cef99e9dfc1d2e043c93c2e1b8068c9 /setup.c
parent359efeffc1f16443be18a80b91ba7cd356eb34f1 (diff)
downloadgit-c14c234f22e0656a61f5718baf155118e6e609c9.tar.gz
git-c14c234f22e0656a61f5718baf155118e6e609c9.tar.xz
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 'setup.c')
-rw-r--r--setup.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/setup.c b/setup.c
index b477faa44..860507e1f 100644
--- a/setup.c
+++ b/setup.c
@@ -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);