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

Re: [long] worktree setup cases

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Oct 21, 2010, 01:46 UTC
Message-ID
<AANLkTimzfxJFz2FRVCJ7b4+icXMxpQGNo0WGm_BXzXNy@mail.gmail.com>
In-Reply-To
<20101020190709.GB10537@burratino>
On Thu, Oct 21, 2010 at 2:07 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 5 quoted lines
>> So there are 2^5 = 32 cases in total. Let's look at them one by
>> one.
>
> Thanks!  To summarize (and make sure I understand correctly):
> anything not following the below rules is a bug, yes?
Let's see.
> A. Weird cases.
>
>  - using a .git file is just like setting GIT_DIR;

Yes, except that GIT_DIR can be detected early when cwd has not been moved. When .git is found a file, cwd could have been changed.

> B. Repository search.
>
>  - if GIT_DIR was set explicitly, GIT_WORK_TREE defaults to
>   "." (for legacy reasons).
Correct.
>  - otherwise, if original cwd was under repository, it will not
>   prompt a search for work tree, even if the repo happens
>   to be named ".git" or core.bare is false.  That is, in
>   this case, GIT_WORK_TREE defaults to unset.

What do you mean by "under repository"? If the repo is /tmp/git/.git, then cwd is at /tmp/git/.git?

>  - otherwise, if original cwd was under a directory containing
>   repository as ".git", GIT_WORK_TREE defaults to that
>   directory (i.e., parent to .git dir).
Yes.
>  - otherwise, there is no repository.  GIT_DIR is unset,
>   GIT_WORK_TREE defaults to unset.
- Otherwise, move up one dir and repeat?
> C. Working directory and prefix
>
>  - if GIT_WORK_TREE is still unset after repository search,
>   stay in the original cwd, prefix = NULL.

if GIT_WORK_TREE and core.worktree are still unset, we get a bare repo here (or force it to be a bare repo), so yes, cwd should stay in original cwd and prefix = NULL.

>  - if original cwd is inside worktree, chdir to toplevel,
>   prefix = path to original cwd.
Yes.
>  - otherwise, stay in the original cwd, prefix = NULL.

I'm not really happy with this, which is why I wrote the --cwd-to-worktree and --worktree-to-cwd patch. But this should be enough for full-tree operations to work, so yes.

Show 6 quoted lines
> D. User-supplied relative paths.
>
>  - path in .git file is relative to containing directory
>  - path in GIT_DIR is relative to original cwd
>  - paths in GIT_WORK_TREE and core.worktree are relative to
>   $GIT_DIR

I think $GIT_WORK_TREE is relative to original cwd. Yes, core.worktree should be relative to $GIT_DIR.

>  - paths passed to git commands are generally relative to
>   original cwd

And filename output should also be relative to original cwd (except a few special, like diff output).

> E. Internally used relative paths.
>
>  - all paths are relative to current cwd.
Yes.
-- 
Duy
Previous: Jonathan NiederNext: Jonathan Nieder
Message 4 of 17 in “[long] worktree setup cases”
  1. Nguyen Thai Ngoc DuyOct 20, 2010
  2. Jonathan NiederOct 20, 2010
  3. Jonathan NiederOct 20, 2010
  4. Nguyen Thai Ngoc DuyOct 21, 2010
  5. Jonathan NiederOct 21, 2010
  6. Nguyen Thai Ngoc DuyOct 21, 2010
  7. Jonathan NiederOct 21, 2010
  8. Nguyen Thai Ngoc DuyOct 23, 2010
  9. Enrico WeigeltOct 21, 2010
  10. Nguyen Thai Ngoc DuyOct 22, 2010
  11. Enrico WeigeltOct 22, 2010
  12. .git file (Re: [long] worktree setup cases)Jonathan Nieder, Oct 22, 2010
  13. Nguyen Thai Ngoc DuyOct 22, 2010
  14. Junio C HamanoOct 20, 2010
  15. Nguyen Thai Ngoc DuyOct 21, 2010
  16. Enrico WeigeltOct 21, 2010
  17. Junio C HamanoOct 21, 2010

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.