diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2014-11-30 15:24:44 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-12-01 11:00:15 -0800 |
commit | 31e26ebcb512ad234d9725120fb4f5670ff75625 (patch) | |
tree | 065370d0f48d3a715c888e2ee4bf796c45a11f16 /environment.c | |
parent | setup.c: detect $GIT_COMMON_DIR check_repository_format_gently() (diff) | |
download | tgif-31e26ebcb512ad234d9725120fb4f5670ff75625.tar.xz |
setup.c: support multi-checkout repo setup
The repo setup procedure is updated to detect $GIT_DIR/commondir and
set $GIT_COMMON_DIR properly.
The core.worktree is ignored when $GIT_COMMON_DIR is set. This is
because the config file is shared in multi-checkout setup, but
checkout directories _are_ different. Making core.worktree effective
in all checkouts mean it's back to a single checkout.
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'environment.c')
-rw-r--r-- | environment.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/environment.c b/environment.c index 050f1607d5..8351007b30 100644 --- a/environment.c +++ b/environment.c @@ -142,6 +142,7 @@ static char *git_path_from_env(const char *envvar, const char *git_dir, static void setup_git_env(void) { + struct strbuf sb = STRBUF_INIT; const char *gitfile; const char *shallow_file; @@ -150,12 +151,9 @@ static void setup_git_env(void) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT; gitfile = read_gitfile(git_dir); git_dir = xstrdup(gitfile ? gitfile : git_dir); - git_common_dir = getenv(GIT_COMMON_DIR_ENVIRONMENT); - if (git_common_dir) { + if (get_common_dir(&sb, git_dir)) git_common_dir_env = 1; - git_common_dir = xstrdup(git_common_dir); - } else - git_common_dir = git_dir; + git_common_dir = strbuf_detach(&sb, NULL); git_object_dir = git_path_from_env(DB_ENVIRONMENT, git_common_dir, "objects", &git_db_env); git_index_file = git_path_from_env(INDEX_ENVIRONMENT, git_dir, |