{"thread":{"id":"44815","subject":"git branch -D doesn't work with deleted worktree","startedAt":"2017-01-05T10:14:25Z","lastAt":"2017-01-10T10:48:05Z","messageCount":7,"participants":["Roland Illig","Stefan Beller","Duy Nguyen","Jacob Keller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"308815","messageId":"4D106F0FF3D29E4FA1D91C1A31CE4C3501B8DEF2E6@email.novomind.com","threadId":"44815","inReplyTo":null,"subject":"git branch -D doesn't work with deleted worktree","fromName":"Roland Illig","fromEmail":"rillig@novomind.com","sentAt":"2017-01-05T10:06:08Z","receivedAt":"2017-01-05T10:14:25Z","isPatch":false,"sender":{"key":"rillig@novomind.com","avatar":null},"body":"Git 2.11.0 gives a wrong error message after the following commands:\n \n$ git init\n$ echo hello >file\n$ git add file\n$ git commit -m \"message\"\n$ git worktree add ../worktree\n$ rm -rf ../worktree\n$ git br -D worktree\nerror: Cannot delete branch 'worktree' checked out at '../worktree'\n\nSince ../worktree has been deleted, there cannot be anything checked out at that location.\n\nIn my opinion, deleting the branch should just work. Especially since I used the -D option and the \"git worktree\" documentation says \"When you are done with a linked working tree you can simply delete it.\"\n\nRegards,\nRoland\n\n"},{"id":"308821","messageId":"CAGZ79kaLpf1nzSAgRJQamMGk-327LO+qQYihYVVcU+86n92ivg@mail.gmail.com","threadId":"44815","inReplyTo":"4D106F0FF3D29E4FA1D91C1A31CE4C3501B8DEF2E6@email.novomind.com","subject":"Re: git branch -D doesn't work with deleted worktree","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-01-05T14:02:07Z","receivedAt":"2017-01-05T14:02:47Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:\n> Git 2.11.0 gives a wrong error message after the following commands:\n>\n> $ git init\n> $ echo hello >file\n> $ git add file\n> $ git commit -m \"message\"\n> $ git worktree add ../worktree\n> $ rm -rf ../worktree\n> $ git br -D worktree\n> error: Cannot delete branch 'worktree' checked out at '../worktree'\n>\n> Since ../worktree has been deleted, there cannot be anything checked out at that location.\n>\n> In my opinion, deleting the branch should just work. Especially since I used the -D option and the \"git worktree\" documentation says \"When you are done with a linked working tree you can simply delete it.\"\n>\n> Regards,\n> Roland\n>\n"},{"id":"308851","messageId":"CACsJy8C6QWeHSwhsYyJnupkue=aoCG+3Tecytb_0p+gB-CuVKg@mail.gmail.com","threadId":"44815","inReplyTo":"CAGZ79kaLpf1nzSAgRJQamMGk-327LO+qQYihYVVcU+86n92ivg@mail.gmail.com","subject":"Re: git branch -D doesn't work with deleted worktree","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-01-06T10:05:53Z","receivedAt":"2017-01-06T10:08:55Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Jan 5, 2017 at 9:02 PM, Stefan Beller <sbeller@google.com> wrote:\n> On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:\n>> Git 2.11.0 gives a wrong error message after the following commands:\n>>\n>> $ git init\n>> $ echo hello >file\n>> $ git add file\n>> $ git commit -m \"message\"\n>> $ git worktree add ../worktree\n>> $ rm -rf ../worktree\n>> $ git br -D worktree\n>> error: Cannot delete branch 'worktree' checked out at '../worktree'\n>>\n>> Since ../worktree has been deleted, there cannot be anything checked out at that location.\n>>\n>> In my opinion, deleting the branch should just work. Especially since I used the -D option and the \"git worktree\" documentation says \"When you are done with a linked working tree you can simply delete it.\"\n\nSince -D means \"I know what I'm doing, get out of my way\", maybe we\nshould continue if any worktree has the branch checked out by\ndetaching it?\n\n(Yes I'm carefully tip toeing around the deleted worktree issue since\n\"git worktree remove\" is coming. After that point, running \"worktree\nprune\" before \"branch -D\" does not sound so bad)\n-- \nDuy\n"},{"id":"308982","messageId":"CA+P7+xofFufcUMBJFqEcP=C5r80HCr1-j4210gOm7t=aLYw2zw@mail.gmail.com","threadId":"44815","inReplyTo":"CACsJy8C6QWeHSwhsYyJnupkue=aoCG+3Tecytb_0p+gB-CuVKg@mail.gmail.com","subject":"Re: git branch -D doesn't work with deleted worktree","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-01-09T03:44:20Z","receivedAt":"2017-01-09T03:44:50Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Jan 6, 2017 at 2:05 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Thu, Jan 5, 2017 at 9:02 PM, Stefan Beller <sbeller@google.com> wrote:\n>> On Thu, Jan 5, 2017 at 2:06 AM, Roland Illig <rillig@novomind.com> wrote:\n>>> Git 2.11.0 gives a wrong error message after the following commands:\n>>>\n>>> $ git init\n>>> $ echo hello >file\n>>> $ git add file\n>>> $ git commit -m \"message\"\n>>> $ git worktree add ../worktree\n>>> $ rm -rf ../worktree\n>>> $ git br -D worktree\n>>> error: Cannot delete branch 'worktree' checked out at '../worktree'\n>>>\n>>> Since ../worktree has been deleted, there cannot be anything checked out at that location.\n>>>\n>>> In my opinion, deleting the branch should just work. Especially since I used the -D option and the \"git worktree\" documentation says \"When you are done with a linked working tree you can simply delete it.\"\n>\n> Since -D means \"I know what I'm doing, get out of my way\", maybe we\n> should continue if any worktree has the branch checked out by\n> detaching it?\n>\n> (Yes I'm carefully tip toeing around the deleted worktree issue since\n> \"git worktree remove\" is coming. After that point, running \"worktree\n> prune\" before \"branch -D\" does not sound so bad)\n> --\n> Duy\n\nWhy not just update the documentation to be \"when you are done with a\nwork tree you can delete it and then run git worktree prune\"?\n\nThanks,\nJake\n"},{"id":"309013","messageId":"CACsJy8AfcZOR966ypfbZa1+7=tr2RVxPUk8+XmQkGeoMBJ7Z0g@mail.gmail.com","threadId":"44815","inReplyTo":"CA+P7+xofFufcUMBJFqEcP=C5r80HCr1-j4210gOm7t=aLYw2zw@mail.gmail.com","subject":"Re: git branch -D doesn't work with deleted worktree","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-01-09T10:07:19Z","receivedAt":"2017-01-09T10:11:06Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Jan 9, 2017 at 10:44 AM, Jacob Keller <jacob.keller@gmail.com> wrote:\n> Why not just update the documentation to be \"when you are done with a\n> work tree you can delete it and then run git worktree prune\"?\n\nThe document does say that (a bit verbose though):\n\nWhen you are done with a linked working tree you can simply delete it.\nThe working tree's administrative files in the repository (see\n\"DETAILS\" below) will eventually be removed automatically (see\n`gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run\n`git worktree prune` in the main or any linked working tree to\nclean up any stale administrative files.\n-- \nDuy\n"},{"id":"309106","messageId":"CA+P7+xqOrRwJsnskfGQpLYyQFjce=4z24zuhrEBd2P4gBLh0Qw@mail.gmail.com","threadId":"44815","inReplyTo":"CACsJy8AfcZOR966ypfbZa1+7=tr2RVxPUk8+XmQkGeoMBJ7Z0g@mail.gmail.com","subject":"Re: git branch -D doesn't work with deleted worktree","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-01-10T05:08:11Z","receivedAt":"2017-01-10T05:13:51Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, Jan 9, 2017 at 2:07 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Mon, Jan 9, 2017 at 10:44 AM, Jacob Keller <jacob.keller@gmail.com> wrote:\n>> Why not just update the documentation to be \"when you are done with a\n>> work tree you can delete it and then run git worktree prune\"?\n>\n> The document does say that (a bit verbose though):\n>\n> When you are done with a linked working tree you can simply delete it.\n> The working tree's administrative files in the repository (see\n> \"DETAILS\" below) will eventually be removed automatically (see\n> `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run\n> `git worktree prune` in the main or any linked working tree to\n> clean up any stale administrative files.\n> --\n> Duy\n\nRight, so maybe we can make it more clear since it's not quite as\nsimple as \"deleting the work tree\" because of stuff like stale\nbranches.. or would it be worth re-scanning worktrees when we do\nbranch deletion? (obviously ignoring the ones that are marked as on\nremovable media)\n\nThanks,\nJake\n"},{"id":"309134","messageId":"CACsJy8Cd73pJ6+pakC6v79VJ9wp5MrF9eE6a1WM4jAoywgmL0g@mail.gmail.com","threadId":"44815","inReplyTo":"CA+P7+xqOrRwJsnskfGQpLYyQFjce=4z24zuhrEBd2P4gBLh0Qw@mail.gmail.com","subject":"Re: git branch -D doesn't work with deleted worktree","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-01-10T10:47:29Z","receivedAt":"2017-01-10T10:48:05Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jan 10, 2017 at 12:08 PM, Jacob Keller <jacob.keller@gmail.com> wrote:\n> On Mon, Jan 9, 2017 at 2:07 AM, Duy Nguyen <pclouds@gmail.com> wrote:\n>> On Mon, Jan 9, 2017 at 10:44 AM, Jacob Keller <jacob.keller@gmail.com> wrote:\n>>> Why not just update the documentation to be \"when you are done with a\n>>> work tree you can delete it and then run git worktree prune\"?\n>>\n>> The document does say that (a bit verbose though):\n>>\n>> When you are done with a linked working tree you can simply delete it.\n>> The working tree's administrative files in the repository (see\n>> \"DETAILS\" below) will eventually be removed automatically (see\n>> `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run\n>> `git worktree prune` in the main or any linked working tree to\n>> clean up any stale administrative files.\n>> --\n>> Duy\n>\n> Right, so maybe we can make it more clear since it's not quite as\n> simple as \"deleting the work tree\" because of stuff like stale\n> branches..\n\nPatches are welcome. I wrote that paragraph and you could clearly see\nits \"quality\" (from user perspective).\n\n> or would it be worth re-scanning worktrees when we do\n> branch deletion? (obviously ignoring the ones that are marked as on\n> removable media)\n\nProbably. We run \"git worktree prune\" as part of \"git gc\" and that\ncommand is automatically called in a couple places. Adding another\n\"git gc\" here probably does not hurt. However it could trigger a full\nrepack and make \"git branch\" hang for a few seconds...\n\nAnd no I don't want to single out \"git worktree prune\" to be called in\ngit-branch. We should either go through git-gc or none. We could check\nif a worktree is deleted and suggest the user to run \"git gc\" though,\nbut it's getting too complicated when \"git worktree remove\" will soon\nbe the recommended way of deleting a worktree. So.. I don't know..\n-- \nDuy\n"}]}