hitting home directory's parent
Hi:
I just installed git in my Cygwin installation for the first time. The git version is 1.6.1.2, which is the latest version they have. When I enter one of the following commands:
git --help
git config --global user.name "Daniel Convissor"I get this error:
fatal: Cannot change to /home/danielc/..: Permission denied
Though "git --version" executes fine.
I've been using Cygwin for many years and no other program has ever produced this issue for me. For example, svn --help, ls --help, etc work just fine.
Why is git venturing into to the home directory's parent directory? Is this a bug? If not, is this really necessary?
Thanks,
--Dan
PS: I'm not subscribed to the list.
Signature · 4 lines
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409Quoted 11 lines · Daniel Convissor
Hi:
I just installed git in my Cygwin installation for the first time. The git version is 1.6.1.2, which is the latest version they have. When I enter one of the following commands:
git --help
git config --global user.name "Daniel Convissor"I get this error:
fatal: Cannot change to/home/danielc/..: Permission denied
Quoted 8 lines
Though "git --version" executes fine.
I've been using Cygwin for many years and no other program has ever produced this issue for me. For example, svn --help, ls --help, etc work just fine.
Why is git venturing into to the home directory's parent directory? Is this a bug? If not, is this really necessary?
I guess it tried to find .git directory upward. I think you can set GIT_CEILING_DIRECTORIES to make it stop at /home/danielc. Excerpt from git.txt
-'GIT_CEILING_DIRECTORIES'::
This should be a colon-separated list of absolute paths. If set, it is a list of directories that git should not chdir up into while looking for a repository directory. It will not exclude the current working directory or a GIT_DIR set on the command line or in the environment. (Useful for excluding slow-loading network directories.)
-
Duy
Hi Duy:
Quoted 4 lines · Nguyen Thai Ngoc Duy
I guess it tried to find .git directory upward. I think you can set
GIT_CEILING_DIRECTORIESto make it stop at/home/danielc. Excerpt from git.txt
That didn't change the situation.
I did read a bit farther in the manual and initialized a new repository. Issuing "git --help" once inside that new repository works. Requiring the --help command to be called from inside a repository, or even that it's looking for a repository at all, seems unwise. All it should do is display the usage information and exit.
Thanks,
--Dan
Signature · 4 lines
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409Quoted 9 lines · Daniel Convissor
Hi Duy:
Quoted 4 lines · Nguyen Thai Ngoc Duy
I guess it tried to find .git directory upward. I think you can set
GIT_CEILING_DIRECTORIESto make it stop at/home/danielc. Excerpt from git.txtThat didn't change the situation.
I'd suggest you to degrade Git to a version earlier than 1.6.1, when the error was not added. :-D
But did it at least change the error message? Here is what I got when "chmod 000 /tmp/a":
/tmp/a/b/c $ cd ../..
bash: cd: ../..: Permission denied/tmp/a/b/c $ git --help
fatal: Cannot change to '/tmp/a/b/c/..': Permission denied /tmp/a/b/c $ GIT_CEILING_DIRECTORIES=/tmp/a/b git --help
fatal: Cannot come back to cwd: Permission denied
Looks like absolute path will cause troubles anyway this case.
Quoted 5 lines
I did read a bit farther in the manual and initialized a new repository. Issuing "git --help" once inside that new repository works. Requiring the --help command to be called from inside a repository, or even that it's looking for a repository at all, seems unwise. All it should do is display the usage information and exit.
For simple things like --help, I agree Git should not do extra work such as searching for Git repository, which is the cause. That was on Jeff's plan IIRC.
Signature · 1 line
Duy
Quoted 9 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines
I did read a bit farther in the manual and initialized a new repository. Issuing "git --help" once inside that new repository works. Requiring the --help command to be called from inside a repository, or even that it's looking for a repository at all, seems unwise. All it should do is display the usage information and exit.
For simple things like --help, I agree Git should not do extra work such as searching for Git repository, which is the cause. That was on Jeff's plan IIRC.
Without looking, I would not be surprised if it is a side effect of git trying to look up help-related config. So I don't think it is a problem exactly that it checks to see if it is in a repo (which would impact config lookup), but that inability to find a repo is a hard error.
Probably it is calling "setup_git_directory_gently" and ignoring an error return, but there is a die() inside that function. The bug then is that the _gently form is calling die().
As for fixing the setup code, I am sadly way behind on my git queue and not likely to catch up to this anytime soon. So if anybody feels like taking a stab at it, that would be very welcome.
-Peff
Hi Jeff:
Quoted 3 lines · Jeff King
Without looking, I would not be surprised if it is a side effect of git trying to look up help-related config.
That explains what's happening. cmd_help() calls git_config(). Though it seems it would be more, uh, helpful, if help produced basic usage output no matter what, and then produce the more detailed config based output if possible.
Quoted 3 lines
Probably it is calling "
setup_git_directory_gently" and ignoring an error return, but there is adie()inside that function. The bug then is that the_gentlyform is callingdie().
Yep. setup.c, lines 391 and 392 (master branch):
if (chdir(".."))
die_errno("Cannot change to '%s/..'", cwd);Quoted 3 lines
As for fixing the setup code, I am sadly way behind on my git queue and not likely to catch up to this anytime soon. So if anybody feels like taking a stab at it, that would be very welcome.
Is there a bug tracker y'all use where I can enter a ticket?
Thanks,
--Dan
Signature · 4 lines
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409Quoted 4 lines · Daniel Convissor
That explains what's happening.
cmd_help()callsgit_config(). Though it seems it would be more, uh, helpful, if help produced basic usage output no matter what, and then produce the more detailed config based output if possible.
I agree, but the way the code is structured right now means doing this right is probably a pretty big change (see my other message to Duy). So I think it will probably go unfixed for the time being.
Quoted 1 line
Is there a bug tracker y'all use where I can enter a ticket?
We don't have a formal bug tracker, but this is really just a sub-part of another issue, so it will get addressed when the parent issue is fixed.
-Peff
Quoted 18 lines · Jeff King
Quoted 9 lines · Nguyen Thai Ngoc Duy
Quoted 5 lines
I did read a bit farther in the manual and initialized a new repository. Issuing "git --help" once inside that new repository works. Requiring the --help command to be called from inside a repository, or even that it's looking for a repository at all, seems unwise. All it should do is display the usage information and exit.
For simple things like --help, I agree Git should not do extra work such as searching for Git repository, which is the cause. That was on Jeff's plan IIRC.
Without looking, I would not be surprised if it is a side effect of git trying to look up help-related config. So I don't think it is a problem exactly that it checks to see if it is in a repo (which would impact config lookup), but that inability to find a repo is a hard error.
Quoted 3 lines
Probably it is calling "
setup_git_directory_gently" and ignoring an error return, but there is adie()inside that function. The bug then is that the_gentlyform is callingdie().
It is (and should be worked around with GIT_CEILING_DIRECTORIES). Unfortunately in my test, it could not chdir() back when it failed to find gitdir. chdir() was called with an absolute directory, and one directory in that path was inaccesible, leading another die("Cannot come back to cwd"). This one is fatal and should not be ignored. I don't know whether having an inaccesible parent directory is a real scenario, as lots of tools would break.
Signature · 1 line
Duy
Quoted 7 lines · Nguyen Thai Ngoc Duy
It is (and should be worked around with
GIT_CEILING_DIRECTORIES). Unfortunately in my test, it could notchdir()back when it failed to find gitdir.chdir()was called with an absolute directory, and one directory in that path was inaccesible, leading anotherdie("Cannot come back to cwd"). This one is fatal and should not be ignored. I don't know whether having an inaccesible parent directory is a real scenario, as lots of tools would break.
Hmm, good point. Some of those die()s really can't be removed, because we have munged state in a way that can't be recovered (or is hard to recover).
Also, thinking about it a bit more, I'm not sure it is correct to turn such a die() into a "return -1" without passing more information along to the caller. Because there are really three possible outcomes:
1. we are in a git repo
2. we are not in a git repo
3. some error occurred and we could not determine which of (1) and (2) is the case
And the "gently" bit really just refers to (1) versus (2). It is tempting to fold (3) into (2), but I'm not sure that is the right thing to do; some callers (including script callers not under our control) may care about the distinction (though I think we already blur it; for example, a non-existent '.git' regular file is treated the same as one which we couldn't stat for permission problems).
So perhaps the right thing is to either pass back a tri-state status, or to have an extra_gently mode, either of which could be used by "git help". The problem with either is that the current setup process is not amenable to exiting in the middle -- it really may leave us in a weird and buggy state due to the chdir.
So short of major surgery on the setup procedure, I think we may have to leave this bug be for now (especially because I'm not convinced the setup of a non-executable parent directory isn't a little bit crazy).
-Peff
Hi Duy:
Quoted 6 lines · Nguyen Thai Ngoc Duy
Quoted 4 lines · Daniel Convissor
Hi Duy:
Quoted 1 line · Nguyen Thai Ngoc Duy
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I guess it tried to find .git directory upward. I think you can set
GIT_CEILING_DIRECTORIESto make it stop at/home/danielc. Excerpt from git.txtThat didn't change the situation.
I'd suggest you to degrade Git to a version earlier than 1.6.1, when the error was not added. :-D
:) Might be easier to use "svn ci" instead. :)
Quoted 2 lines
But did it at least change the error message? Here is what I got when "chmod 000
/tmp/a":
No. It produced the same exact error message:
fatal: Cannot change to /home/danielc/..: Permission denied
Thanks,
--Dan
Signature · 4 lines
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409Quoted 9 lines · Nguyen Thai Ngoc Duy
But did it at least change the error message? Here is what I got when "chmod 000
/tmp/a":
/tmp/a/b/c$ cd ../..
bash: cd: ../..: Permission denied/tmp/a/b/c$ git --help
fatal: Cannot change to '/tmp/a/b/c/..': Permission denied/tmp/a/b/c$ GIT_CEILING_DIRECTORIES=/tmp/a/b git --help
fatal: Cannot come back to cwd: Permission denied
Note: I tested it on Linux, not Cygwin so the behavior may differ.
Signature · 1 line
Duy