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

Re: [PATCH] rebase --abort: cleanup refs/rewritten

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
May 3, 2019, 10:06 UTC
Message-ID
<e7adc1ec-3db3-654c-4ee1-e1a93ec84a99@gmail.com>
In-Reply-To
<nycvar.QRO.7.76.6.1905031117500.45@tvgsbejvaqbjf.bet>
Hi Dscho
On 03/05/2019 10:21, Johannes Schindelin wrote:
Show 47 quoted lines
> Hi Phillip,
> 
> On Wed, 1 May 2019, Phillip Wood wrote:
> 
>> On 30/04/2019 23:49, Johannes Schindelin wrote:
>>>
>>> On Tue, 30 Apr 2019, Phillip Wood wrote:
>>>
>>>> On 29/04/2019 17:07, Johannes Schindelin wrote:
>>>>>
>>>>> On Fri, 26 Apr 2019, Phillip Wood wrote:
>>>>>
>>>>>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>>>>>>
>>>>>> When `rebase -r` finishes it removes any refs under refs/rewritten
>>>>>> that it has created. However if the rebase is aborted these refs are
>>>>>> not removed. This can cause problems for future rebases. For example I
>>>>>> recently wanted to merge a updated version of a topic branch into an
>>>>>> integration branch so ran `rebase -ir` and removed the picks and label
>>>>>> for the topic branch from the todo list so that
>>>>>>        merge -C <old-merge> topic
>>>>>> would pick up the new version of topic. Unfortunately
>>>>>> refs/rewritten/topic already existed from a previous rebase that had
>>>>>> been aborted so the rebase just used the old topic, not the new one.
>>>>>>
>>>>>> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
>>>>>> ---
>>>>>
>>>>> Makes a ton of sense, and I feel a bit embarrassed that I forgot about
>>>>> that item on my TODO list. The patch looks obviously correct!
>>>>
>>>> Thanks, after I sent it I realized that --quit should probably clear
>>>> refs/rewritten as well, so I'll re-roll with that added. (One could argue
>>>> that
>>>> a user might want them after quitting the rebase but there is no way to
>>>> clean
>>>> them up safely once we've deleted the state files and I suspect most users
>>>> would be suprised if they were left laying around)
>>>
>>> I am not so sure. `--quit` is essentially all about "leave the state
>>> as-is, but still abort the rebase".
>>
>> I think it depends on what you mean by "state" `--quit` is about removing
>> state specific to rebases while preserving HEAD, the index and worktree.
> 
> I guess the fault is mine for bleeding out internal rebase state into the
> refs namespace.

I wouldn't feel bad about that, I guess it would be possible to get gc to read a list of objects not to collect from a file in .git/rebase-merge but creating a refs for labels seems like a sensible way to stop them from being collect by gc.

> While I cannot really imagine any harm from this patch in practice, it is
> slightly worrisome that deleting refs also deletes their reflogs,

Yes it's a shame there's no way to get a ref back once it's been deleted (though I'm not sure how long we'd want to keep any reflog of a deleted ref before gc'ing the objects). In any case refs/rewritten only has a reflog if the user has explicitly enabled it.

> which
> makes it an unrecoverable problem *iff* any user runs into trouble with
> this.

I guess "rebase --quit" could print a warning listing the refs that are being deleted so the user can cut and paste if they need to. I'm not sure how likely they are to need that though.

Best Wishes
Phillip
> Ciao,
> Dscho
> 
Previous: Johannes SchindelinNext: SZEDER Gábor
Message 7 of 15 in “rebase --abort: cleanup refs/rewritten”
  1. rebase --abort: cleanup refs/rewrittenPhillip Wood, Apr 26, 2019
  2. Johannes SchindelinApr 29, 2019
  3. Phillip WoodApr 30, 2019
  4. Johannes SchindelinApr 30, 2019
  5. Phillip WoodMay 1, 2019
  6. Johannes SchindelinMay 3, 2019
  7. Phillip WoodMay 3, 2019
  8. SZEDER GáborMay 7, 2019
  9. Junio C HamanoMay 7, 2019
  10. Phillip WoodMay 7, 2019
  11. 0/4 rebase --abort/--quit: cleanup refs/rewrittenPhillip Wood, May 14, 2019
  12. 1/4 rebase: fix a memory leakPhillip Wood, May 14, 2019
  13. 2/4 rebase: warn if state directory cannot be removedPhillip Wood, May 14, 2019
  14. 4/4 rebase --abort/--quit: cleanup refs/rewrittenPhillip Wood, May 14, 2019
  15. 3/4 sequencer: return errors from sequencer_remove_state()Phillip Wood, May 14, 2019

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.