Re: handle_alias() inside .git dir
From: Jeff King <hidden>
Date: 2016-06-15 22:44:09
On Sat, Feb 02, 2008 at 04:02:20AM -0500, Kevin Ballard wrote:
This happens because setup_git_directory_gently() ends up setting GIT_DIR_ENVIRONMENT to "." if it detects that we are in the .git directory, and then a subsequent call to setup_git_directory() calls setup_git_directory_gently() again, which sees the GIT_DIR_ENVIRONMENT and ends up calling set_work_tree(). The comment to set_work_tree() says it's only called if GIT_DIR is set and calls what it does "old behavior". I assume it exists for some sort of backwards compatibility, but in quick testing simply commenting out line 266 of setup.c (the call to set_work_tree) makes `git st` work as expected. I'm not sure if this will have any adverse effect on anything else. Does anybody know if this will cause problems?
No, I don't think that's right. That call is there for people who have explicitly set GIT_DIR to use their cwd as the working tree, wherever it may be. The problem is that setup_git_directory_gently actually _sets_ GIT_DIR. So the next time through when we call setup_git_directory_gently again, it thinks you have set it in the environment, which has the special meaning. Unfortunately, it doesn't look like there's a simple fix. Because the semantics of the two are related, I think we need to set GIT_WORK_TREE whenever we set GIT_DIR, and we need some way of setting GIT_WORK_TREE to a value that means "I don't have a work tree." -Peff