Nguyen Thai Ngoc Duy wrote: > 1. When .git is a file and contains a relative path, I assume it is > relative to .git file's parent directory. read_gitfile_gently() > function will make the path absolute, but it depends on (maybe > wrong) cwd. Yep. > 2. Relative path is preferred over absolute path. I'm tempted to say: let's use absolute paths where it's more convenient. They can be changed to relative paths as an afterthought after the bugs are gone. Relative paths have two big advantages over absolute paths, which are avoiding path traversal overhead and allowing paths longer than PATH_MAX. Supporting the latter consistently would presumably require using openat() and co, though. > 3. core.worktree is overidden by GIT_WORK_TREE Yeah. > 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? A. Weird cases. - using a .git file is just like setting GIT_DIR; - setting core.worktree is just like setting GIT_WORK_TREE. B. Repository search. - if GIT_DIR was set explicitly, GIT_WORK_TREE defaults to "." (for legacy reasons). - 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. - 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). - otherwise, there is no repository. GIT_DIR is unset, GIT_WORK_TREE defaults to unset. C. Working directory and prefix - if GIT_WORK_TREE is still unset after repository search, stay in the original cwd, prefix = NULL. - if original cwd is inside worktree, chdir to toplevel, prefix = path to original cwd. - otherwise, stay in the original cwd, prefix = NULL. 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 - paths passed to git commands are generally relative to original cwd E. Internally used relative paths. - all paths are relative to current cwd. -- 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