threads / discuss / 20690

hitting home directory's parent

Subject: hitting home directory's parent

## tl;dr

11 messages between Aug 21, 2009 and Aug 25, 2009.

replies: 10people: 3as markdown or json

Daniel Convissor· Aug 21, 2009, 20:05 UTC · lore
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.
-- 
 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-0409
Nguyen Thai Ngoc Duy· Aug 22, 2009, 04:10 UTC · re: Daniel Convissor · lore

Re: hitting home directory's parent

On Sat, Aug 22, 2009 at 3:05 AM, Daniel Convissor<danielc@analysisandsolutions.com> wrote:

Show 19 quoted lines
> 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?

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
Daniel Convissor· Aug 22, 2009, 15:05 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: hitting home directory's parent

Hi Duy:
On Sat, Aug 22, 2009 at 11:10:18AM +0700, Nguyen Thai Ngoc Duy wrote:
> 
> 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
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
-- 
 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-0409
Nguyen Thai Ngoc Duy· Aug 22, 2009, 16:20 UTC · re: Daniel Convissor · lore

Re: hitting home directory's parent

On Sat, Aug 22, 2009 at 10:05 PM, Daniel Convissor<danielc@analysisandsolutions.com> wrote:

Show 9 quoted lines
> Hi Duy:
>
> On Sat, Aug 22, 2009 at 11:10:18AM +0700, Nguyen Thai Ngoc Duy wrote:
>>
>> 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
>
> That 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.
Show 5 quoted 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.

-- 
Duy
Nguyen Thai Ngoc Duy· Aug 22, 2009, 16:22 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: hitting home directory's parent

On Sat, Aug 22, 2009 at 11:20 PM, Nguyen Thai Ngoc Duy<pclouds@gmail.com> wrote:
Show 9 quoted lines
> 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.
-- 
Duy
Jeff King· Aug 22, 2009, 18:16 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: hitting home directory's parent

On Sat, Aug 22, 2009 at 11:20:39PM +0700, Nguyen Thai Ngoc Duy wrote:
Show 9 quoted 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
Nguyen Thai Ngoc Duy· Aug 23, 2009, 04:07 UTC · re: Jeff King · lore

Re: hitting home directory's parent

On Sun, Aug 23, 2009 at 1:16 AM, Jeff King<peff@peff.net> wrote:
Show 21 quoted lines
> On Sat, Aug 22, 2009 at 11:20:39PM +0700, Nguyen Thai Ngoc Duy wrote:
>
>> > 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().

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.

-- 
Duy
Jeff King· Aug 25, 2009, 04:42 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: hitting home directory's parent

On Sun, Aug 23, 2009 at 11:07:39AM +0700, Nguyen Thai Ngoc Duy wrote:
Show 7 quoted lines
> 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.

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
Daniel Convissor· Aug 23, 2009, 05:12 UTC · re: Jeff King · lore

Re: hitting home directory's parent

Hi Jeff:
On Sat, Aug 22, 2009 at 02:16:07PM -0400, Jeff King wrote:
> 
> 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.

> 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().
Yep.  setup.c, lines 391 and 392 (master branch):
		if (chdir(".."))
			die_errno("Cannot change to '%s/..'", cwd);
> 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
-- 
 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-0409
Jeff King· Aug 25, 2009, 04:48 UTC · re: Daniel Convissor · lore

Re: hitting home directory's parent

On Sun, Aug 23, 2009 at 01:12:44AM -0400, Daniel Convissor wrote:
> 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.

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.

> 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
Daniel Convissor· Aug 23, 2009, 04:42 UTC · re: Nguyen Thai Ngoc Duy · lore

Re: hitting home directory's parent

Hi Duy:
On Sat, Aug 22, 2009 at 11:20:39PM +0700, Nguyen Thai Ngoc Duy wrote:
Show 14 quoted lines
> On Sat, Aug 22, 2009 at 10:05 PM, Daniel
> Convissor<danielc@analysisandsolutions.com> wrote:
> > Hi Duy:
> >
> > On Sat, Aug 22, 2009 at 11:10:18AM +0700, Nguyen Thai Ngoc Duy wrote:
> >>
> >> 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
> >
> > That 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. :)
> 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
-- 
 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-0409

← back to recent threads