git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: handle_alias() inside .git dir

From
Jeff King <peff@peff.net>
Date
Feb 3, 2008, 04:57 UTC
Message-ID
<20080203045738.GA10660@coredump.intra.peff.net>
In-Reply-To
<837649D4-465F-4C85-BBE8-B004637EDEF7@sb.org>
On Sat, Feb 02, 2008 at 04:02:20AM -0500, Kevin Ballard wrote:
Show 11 quoted lines
> 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
Previous: Kevin Ballard
Message 2 of 2 in “handle_alias() inside .git dir”
  1. Kevin BallardFeb 2, 2008
  2. Jeff KingFeb 3, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.