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

Re: [RFC PATCH 0/1] rebase --onto detection of already applied commits

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Dec 15, 2022, 15:40 UTC
Message-ID
<3c5cb346-e6b4-7b85-6d3e-4b625cc21a94@dunelm.org.uk>
In-Reply-To
<9e06bfd1-3e63-2414-e18c-6901fbb290e3@collabora.com>
Hi Cristian
On 13/12/2022 15:34, Cristian Ciocaltea wrote:
Show 31 quoted lines
> Hi Phillip,
> 
> On 12/13/22 15:04, Phillip Wood wrote:
>> Hi Christian
>>
>> On 13/12/2022 10:37, Cristian Ciocaltea wrote:
>>> Currently '--onto' works as if the user provided the 
>>> '--reapply-cherry-picks' flag,
>>
>> --onto does not affect the cherry-pick detection. When running
>>
>>      git rebase --onto new-base upstream feature
>>
>> any commits in upstream have been cherry-picked from feature they will 
>> not be rebased. What it does not do is look for cherry-picks in 
>> onto...feature. It would be nice to add that but I'm not sure it is 
>> straight forward to do so and still exclude commits that have been 
>> cherry-picked from feature to upstream.
> 
> The proposed patch enables looking for commits into new-base..feature 
> range and excluding the ones reachable from upstream. Since this is a 
> change in the existing behavior, we might need to introduce a new flag 
> to enable it. I previously suggested to use '--no-reapply-cherry-picks' 
> for this purpose, but now it's pretty obvious this will be a source of 
> confusion, since the "cherry-picks" term refers to the commits picked 
> from feature to upstream instead of new-base, as you already mentioned.
> 
> I agree it would be nice to support both exclusion ranges, but I'm not 
> sure how complicated the implementation would be, since I don't have any 
> previous experience with the Git internals. Could this be added as a 
> separate feature at a later point?

If we can I'd rather add code that excludes cherry-pick both ranges. To remove the cherry-picks that are in upstream and new-base you could rework the todo list generation as follows

1. Calculate the merge-base $mb of feature and upstream
2. Store the list of commits $mb..feature in an array and in a hash
    table indexed their patch-id.
3. Walk $mb..upstream calculating the patch-id for each commit and
    removing any commit in the list from step 2 that matches.
4. If onto is equal to upstream skip to step 7
5. Calculate the merge-base $mb of feature and onto.
6. Walk $mb..new-base calculating the patch-id for each commit and
    removing any commit in the list from step 2 that matches.
7. Generate the todo list using the modified list of commits from step
    2.

I don't have much time at the moment but I can try and help a bit more in the New Year if you want.

Best Wishes
Phillip
Previous: Cristian CiocalteaNext: Cristian Ciocaltea
Message 10 of 12 in “rebase --onto detection of already applied commits”
  1. 0/1 rebase --onto detection of already applied commitsCristian Ciocaltea, Dec 12, 2022
  2. 1/1 rebase --onto: Skip previously applied commitsCristian Ciocaltea, Dec 12, 2022
  3. Ævar Arnfjörð BjarmasonDec 12, 2022
  4. Cristian CiocalteaDec 12, 2022
  5. Junio C HamanoDec 13, 2022
  6. Cristian CiocalteaDec 13, 2022
  7. Junio C HamanoDec 13, 2022
  8. Phillip WoodDec 13, 2022
  9. Cristian CiocalteaDec 13, 2022
  10. Phillip WoodDec 15, 2022
  11. Cristian CiocalteaDec 15, 2022
  12. Phillip WoodDec 15, 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.