From: Eric Sunshine Date: Tue, 29 Mar 2016 18:47:10 GMT Subject: Re: [PATCH v2] branch -d: refuse deleting a branch which is currently checked out Message-ID: In-Reply-To: <20160329092802.GA17915@chikuwa.rhe.jp> On Tue, Mar 29, 2016 at 5:28 AM, Kazuki Yamaguchi wrote: > On Mon, Mar 28, 2016 at 12:51:21PM -0400, Eric Sunshine wrote: >> On Mon, Mar 28, 2016 at 3:22 AM, Kazuki Yamaguchi wrote: >> > + if (kinds == FILTER_REFS_BRANCHES) { >> > + char *worktree = find_shared_symref("HEAD", name); >> > + if (worktree) { >> > + error(_("Cannot delete the branch '%s' " >> > + "which is currently checked out at '%s'"), >> > + bname.buf, worktree); >> > + free(worktree); >> >> Would it make sense to show all worktrees at which this branch is >> checked out, rather than only one, or is that not worth the effort and >> extra code ugliness? > > I thought one is enough. > I think the worktrees usually won't be more than one, considering > "git worktree add" requires additional option to check out an already > checked out branch. Also, since the branch is not actually deleted at > that time, the user can safely retry after checking "git worktree list". Fair enough. A more thorough error message can be done a future enhancement if there is a need for it.