From: Nguyen Thai Ngoc Duy Date: Thu, 21 Oct 2010 01:46:44 GMT Subject: Re: [long] worktree setup cases Message-ID: In-Reply-To: <20101020190709.GB10537@burratino> On Thu, Oct 21, 2010 at 2:07 AM, Jonathan Nieder wrote: >> So there are 2^5 = 32 cases in total. Let's look at them one by >> one. > > Thanks!  To summarize (and make sure I understand correctly): > anything not following the below rules is a bug, yes? Let's see. > A. Weird cases. > >  - using a .git file is just like setting GIT_DIR; Yes, except that GIT_DIR can be detected early when cwd has not been moved. When .git is found a file, cwd could have been changed. > B. Repository search. > >  - if GIT_DIR was set explicitly, GIT_WORK_TREE defaults to >   "." (for legacy reasons). Correct. >  - otherwise, if original cwd was under repository, it will not >   prompt a search for work tree, even if the repo happens >   to be named ".git" or core.bare is false.  That is, in >   this case, GIT_WORK_TREE defaults to unset. What do you mean by "under repository"? If the repo is /tmp/git/.git, then cwd is at /tmp/git/.git? >  - otherwise, if original cwd was under a directory containing >   repository as ".git", GIT_WORK_TREE defaults to that >   directory (i.e., parent to .git dir). Yes. >  - otherwise, there is no repository.  GIT_DIR is unset, >   GIT_WORK_TREE defaults to unset. - Otherwise, move up one dir and repeat? > C. Working directory and prefix > >  - if GIT_WORK_TREE is still unset after repository search, >   stay in the original cwd, prefix = NULL. if GIT_WORK_TREE and core.worktree are still unset, we get a bare repo here (or force it to be a bare repo), so yes, cwd should stay in original cwd and prefix = NULL. >  - if original cwd is inside worktree, chdir to toplevel, >   prefix = path to original cwd. Yes. >  - otherwise, stay in the original cwd, prefix = NULL. I'm not really happy with this, which is why I wrote the --cwd-to-worktree and --worktree-to-cwd patch. But this should be enough for full-tree operations to work, so yes. > D. User-supplied relative paths. > >  - path in .git file is relative to containing directory >  - path in GIT_DIR is relative to original cwd >  - paths in GIT_WORK_TREE and core.worktree are relative to >   $GIT_DIR I think $GIT_WORK_TREE is relative to original cwd. Yes, core.worktree should be relative to $GIT_DIR. >  - paths passed to git commands are generally relative to >   original cwd And filename output should also be relative to original cwd (except a few special, like diff output). > E. Internally used relative paths. > >  - all paths are relative to current cwd. Yes. -- Duy