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
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 12, 2007, 12:31 UTC
Message-ID
<Pine.LNX.4.64.0711121224430.4362@racer.site>
In-Reply-To
<fcaeb9bf0711120413w180c07e1qbf1b186753593d7@mail.gmail.com>
Hi,
On Mon, 12 Nov 2007, Nguyen Thai Ngoc Duy wrote:
Show 10 quoted lines
> 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.

Show 10 quoted lines
> > 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.

But we could break down _gently() quite nicely. ATM it both handles the cases when gitdirenv was set, and when it was unset. Even if those are really two pretty different situations.

Ciao, Dscho

Previous: Johannes SixtNext: Nguyen Thai Ngoc Duy
Message 4 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.