Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Tamir Duberstein <tamird@fuseenergy.com>
Cc: git@vger.kernel.org, Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: bug report: spurious "cannot delete branch '%s' used by worktree"
Date: Sun, 31 Mar 2024 02:49:12 -0400	[thread overview]
Message-ID: <CAPig+cQdFi5zBkDQWTEWXCTt5h9gVFNJv7obf=tWCkOvsaEHEA@mail.gmail.com> (raw)
In-Reply-To: <CAEYvaskXRyxNTLNeRPPyawFrBVRgCbSnJiuF7D7cOGiaDq=V2Q@mail.gmail.com>

[please reply inline rather than top-posting; I've moved your reply
inline for this response]

On Thu, Mar 28, 2024 at 1:40 PM Tamir Duberstein <tamird@fuseenergy.com> wrote:
> On Thu, Mar 28, 2024 at 5:24 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
> > On Thu, Mar 28, 2024 at 10:54 AM Tamir Duberstein <tamird@fuseenergy.com> wrote:
> > > % git branch -d cleanup
> > > error: cannot delete branch 'cleanup' used by worktree at '<my source dir>'
> > > % git worktree list
> > > <my source dir>  dc46f6d5e [main]
> > > % git branch
> > >   cleanup
> > > * main
> >
> > Is this error persistent once it arises? That is, if you invoke `git
> > branch -d cleanup` again immediately after (or a little while after)
> > the above sequence, does the problem persist? Or does it "clear up" on
> > its own at some point?
>
> Yes, the problem is persistent. The branch is never deleted.

I'd guess that there may be some sort of "ref" still pointing at the
"cleanup" branch which presumably was, at some point, checked out at
"<my source dir>". Digging through the code[1,2,3] suggests that you
might have some stale state from a rebase, bisect, or other sequencer
operation which still references the "cleanup" branch.

[Cc'ing Phillip who is probably much more familiar with this code than am I.]

By the way, it's not clear from your initial report what you mean when
you say "then the remote deleted the branch". Also, did you fetch
and/or pull from the remote after that?

[1]: https://github.com/git/git/blob/d6fd04375f91/branch.c#L454
[2]: https://github.com/git/git/blob/d6fd04375f91/branch.c#L386
[3]: https://github.com/git/git/blob/d6fd04375f91/sequencer.c#L6551

  reply	other threads:[~2024-03-31  6:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 14:53 bug report: spurious "cannot delete branch '%s' used by worktree" Tamir Duberstein
2024-03-28 17:24 ` Eric Sunshine
2024-03-28 17:39   ` Tamir Duberstein
2024-03-31  6:49     ` Eric Sunshine [this message]
2024-03-31  7:45       ` Tamir Duberstein
2024-04-02 10:10       ` Phillip Wood
2024-04-02 10:26         ` Tamir Duberstein
2024-04-02 10:38           ` Kristoffer Haugsbakk
2024-04-02 11:28           ` phillip.wood123
2024-04-02 11:56             ` Tamir Duberstein
2024-04-02 15:15               ` phillip.wood123

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPig+cQdFi5zBkDQWTEWXCTt5h9gVFNJv7obf=tWCkOvsaEHEA@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.com \
    --cc=tamird@fuseenergy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).