On Sat, Nov 03, 2007 at 09:33:40PM -0700, Junio C Hamano wrote: > Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> writes: > > > When both GIT_DIR and GIT_WORK_TREE are set, and > > setup_git_directory_gently() changes the current working > > directory accordingly, it should also set inside_work_tree = 1. > > > > Without this, work_tree handling code in setup_git_directory() > > will be activated. If you stay in root work tree (no prefix), > > it does not harm. It does if you work from a subdirectory though. > > Please add automated test script for this, thanks. > Thank you for reminding. I tried to put a test in t1501-worktree.sh and found out core.worktree can override inside_work_tree previously set by setup_git_directory_gently(), activating the worktree code in setup_git_directory() again. This made me think setup_git_directory_gently() should use get_git_work_tree() instead. But then git_work_tree_cfg may not be initialized when get_git_work_tree() is called (starting from setup_git_directory(), git_work_tree_cfg is initialized in check_repository_format_version(), which is called _after_ setup_git_directory_gently()). The interaction between these variables and functions is really beyond my knowledge. Johannes, can you have a look at this? In theory the following test should pass: diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 7ee3820..bdb7720 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -103,6 +103,11 @@ test_expect_success 'repo finds its work tree from work tree, too' ' test sub/dir/tracked = "$(git ls-files)") ' +test_expect_success 'Try a command from subdir in worktree' ' + (cd repo.git/work/sub && + GIT_DIR=../.. GIT_WORK_TREE=.. git blame dir/tracked) +' + test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' ' cd repo.git/work/sub/dir && GIT_DIR=../../.. GIT_WORK_TREE=../.. GIT_PAGER= \ -- 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