git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] history: refuse to rewrite branches used by other worktrees

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 24, 2026, 10:49 UTC
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.
Show 9 quoted lines
>> 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.
Show 5 quoted lines
>> 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.
Previous: Aniket GuptaNext: Aniket Gupta
Message 4 of 7 in “history: refuse to rewrite branches used by other worktrees”
  1. history: refuse to rewrite branches used by other worktreesAniket Gupta, Nov 23, 2026
  2. Phillip WoodNov 23, 2026
  3. Aniket GuptaNov 23, 2026
  4. Phillip WoodNov 24, 2026
  5. Aniket GuptaNov 24, 2026
  6. Junio C HamanoNov 23, 2026
  7. Aniket GuptaNov 23, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.