From: Phillip Wood Date: Tue, 24 Nov 2026 10:49:42 GMT Subject: Re: [PATCH] history: refuse to rewrite branches used by other worktrees Message-ID: <14c971ef-438c-4197-b0cd-df9bf0ef0ae4@gmail.com> In-Reply-To: <20261123215431.27574-1-aniketgupta3001@gmail.com> On 23/11/2026 21:54, Aniket Gupta wrote: > Thanks for taking a look! You're welcome, thanks for working on it. >> What happens if a rebase is running in the same worktree as the user >> tries to run "git history"? > > It is refused. HEAD is detached then, so the branch being rebased is not > the one this worktree has checked out, and it gets treated like any > other branch in use. There is a test for it, but the commit message does > not contain this. Will fix. > > In that case --update-refs=head is not refused: it only rewrites the > detached HEAD, same as before. I tried fixup, reword, drop and squash > that way, and "git rebase --continue" finished fine each time. That sounds like a bug though, because "git history" will update HEAD in the middle of a rebase and we throw away the result of running "git history" when "git rebase" completes. > >> We should also prevent rebase from rewriting a branch that is being >> rewritten by "git history" but that can come later. > > Agreed, that can come later. we should also refuse to run if another "git history" is rewriting the same branches - that's also something for another time. >> This is correct, but it duplicates the revision walk we're already >> doing when looking for merge commits. > > Makes sense. I gave it a try and it works. One point: the branch > pointing at the rewritten commit itself is not part of the walk, so I > look at its decorations too. Great, I realized that after I sent my mail yesterday, well spotted. Thanks Phillip > Rewriting a commit that another worktree's > branch points at goes through without it. Will do it like this in v2.