Re: [PATCH] git-init: set core.workdir when GIT_WORK_DIR is specified
From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:00
Hi, On Sun, 18 Mar 2007, Junio C Hamano wrote:
Matthias Lederhofer [off-list ref] writes:quoted
Junio C Hamano [off-list ref] wrote:quoted
Matthias Lederhofer [off-list ref] writes:quoted
* is_bare_repository() in generalThere 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 NULLLuckily, this is an area that two of the most active git regulars have touched, and I can rely on their judgement to help me ;-) What you describe sounds like a sane outline to me.
Yes, I like it, too (that is, I did not find an obvious flaw in it). Ciao, Dscho