From: Matthias Lederhofer Date: Sun, 18 Mar 2007 21:18:36 GMT Subject: Re: [PATCH] git-init: set core.workdir when GIT_WORK_DIR is specified Message-ID: <20070318211836.GA12456@moooo.ath.cx> In-Reply-To: <7vr6rnlyzt.fsf@assigned-by-dhcp.cox.net> Junio C Hamano wrote: > Matthias Lederhofer writes: > > * is_bare_repository() in general > > There is a bit of chicken and egg involved in is_bare, because > we need to find out where GIT_DIR is in order to find where to > read GIT_DIR/config from, and only after reading the file we > would know if the user explicitly told us the repository is > bare, and setup_gently does not want to cd-up if the repository > is bare (i.e. there is no "top" to move to). How about changing setup_git_directory_gently to do the following: Find the git directory ($GIT_DIR, .git in parent directories and "." at last). Read configuration for core.bare and core.worktree. If core.bare is not specified do the old guessing. if core.bare = true: Set GIT_DIR if it isn't set yet and stop (don't change the directory). if core.bare = false: GIT_DIR specified: use GIT_WORK_TREE, core.worktree or "." as working tree found repository as .git directory: use the parent directory of the .git directory as working tree found repository in ".": use "." as working tree if cwd is below the working tree: change to working tree inside_work_tree = 1 return prefix if cwd is outside of the working tree: inside_work_tree = 0 return NULL