Re: [PATCH] Add missing inside_work_tree setting in setup_git_directory_gently
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Nov 3, 2007, 12:16 UTC
- Message-ID
- <Pine.LNX.4.64.0711031211520.4362@racer.site>
- In-Reply-To
- <fcaeb9bf0711030457se2f5f5bpd9aa463e878cd621@mail.gmail.com>
Hi,
On Sat, 3 Nov 2007, Nguyen Thai Ngoc Duy wrote:
Show 33 quoted lines
> On 11/3/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > On Sat, 3 Nov 2007, Nguyễn Thái Ngọc Duy wrote:
> >
> > > Without this, work_tree handling code in setup_git_directory will be
> > > activated. If you stay in root work tree (no prefix), it does not
> > > harm. It does if you work from a subdirectory though.
> > >
> > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> > > ---
> > > Turns out my patch on NEED_WORK_TREE is fixing a wrong place.
> > >
> > > setup.c | 1 +
> > > 1 files changed, 1 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/setup.c b/setup.c
> > > index 145eca5..6f8f769 100644
> > > --- a/setup.c
> > > +++ b/setup.c
> > > @@ -240,6 +240,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
> > > if (chdir(work_tree_env) < 0)
> > > die ("Could not chdir to %s", work_tree_env);
> > > strcat(buffer, "/");
> > > + inside_work_tree = 1;
> >
> > I really have to wonder why this is needed, as it should be deduced
> > (correctly!) when you ask is_inside_work_tree().
>
> Because setup_git_directory() does not? From what I see,
> setup_git_directory() calls setup_git_directory_gently() then check
> for inside_work_tree variable almost immediately
> (check_repository_format() does not seem to ask
> is_inside_work_tree()).Ah, I see the problem.
>From your commit message I assumed that you fixed the wrong spot... Which
you did not. It would have helped me if the message had read:
When both GIT_DIR and GIT_WORK_TREE are set, and setup_git_directory_gently() changes the current working directory accordingly, it should also set inside_work_tree = 1.
Your fix is the proper one, but it not only fixes setup_git_directory(), but all callers of setup_git_directory_gently().
Thanks, Dscho