On Thu, Oct 21, 2010 at 2:07 AM, Jonathan Nieder <jrnieder@xxxxxxxxx> 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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html