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

Re: init --separate-git-dir does not set core.worktree

From
Kyle Meyer <kyle@kyleam.com>
Date
Feb 2, 2017, 12:37 UTC
Message-ID
<87efzg7oq3.fsf@kyleam.com>
In-Reply-To
<CACsJy8AZUBt76ZocS2JEr9FP_8Obv8L911AvZxE_sww3qXB7qw@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
Show 10 quoted lines
> On Thu, Feb 2, 2017 at 10:55 AM, Kyle Meyer <kyle@kyleam.com> wrote:
>>
>> As of 6311cfaf9 (init: do not set unnecessary core.worktree,
>> 2016-09-25), "git init --separate-git-dir" no longer sets core.worktree
>> (test below).  Based on the commit message and the corresponding thread
>> [1], I don't think this change in behavior was intentional, but I wasn't
>> able to understand things well enough to attempt a patch.
>
> I'm missing some context. Why does --separate-git-dir have to set
> core.worktree? What fails for you exactly?

Sorry for not providing enough information. I haven't run into a failure.

In Magit, we need to determine the top-level of the working tree from COMMIT_EDITMSG. Right now that logic [*1*] looks something like this:

 * COMMIT_EDITMSG in .git/modules/<module>/: set working tree to the
   output of "git rev-parse --show-toplevel"
 * COMMIT_EDITMSG in .git/worktrees/<wtree>/: set working tree to the
   path in .git/worktrees/<wtree>/gitdir, minus the trailing "/.git"
 * COMMIT_EDITMSG in .git: set working tree to the parent directory

This fails for a repo set up with --separate-git-dir [*2*], where the last step will go out into an unrelated repo. If core.worktree was set and "git rev-parse --show-toplevel" returned the working tree like it did for submodules, things would work.

Of course, the issue above isn't a reason that --separate-git-dir should set core.worktree, but the submodule behavior is why we were wondering if it should. And so I was going to ask here whether core.worktree should be set, but then I confused myself into thinking 6311cfaf9 unintentionally changed this behavior.

[*1*] This is done by magit-toplevel:
      https://github.com/magit/magit/blob/e34f4e8eb00f292e8c475489fa7caa286857a421/lisp/magit-git.el#L400
[*2*] https://github.com/magit/magit/issues/2955
      https://github.com/magit/magit/issues/2981
Previous: Duy NguyenNext: Duy Nguyen
Message 3 of 7 in “init --separate-git-dir does not set core.worktree”
  1. Kyle MeyerFeb 2, 2017
  2. Duy NguyenFeb 2, 2017
  3. Kyle MeyerFeb 2, 2017
  4. Duy NguyenFeb 3, 2017
  5. Kyle MeyerFeb 4, 2017
  6. Stefan BellerFeb 8, 2017
  7. Stefan BellerFeb 8, 2017

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.