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

Re: [PATCH] setup_git_directory: Setup cwd properly if worktree is found

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Nov 27, 2007, 14:12 UTC
Message-ID
<fcaeb9bf0711270612p52ce20eaue39eac1d529c3fd3@mail.gmail.com>
In-Reply-To
<Pine.LNX.4.64.0711121224430.4362@racer.site>
On Nov 12, 2007 7:31 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 38 quoted lines
> Hi,
>
> On Mon, 12 Nov 2007, Nguyen Thai Ngoc Duy wrote:
>
> > On Nov 12, 2007 6:57 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> >
> > > But what about setup_git_directory_gently()?  If the working tree is
> > > overridden by the config, this function is still bogus, right?
> >
> > Hmm.. thinking a little bit more. I guess you're right because
> > GIT_WORK_TREE takes precedence over core.worktree. Maybe some more bits
> > for check_repository_format_version(). Tough decision because, from the
> > value of inside_work_tree, we don't know if we can safely skip
> > overriding inside_work_tree.
>
> I was thinking about adding check_repository_format_version() and a check
> for inside_work_tree < 0 with obvious handling in two places, probably as
> a function:  first, when we have a gitdirenv but no work_tree_env, and
> second, at the end of _gently() when we found a git dir but only if
> work_tree_env was not set.
>
> > > As far as I see, setup_git_directory_gently() only works correctly
> > > when core.worktree is _not_ set, unless GIT_WORK_TREE is set (which is
> > > supposed to override the config setting).  Note: I treat GIT_WORK_TREE
> > > the same as --work-tree, since at that time they are identical.
> > >
> > > Maybe the config stuff has to move into _gently()?
> >
> > Well, it could be a bit more complicated because you need to know
> > GIT_DIR first before reading config. I'd rather not move as _gently()
> > is complicated already.
>
> AFAICT it is not a question of complexity, but of correctness.  Wouldn't
> you agree that the prefix _gently() returns is wrong if we don't fix it?
>
> Besides, it might be needed anyway if we are serious about the version
> check.  This check, however, would have to be done _whenever_ we found a
> git directory, not only when work_tree_env is NULL.

Question time. setup_git_directory_gently() can be happy even if there is no repository. Now if we move version check into setup_..._gently and it finds git program is too old to handle the repository, what would we do? die() like in check_repository_format() or tell the caller there is no repository?

-- 
Duy
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 5 of 6 in “setup_git_directory: Setup cwd properly if worktree is found”
  1. setup_git_directory: Setup cwd properly if worktree is foundNguyễn Thái Ngọc Duy, Nov 12, 2007
  2. Johannes SchindelinNov 12, 2007
  3. Johannes SixtNov 12, 2007
  4. Johannes SchindelinNov 12, 2007
  5. Nguyen Thai Ngoc DuyNov 27, 2007
  6. Johannes SchindelinNov 27, 2007

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.