{"thread":{"id":"45966","subject":"RE: git worktrees must exist even if locked","startedAt":"2017-05-15T13:58:43Z","lastAt":"2017-05-29T10:17:50Z","messageCount":3,"participants":["taylor, david","Junio C Hamano","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"319785","messageId":"63F1AEE13FAE864586D589C671A6E18B0D6B8C@MX203CL03.corp.emc.com","threadId":"45966","inReplyTo":null,"subject":"RE: git worktrees must exist even if locked","fromName":"taylor, david","fromEmail":"david.taylor@dell.com","sentAt":"2017-05-15T13:58:19Z","receivedAt":"2017-05-15T13:58:43Z","isPatch":false,"sender":{"key":"david.taylor@dell.com","avatar":null},"body":"The original report was against Git v2.12.2.  I have since tried v2.12.3, v2.13.0,\nand the next branch.  All exhibit the same symptoms.\n\nEven if you ignore the original scenario for creating the problem, if I do a 'rm -rf' or 'mv'\nof a tree that contains within it worktrees, that should not break the use of Git with\nworktrees that live elsewhere nor commands that don't require a repository.\n\n> -----Original Message-----\n> From: taylor, david\n> Sent: Wednesday, May 10, 2017 4:25 PM\n> To: git@vger.kernel.org\n> Subject: git worktrees must exist even if locked\n> \n> The Git documentation in describing worktrees says that one reason\n> why you might want to lock a worktree is to prevent it from being pruned\n> if it is on a removable media that isn't currently mounted.\n> \n> So, my expectation was that if the worktree is inaccessible (and locked), Git\n> would pretend that there is no worktree by that name.\n> \n> In reality, if you have such a worktree, Git gets an error.\n> \n>  On local systems, /home is local to a machine; home directories are\n> elsewhere.\n> Home directories are NFS mounted; /home is not.\n> \n> . create a repository in /my/home/dir/my-repo.git with\n> \n>     git clone --bare <some arguments>\n> \n> . create an empty directory /home/somedir/worktree-tests\n> \n> . use 'git worktree add' to add /home/somedir/worktree-tests/<branch-\n> name>\n>   as a worktree on branch <branch-name>.  It gets populated with the correct\n>   content.\n> \n> . lock it using'git worktree lock'\n> \n> So far, so good.  Now, go to a different computer -- one on which\n> /home/somedir/worktree-tests does not exist (and therefore\n> /home/somedir/worktree-tests/<branch-name> does not exist).\n> \n> . cd /my/home/dir/my-repo.git\n> \n> Now, try issuing Git commands.  Many will fail.\n> \n>   git fetch ==> fails:\n> \n>   fatal: Invalid path '/home/somedir/worktree-tests': No such file or directory\n> \n>   git status ==> fails -- same error as above\n>   git help worktree ==> fails -- same error as above\n"},{"id":"319846","messageId":"xmqqshk568s4.fsf@gitster.mtv.corp.google.com","threadId":"45966","inReplyTo":"63F1AEE13FAE864586D589C671A6E18B0D6B8C@MX203CL03.corp.emc.com","subject":"Re: git worktrees must exist even if locked","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-15T22:43:23Z","receivedAt":"2017-05-15T22:43:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"taylor, david\" <David.Taylor@dell.com> writes:\n\n> The original report was against Git v2.12.2.  I have since tried v2.12.3, v2.13.0,\n> and the next branch.  All exhibit the same symptoms.\n>\n> Even if you ignore the original scenario for creating the problem, if I do a 'rm -rf' or 'mv'\n> of a tree that contains within it worktrees, that should not break the use of Git with\n> worktrees that live elsewhere nor commands that don't require a repository.\n\nDuy, any ideas?\n\nThanks.\n\n>\n>> -----Original Message-----\n>> From: taylor, david\n>> Sent: Wednesday, May 10, 2017 4:25 PM\n>> To: git@vger.kernel.org\n>> Subject: git worktrees must exist even if locked\n>> \n>> The Git documentation in describing worktrees says that one reason\n>> why you might want to lock a worktree is to prevent it from being pruned\n>> if it is on a removable media that isn't currently mounted.\n>> \n>> So, my expectation was that if the worktree is inaccessible (and locked), Git\n>> would pretend that there is no worktree by that name.\n>> \n>> In reality, if you have such a worktree, Git gets an error.\n>> \n>>  On local systems, /home is local to a machine; home directories are\n>> elsewhere.\n>> Home directories are NFS mounted; /home is not.\n>> \n>> . create a repository in /my/home/dir/my-repo.git with\n>> \n>>     git clone --bare <some arguments>\n>> \n>> . create an empty directory /home/somedir/worktree-tests\n>> \n>> . use 'git worktree add' to add /home/somedir/worktree-tests/<branch-\n>> name>\n>>   as a worktree on branch <branch-name>.  It gets populated with the correct\n>>   content.\n>> \n>> . lock it using'git worktree lock'\n>> \n>> So far, so good.  Now, go to a different computer -- one on which\n>> /home/somedir/worktree-tests does not exist (and therefore\n>> /home/somedir/worktree-tests/<branch-name> does not exist).\n>> \n>> . cd /my/home/dir/my-repo.git\n>> \n>> Now, try issuing Git commands.  Many will fail.\n>> \n>>   git fetch ==> fails:\n>> \n>>   fatal: Invalid path '/home/somedir/worktree-tests': No such file or directory\n>> \n>>   git status ==> fails -- same error as above\n>>   git help worktree ==> fails -- same error as above\n"},{"id":"320937","messageId":"CACsJy8A691aGfKfa7h1y7A3sgnWgDm_eLA5tj78ES1XjP+mK5Q@mail.gmail.com","threadId":"45966","inReplyTo":"xmqqshk568s4.fsf@gitster.mtv.corp.google.com","subject":"Re: git worktrees must exist even if locked","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-05-29T10:17:15Z","receivedAt":"2017-05-29T10:17:50Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 16, 2017 at 5:43 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \"taylor, david\" <David.Taylor@dell.com> writes:\n>\n>> The original report was against Git v2.12.2.  I have since tried v2.12.3, v2.13.0,\n>> and the next branch.  All exhibit the same symptoms.\n>>\n>> Even if you ignore the original scenario for creating the problem, if I do a 'rm -rf' or 'mv'\n>> of a tree that contains within it worktrees, that should not break the use of Git with\n>> worktrees that live elsewhere nor commands that don't require a repository.\n>\n> Duy, any ideas?\n\nWe are supposed to tolerate missing worktrees if locked. I'm guessing\nthat lots of changes in get_worktrees() lately may perhaps forget\nabout this and be too strict on locked worktrees.\n-- \nDuy\n"}]}