Re: [PATCH] git-init: set core.workdir when GIT_WORK_DIR is specified
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 19, 2007, 14:24 UTC
- Message-ID
- <Pine.LNX.4.63.0703191523520.22628@wbgn013.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <7vk5xensjn.fsf@assigned-by-dhcp.cox.net>
Hi,
On Sun, 18 Mar 2007, Junio C Hamano wrote:
Show 46 quoted lines
> Matthias Lederhofer <matled@gmx.net> writes: > > > Junio C Hamano <junkio@cox.net> wrote: > >> Matthias Lederhofer <matled@gmx.net> 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 > > Luckily, 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