git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* handle_alias() inside .git dir
@ 2008-02-02  9:02 Kevin Ballard
  2008-02-03  4:57 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Ballard @ 2008-02-02  9:02 UTC (permalink / raw
  To: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]

It seems that using any aliases while inside a .git dir will end up  
setting the work tree to the current dir, even though it's clearly not  
a work tree. This means that having an alias like `git config alias.st  
= status` and running `git st` inside a .git dir will proceed to spit  
out a listing that claims that every file in the project is missing  
rather than displaying an error about not being in a work tree like  
`git status` will show.

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?

Another option that seems like it should work is checking if we're a  
bare repo, and if not then setting the work tree to our parent dir,  
assuming any relevant config values or env variables aren't set that  
would point elsewhere. I would try and implement this but after  
looking at it for a few minutes, I fear 4AM is not the best of times  
to try and figure out how this code works.

-Kevin Ballard

-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com



[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2432 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: handle_alias() inside .git dir
  2008-02-02  9:02 handle_alias() inside .git dir Kevin Ballard
@ 2008-02-03  4:57 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2008-02-03  4:57 UTC (permalink / raw
  To: Kevin Ballard; +Cc: Git Mailing List

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-03  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-02  9:02 handle_alias() inside .git dir Kevin Ballard
2008-02-03  4:57 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).