Re: [rebase] `fatal: cannot force update the branch ... checkout out at ...` is confusing when it isn't active
From: Junio C Hamano <hidden>
Date: 2023-07-12 20:49:55
Josh Soref [off-list ref] writes:
Josh Soref writes:quoted
fatal: cannot force update the branch 'main' checked out at '/private/var/folders/r3/n29fz25x72x191fdv6mhhr3m0000gp/T/tmp.fGD64HAf'quoted
It's true git in the repository does have a pin of sorts for the `main` branch and that `git-rebase` would be very upset if the branch's location were changed, but as an end user, the `main` branch is not checked out, the `next` branch is checked out.Junio C Hamano wrote:quoted
Fair enough. Perhaps "cannot force update the branch 'main' in use" would alleviate the confusion?That would be better. Even better would be to tell me what's using it (rebase). I'm not sure how possible that is.
When branch.c:prepare_checked_out() notices which branch is in use in what way in which worktree, it does check many conditions (e.g. "in this worktree, is a rebase in progress and if so which branch is being affected?") but the information is lost there to only record a mapping from branch names to worktree location. So "it is in use over there" with exact location is given, but "how it is used" is not recorded. It shouldn't be a rocket surgery to teach the function to leave that information, but I am not offhand sure how valuable it would be to do so. After all, once you learn which worktree of yours is using the branch you wanted to touch, you'll either know already or it would be easy for you to find out what you have been doing in that other worktree anyway, no?