{"thread":{"id":"45925","subject":"git worktrees must exist even if locked","startedAt":"2017-05-10T20:25:23Z","lastAt":"2017-05-29T11:19:33Z","messageCount":2,"participants":["taylor, david","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"319295","messageId":"63F1AEE13FAE864586D589C671A6E18B0D5F2C@MX203CL03.corp.emc.com","threadId":"45925","inReplyTo":null,"subject":"git worktrees must exist even if locked","fromName":"taylor, david","fromEmail":"david.taylor@dell.com","sentAt":"2017-05-10T20:24:59Z","receivedAt":"2017-05-10T20:25:23Z","isPatch":false,"sender":{"key":"david.taylor@dell.com","avatar":null},"body":"The Git documentation in describing worktrees says that one reason\nwhy you might want to lock a worktree is to prevent it from being pruned\nif it is on a removable media that isn't currently mounted.\n\nSo, my expectation was that if the worktree is inaccessible (and locked), Git\nwould pretend that there is no worktree by that name.\n\nIn 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 elsewhere.\nHome 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-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\nSo 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\nNow, 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":"320946","messageId":"CACsJy8AGVDCR0uO--txR2-6B6tF1w8mhZ4G6BPMznHVWS-vzGA@mail.gmail.com","threadId":"45925","inReplyTo":"63F1AEE13FAE864586D589C671A6E18B0D5F2C@MX203CL03.corp.emc.com","subject":"Re: git worktrees must exist even if locked","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-05-29T11:18:58Z","receivedAt":"2017-05-29T11:19:33Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, May 11, 2017 at 3:24 AM, taylor, david <David.Taylor@dell.com> wrote:\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 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-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\nFWIW I couldn't reproduce this. The fact that \"git help\" also fails\nsuggests this is triggered by some early setup code, which narrows\ndown the starting point to strbuf_realpath (that can print \"Invalid\npath\", the other call in read-cache.c involves adding index entries\nand can be ignored). But I fail to see how early setup code needs to\nlook at any worktree at all, especially when you issue command\nstanding from my-repo.git (i.e. bare repo setup, even current worktree\nis ignored). An strace output, if possible, might help pinpoint the\nproblem.\n-- \nDuy\n"}]}