{"thread":{"id":"47427","subject":"Shared clone from worktree directory","startedAt":"2017-12-11T17:02:18Z","lastAt":"2017-12-11T19:56:04Z","messageCount":3,"participants":["Marc-André Lureau","Randall S. Becker","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"334609","messageId":"CAJ+F1CJB+fOJmYpDQtjn1kLa-wk=oUeQGjO7q=N2igYhVG0tiQ@mail.gmail.com","threadId":"47427","inReplyTo":null,"subject":"Shared clone from worktree directory","fromName":"Marc-André Lureau","fromEmail":"marcandre.lureau@gmail.com","sentAt":"2017-12-11T17:02:09Z","receivedAt":"2017-12-11T17:02:18Z","isPatch":false,"sender":{"key":"marcandre.lureau@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9381?v=4"},"body":"Hi,\n\nFor better, or worse, I encountered a script doing a git clone\n--shared from the working directory. However, if clone --shared is run\nfrom a worktree, it fails with cryptic errors.\n\nEx:\nelmarco@boraha:/tmp/test/wt (wt)$ git worktree list\n/tmp/test     4ae16a0 [master]\n/tmp/test/wt  4ae16a0 [wt]\nelmarco@boraha:/tmp/test/wt (wt)$ git clone --shared  . clone-dir\nCloning into 'clone-dir'...\ndone.\nerror: object directory /tmp/test/.git/worktrees/wt/objects does not\nexist; check .git/objects/info/alternates.\nfatal: update_ref failed for ref 'HEAD': cannot update ref\n'refs/heads/wt': trying to write ref 'refs/heads/wt' with nonexistent\nobject 4ae16a066ee088d40dbefeaaae7b5578d68b4b51\nfatal: The remote end hung up unexpectedly\n\nIs this a bug? If not, a nicer error message would be welcome, as well\nas man page note.\n\nthanks\n\n-- \nMarc-André Lureau\n"},{"id":"334611","messageId":"000801d372a4$c9844c10$5c8ce430$@nexbridge.com","threadId":"47427","inReplyTo":"CAJ+F1CJB+fOJmYpDQtjn1kLa-wk=oUeQGjO7q=N2igYhVG0tiQ@mail.gmail.com","subject":"RE: Shared clone from worktree directory","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2017-12-11T17:23:35Z","receivedAt":"2017-12-11T17:23:47Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On December 11, 2017 12:02 PM, Marc-André Lureau wrote:\n>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.\n>elmarco@boraha:/tmp/test/wt (wt)$ git worktree list\n>/tmp/test     4ae16a0 [master]\n>/tmp/test/wt  4ae16a0 [wt]\n>elmarco@boraha:/tmp/test/wt (wt)$ git clone --shared  . clone-dir Cloning into 'clone-dir'...\n>done.\n>error: object directory /tmp/test/.git/worktrees/wt/objects does not exist; check .git/objects/info/alternates.\n>fatal: update_ref failed for ref 'HEAD': cannot update ref\n>'refs/heads/wt': trying to write ref 'refs/heads/wt' with nonexistent object 4ae16a066ee088d40dbefeaaae7b5578d68b4b51\n>fatal: The remote end hung up unexpectedly\n>Is this a bug? If not, a nicer error message would be welcome, as well as man page note.\n\n\"The add worktree documentation states:\n    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}.\"\n\nSo 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.\n\nIf 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.\n\nCheers,\nRandall\n\n-- Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400)/NonStop(211288444200000000) \n-- In my real life, I talk too much.\n\n\n\n"},{"id":"334622","messageId":"CAPig+cSxOcSkANUx2+nuVdN9VHiuy_X0Xk7L64G6=07fLf9q+A@mail.gmail.com","threadId":"47427","inReplyTo":"CAJ+F1CJB+fOJmYpDQtjn1kLa-wk=oUeQGjO7q=N2igYhVG0tiQ@mail.gmail.com","subject":"Re: Shared clone from worktree directory","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2017-12-11T19:55:58Z","receivedAt":"2017-12-11T19:56:04Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Dec 11, 2017 at 12:02 PM, Marc-André Lureau\n<marcandre.lureau@gmail.com> wrote:\n> For better, or worse, I encountered a script doing a git clone\n> --shared from the working directory. However, if clone --shared is run\n> from a worktree, it fails with cryptic errors.\n>\n> elmarco@boraha:/tmp/test/wt (wt)$ git worktree list\n> /tmp/test     4ae16a0 [master]\n> /tmp/test/wt  4ae16a0 [wt]\n> elmarco@boraha:/tmp/test/wt (wt)$ git clone --shared  . clone-dir\n> Cloning into 'clone-dir'...\n> done.\n> error: object directory /tmp/test/.git/worktrees/wt/objects does not\n> exist; check .git/objects/info/alternates.\n> fatal: update_ref failed for ref 'HEAD': cannot update ref\n> 'refs/heads/wt': trying to write ref 'refs/heads/wt' with nonexistent\n> object 4ae16a066ee088d40dbefeaaae7b5578d68b4b51\n> fatal: The remote end hung up unexpectedly\n>\n> Is this a bug? If not, a nicer error message would be welcome, as well\n> as man page note.\n\nLooks like a simple oversight in the 'worktree' implementation. I\nworked up a patch to fix it, which I'll try to send out later today.\n"}]}