summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-11-26 22:32:35 +0700
committerJunio C Hamano <gitster@pobox.com>2010-12-22 14:34:24 -0800
commite6aea2dba27798f5d1eca32435e407541caca400 (patch)
tree7372724ac020f4c03f78df146c64080e60748b79 /setup.c
parent337e51cedfdf1f98e1c151b72f06c7ca8bcea0fd (diff)
downloadgit-e6aea2dba27798f5d1eca32435e407541caca400.tar.gz
setup: limit get_git_work_tree()'s to explicit setup case only
get_git_work_tree() takes input as core.worktree, core.bare, GIT_WORK_TREE and decides correct worktree setting. Unfortunately it does not do its job well. core.worktree and GIT_WORK_TREE should only be taken into account, if GIT_DIR is set (which is handled by setup_explicit_git_dir). For other setup cases, only core.bare matters. Add a temporary variable setup_explicit to adjust get_git_work_tree() behavior as such. This variable will be gone once setup_* rework is done. Also remove is_bare_repository_cfg check in set_git_work_tree() to ease the rework. We are going to check for core.bare and core.worktree early before setting worktree. For example, if core.bare is true, no need to set worktree. 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 'setup.c')
-rw-r--r--setup.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/setup.c b/setup.c
index 49a1a2525a..c7d71986c0 100644
--- a/setup.c
+++ b/setup.c
@@ -331,6 +331,8 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
static char buffer[1024 + 1];
const char *retval;
+ if (startup_info)
+ startup_info->setup_explicit = 1;
if (PATH_MAX - 40 < strlen(gitdirenv))
die("'$%s' too big", GIT_DIR_ENVIRONMENT);
if (!is_git_directory(gitdirenv)) {
@@ -382,12 +384,15 @@ static const char *setup_discovered_git_dir(const char *work_tree_env,
char *cwd, int *nongit_ok)
{
int root_len;
+ char *work_tree;
inside_git_dir = 0;
if (!work_tree_env)
inside_work_tree = 1;
root_len = offset_1st_component(cwd);
- git_work_tree_cfg = xstrndup(cwd, offset > root_len ? offset : root_len);
+ work_tree = xstrndup(cwd, offset > root_len ? offset : root_len);
+ set_git_work_tree(work_tree);
+ free(work_tree);
if (check_repository_format_gently(gitdir, nongit_ok))
return NULL;
if (offset == len)
@@ -627,7 +632,8 @@ const char *setup_git_directory(void)
const char *retval = setup_git_directory_gently(NULL);
/* If the work tree is not the default one, recompute prefix */
- if (inside_work_tree < 0) {
+ if ((!startup_info || startup_info->setup_explicit) &&
+ inside_work_tree < 0) {
static char buffer[PATH_MAX + 1];
char *rel;
if (retval && chdir(retval))