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

RE: Shared clone from worktree directory

From
Randall S. Becker <rsbecker@nexbridge.com>
Date
Dec 11, 2017, 17:23 UTC
Message-ID
<000801d372a4$c9844c10$5c8ce430$@nexbridge.com>
In-Reply-To
<CAJ+F1CJB+fOJmYpDQtjn1kLa-wk=oUeQGjO7q=N2igYhVG0tiQ@mail.gmail.com>
On December 11, 2017 12:02 PM, Marc-André Lureau wrote:
Show 11 quoted lines
>For better, or worse, I encountered a script doing a git clone --shared from the working directory. However, if clone --shared is run from a worktree, it fails with cryptic errors.
>elmarco@boraha:/tmp/test/wt (wt)$ git worktree list
>/tmp/test     4ae16a0 [master]
>/tmp/test/wt  4ae16a0 [wt]
>elmarco@boraha:/tmp/test/wt (wt)$ git clone --shared  . clone-dir Cloning into 'clone-dir'...
>done.
>error: object directory /tmp/test/.git/worktrees/wt/objects does not exist; check .git/objects/info/alternates.
>fatal: update_ref failed for ref 'HEAD': cannot update ref
>'refs/heads/wt': trying to write ref 'refs/heads/wt' with nonexistent object 4ae16a066ee088d40dbefeaaae7b5578d68b4b51
>fatal: The remote end hung up unexpectedly
>Is this a bug? If not, a nicer error message would be welcome, as well as man page note.
"The add worktree documentation states:
    Create <path> and checkout <branch> into it. The new working directory is linked to the ***current repository***, sharing everything except working directory specific files such as HEAD, index, etc. - may also be specified as <branch>; it is synonymous with @{-1}."
So I'm going to assume that clone from a worktree is not supported. This sounds like a check is needed to prevent the operation from starting up in the first place, or changing the semantics to allow it. The error message, while cryptic, seems actually descriptive because the HEAD would not be available in a worktree as it is not propagated from the current repository.
If the idea is to support an add worktree from a worktree, I would suggest that a new branch go back to the main repository as normal, rather than being added to the worktree. I personally get a headache thinking about the prospect of having layers of worktrees.

Cheers, Randall

-- Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400)/NonStop(211288444200000000) -- In my real life, I talk too much.

Previous: Marc-André LureauNext: Eric Sunshine
Message 2 of 3 in “Shared clone from worktree directory”
  1. Marc-André LureauDec 11, 2017
  2. Randall S. BeckerDec 11, 2017
  3. Eric SunshineDec 11, 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.