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

Re: [PATCH] rebase --update-refs: avoid unintended ref deletion

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 4, 2022, 20:17 UTC
Message-ID
<1ad5f905-f9f1-5a06-e419-476032a0d237@dunelm.org.uk>
In-Reply-To
<Y2VrhR6b0SzG1HEA@nand.local>
Hi Taylor
On 04/11/2022 19:44, Taylor Blau wrote:
Show 11 quoted lines
> On Fri, Nov 04, 2022 at 09:57:36AM -0700, Victoria Dye wrote:
>> However, because 'write_update_refs_state()' will not update the state if
>> the 'refs_to_oids' list was empty, removing *all* 'update-ref' lines will
>> result in the state remaining unchanged from how it was initialized (with
>> all refs' "after" OID being null). Then, when the ref update is applied, all
>> refs will be updated to null and consequently deleted.
> 
> Good catch.
> 
> I wonder, though: should we only add pending ref updates to the
> update-refs state after we reach that point in the sequence?

If I remember correctly the aim of the current behavior is to detect if another process also updates the ref while we're rebasing. To do that we need to record all the branch heads that have update-ref commands at the start of the rebase.

Best Wishes
Phillip
Show 17 quoted lines
> IOW: there is no world where deleting an update-refs command means to
> drop the affected branch, right? So the initial state would be an empty
> list, which would cause us to not update any references.
> 
> Then as we proceed through the rebase, we accumulate update-refs
> commands, and know their after_oid immediately. Then when we're done, we
> can process the update-refs commands for the branches that we do have.
> 
> The more I think about this, the more that I am convinced that the bug
> is in how we initialize the pending list, not our treatment of it later
> on.
> 
> The bug fix works as-is, but I can't help wonder if the above approach
> might be more direct.
> 
> Thanks,
> Taylor
Previous: Taylor BlauNext: Phillip Wood
Message 11 of 17 in “rebase -i --update-refs can lead to deletion of branches”
  1. herr.kasteOct 20, 2022
  2. Erik Cervin EdinOct 20, 2022
  3. Phillip WoodNov 3, 2022
  4. herr.kasteNov 3, 2022
  5. Erik Cervin EdinNov 3, 2022
  6. Victoria DyeNov 4, 2022
  7. Phillip WoodNov 4, 2022
  8. Victoria DyeNov 4, 2022
  9. rebase --update-refs: avoid unintended ref deletionVictoria Dye, Nov 4, 2022
  10. Taylor BlauNov 4, 2022
  11. Phillip WoodNov 4, 2022
  12. Phillip WoodNov 4, 2022
  13. Derrick StoleeNov 7, 2022
  14. rebase --update-refs: avoid unintended ref deletionVictoria Dye, Nov 7, 2022
  15. Taylor BlauNov 7, 2022
  16. Derrick StoleeNov 7, 2022
  17. Phillip WoodNov 8, 2022

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.