Thread (25 messages) flat view 25 messages, 3 authors, 2016-06-16

Re: [PATCH v2] branch -d: refuse deleting a branch which is currently checked out

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:09:05

On Tue, Mar 29, 2016 at 5:28 AM, Kazuki Yamaguchi [off-list ref] wrote:
On Mon, Mar 28, 2016 at 12:51:21PM -0400, Eric Sunshine wrote:
quoted
On Mon, Mar 28, 2016 at 3:22 AM, Kazuki Yamaguchi [off-list ref] wrote:
quoted
+               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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help