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

Re: [PATCH 0/4] rebase: update branches in multi-part topic

From
Derrick Stolee <derrickstolee@github.com>
Date
Jun 7, 2022, 19:39 UTC
Message-ID
<9354d1d3-c1b7-3baf-215f-30659ad48b22@github.com>
In-Reply-To
<90ccd923-3552-fe88-5d6d-869def7f1aeb@gmail.com>
On 6/7/2022 6:11 AM, Phillip Wood wrote:
Show 31 quoted lines
> On 06/06/2022 16:12, Derrick Stolee wrote:
>> On 6/4/2022 11:28 AM, Phillip Wood wrote:
>>> On 03/06/2022 19:27, Taylor Blau wrote:
>>>> On Fri, Jun 03, 2022 at 01:37:48PM +0000, Derrick Stolee via GitGitGadget wrote:
>>>>> This is a feature I've wanted for quite a while. When working on the sparse
>>>>> index topic, I created a long RFC that actually broke into three topics for
>>>>> full review upstream. These topics were sequential, so any feedback on an
>>>>> earlier one required updates to the later ones. I would work on the full
>>>>> feature and use interactive rebase to update the full list of commits.
>>>>> However, I would need to update the branches pointing to those sub-topics.
>>>>
>>>> This is really exciting. I'm glad that you're working on it, because I
>>>> have also wanted this feature a handful of times over the years.
>>>
>>> Yes, thank you Stolee. I agree this will be useful, but I wonder if users
>>> will be confused that --update-refs only updates the branch heads that happen
>>> to be in the todo list, rather than updating all the branches that contain a
>>> rewritten commit. I think the latter is something we should try to add in the
>>> future and so we should take care to design this topic so that is possible.
>>
>> At the moment, the design adds a comment to the TODO list, showing which
>> branches are not possible to move because they are checked out at another
>> worktree (or is currently checked out and will be updated by the rebase
>> itself). That seems like a good place to insert alternative logic in the
>> future if we see a need for better behavior here.
> 
> I think the question of whether to update branches that are checked out in
> another worktree is a question of whether it is less inconvenient to the user
> to skip the ref update and leave the user to manually update the branch or to> update the ref and leave the worktree in a potentially awkward state if the
> user was half way through building a commit. The answer probably depends on
> the preferences of the user.
I think that their 'git status' will look strange no matter what: their
working directory and index could look significantly different from what
the branch at HEAD is reporting. For this situation, I would rather continue
preventing these ref updates from underneath worktrees.
 
Show 6 quoted lines
> I've been using a script that updates the refs for all the branches being
> rewritten for a while and have found it preferable to always update the ref
> rather than have to do it manually. My script also updates the worktree
> checkout to the new HEAD if there are no uncommitted changes which I have
> found very convenient. My preference is probably because I tend not to have
> uncommitted changes lying around in the worktrees whose branches get updated.
Actually updating the worktree to match seems like an interesting twist, which
we would want to consider if we go this route in the future.
 
Show 17 quoted lines
>> Unless: am I misunderstanding something about your concern here? Are you
>> worried about refs outside of refs/heads/*? Are you concerned about it
>> being _all_ refs/heads/* that we find?
> 
> My concerns are primarily about being able to extend the --update-ref
> option in a backwards compatible way.
> 
> I'd like to be able to add functionality to rebase all refs/heads/* that
> are descended from the commits that a simple rebase would rewrite. Say I want
> to edit $commit then I want the rebase to rewrite all the commits and update
> all the branches in in
> 
>     git rev-list $(git for-each-ref --contains $commit refs/heads/) ^$commit^@
> 
> Ideally we'd avoid adding a new commandline option when adding that. I think
> we could use an optional argument as you suggest below (though it would not be
> a refspec).

This is sort of the opposite of what my series is doing: you want to find all refs that contain the current commits and make sure that they are _also_ rebased as we rebase the current set of commits. That seems like an interesting direction, with a very different set of complexities (ignoring other worktrees seems like much more of a blocker here).

I would consider this to be _yet another mode_ that is separate from --update-refs, though it could share some underlying logic. It gets more complicated if there are merge commits involved (do we have a --rebase-merges option?).

This makes me think of earlier discussions around a "git evolve" command (based on Mercurial's evolve command). The idea is to have a different workflow than I am presenting: instead of creating `fixup!` commits at the top of a multi-part topic, you could check out a branch on a middle part and work forward from there. Then, you could "rebase every branch with a rewritten commit" to get things back into a nice line.

In conclusion: I don't think we should go down this rabbit hole right now.
I think that --update-refs would be something we want to enable by default
if we have such a mode, though.
 
Show 17 quoted lines
>> One potential way to extend this (in the future) is to make --update-refs
>> take an optional string argument containing a refspec. This would replace
>> the default refspec of refs/heads/*.
>> [...] 
>>> Instead of using 'label' and 'exec' I'd prefer a new todo list command
>>> ('update-ref' or 'update-branch'?) used in place of 'label' that takes a
>>> branch name and updates the branch ref at the end of the rebase. That
>>> would make it easy to do all the updates in a single transaction as you
>>> suggested. Adding exec lines to do this makes the todo list messy and we
>>> have been trying to stop rebase forking all the time.
>>
>> Thanks. Yes, a new 'update-refs' step at the end would be good to make
>> it clear we want to rewrite the refs in one go without a possible
>> interruption from the user.
> 
> That's great, it is a bit more work for you but I think it gives a much
> nicer UI.

Thanks. After some hurdles on my end (and some additional complexities discovered in the process) I will have v2 ready soon.

Thanks, -Stolee

Previous: Phillip WoodNext: Junio C Hamano
Message 20 of 144 in “rebase: update branches in multi-part topic”
  1. 0/4 rebase: update branches in multi-part topicDerrick Stolee via GitGitGadget, Jun 3, 2022
  2. 2/4 branch: add branch_checked_out() helperDerrick Stolee via GitGitGadget, Jun 3, 2022
  3. Junio C HamanoJun 3, 2022
  4. 1/4 log-tree: create for_each_decoration()Derrick Stolee via GitGitGadget, Jun 3, 2022
  5. Junio C HamanoJun 3, 2022
  6. Derrick StoleeJun 3, 2022
  7. Junio C HamanoJun 3, 2022
  8. 3/4 rebase: add --update-refs optionDerrick Stolee via GitGitGadget, Jun 3, 2022
  9. Phillip WoodJun 7, 2022
  10. 4/4 rebase: add rebase.updateRefs config optionDerrick Stolee via GitGitGadget, Jun 3, 2022
  11. Junio C HamanoJun 3, 2022
  12. Taylor BlauJun 3, 2022
  13. Junio C HamanoJun 3, 2022
  14. Jeff HostetlerJun 3, 2022
  15. Taylor BlauJun 3, 2022
  16. Junio C HamanoJun 3, 2022
  17. Phillip WoodJun 4, 2022
  18. Derrick StoleeJun 6, 2022
  19. Phillip WoodJun 7, 2022
  20. Derrick StoleeJun 7, 2022
  21. Junio C HamanoJun 8, 2022
  22. Junio C HamanoJun 6, 2022
  23. Elijah NewrenJun 7, 2022
  24. 0/7 rebase: update branches in multi-part topicDerrick Stolee via GitGitGadget, Jun 7, 2022
  25. 1/7 log-tree: create for_each_decoration()Derrick Stolee via GitGitGadget, Jun 7, 2022
  26. 3/7 sequencer: define array with enum valuesDerrick Stolee via GitGitGadget, Jun 7, 2022
  27. Junio C HamanoJun 7, 2022
  28. 2/7 branch: add branch_checked_out() helperDerrick Stolee via GitGitGadget, Jun 7, 2022
  29. Junio C HamanoJun 7, 2022
  30. Derrick StoleeJun 8, 2022
  31. Derrick StoleeJun 8, 2022
  32. Junio C HamanoJun 8, 2022
  33. 4/7 sequencer: add update-refs commandDerrick Stolee via GitGitGadget, Jun 7, 2022
  34. 6/7 sequencer: implement 'update-refs' commandDerrick Stolee via GitGitGadget, Jun 7, 2022
  35. Junio C HamanoJun 7, 2022
  36. 5/7 rebase: add --update-refs optionDerrick Stolee via GitGitGadget, Jun 7, 2022
  37. 7/7 rebase: add rebase.updateRefs config optionDerrick Stolee via GitGitGadget, Jun 7, 2022
  38. Phillip WoodJun 8, 2022
  39. Derrick StoleeJun 8, 2022
  40. Phillip WoodJun 9, 2022
  41. 0/8 rebase: update branches in multi-part topicDerrick Stolee via GitGitGadget, Jun 28, 2022
  42. 1/8 t2407: test branches currently using apply backendDerrick Stolee via GitGitGadget, Jun 28, 2022
  43. Junio C HamanoJun 28, 2022
  44. Derrick StoleeJun 29, 2022
  45. Junio C HamanoJun 30, 2022
  46. Derrick StoleeJun 30, 2022
  47. 8/8 rebase: add rebase.updateRefs config optionDerrick Stolee via GitGitGadget, Jun 28, 2022
  48. 6/8 rebase: add --update-refs optionDerrick Stolee via GitGitGadget, Jun 28, 2022
  49. Junio C HamanoJun 28, 2022
  50. Derrick StoleeJun 29, 2022
  51. Phillip WoodJul 1, 2022
  52. Elijah NewrenJul 1, 2022
  53. Derrick StoleeJul 4, 2022
  54. Elijah NewrenJul 4, 2022
  55. Derrick StoleeJul 5, 2022
  56. Elijah NewrenJul 8, 2022
  57. 7/8 rebase: update refs from 'update-ref' commandsDerrick Stolee via GitGitGadget, Jun 28, 2022
  58. Junio C HamanoJun 28, 2022
  59. Derrick StoleeJun 29, 2022
  60. Junio C HamanoJun 30, 2022
  61. Derrick StoleeJun 29, 2022
  62. Phillip WoodJul 1, 2022
  63. Junio C HamanoJul 1, 2022
  64. Elijah NewrenJul 1, 2022
  65. Derrick StoleeJul 4, 2022
  66. 5/8 sequencer: add update-ref commandDerrick Stolee via GitGitGadget, Jun 28, 2022
  67. Phillip WoodJun 30, 2022
  68. 4/8 sequencer: define array with enum valuesDerrick Stolee via GitGitGadget, Jun 28, 2022
  69. Junio C HamanoJun 28, 2022
  70. 2/8 branch: consider refs under 'update-refs'Derrick Stolee via GitGitGadget, Jun 28, 2022
  71. Junio C HamanoJun 28, 2022
  72. Derrick StoleeJun 29, 2022
  73. Phillip WoodJun 30, 2022
  74. Junio C HamanoJun 30, 2022
  75. Junio C HamanoJun 30, 2022
  76. Phillip WoodJun 30, 2022
  77. Derrick StoleeJun 30, 2022
  78. Phillip WoodJul 1, 2022
  79. 3/8 rebase-interactive: update 'merge' descriptionDerrick Stolee via GitGitGadget, Jun 28, 2022
  80. Junio C HamanoJun 28, 2022
  81. Derrick StoleeJun 29, 2022
  82. Junio C HamanoJun 30, 2022
  83. Phillip WoodJun 30, 2022
  84. Junio C HamanoJun 28, 2022
  85. Phillip WoodJul 1, 2022
  86. 00/12 rebase: update branches in multi-part topicDerrick Stolee via GitGitGadget, Jul 12, 2022
  87. 01/12 t2407: test bisect and rebase as black-boxesDerrick Stolee via GitGitGadget, Jul 12, 2022
  88. 02/12 t2407: test branches currently using apply backendDerrick Stolee via GitGitGadget, Jul 12, 2022
  89. 03/12 branch: consider refs under 'update-refs'Derrick Stolee via GitGitGadget, Jul 12, 2022
  90. Phillip WoodJul 15, 2022
  91. 05/12 sequencer: define array with enum valuesDerrick Stolee via GitGitGadget, Jul 12, 2022
  92. 04/12 rebase-interactive: update 'merge' descriptionDerrick Stolee via GitGitGadget, Jul 12, 2022
  93. 06/12 sequencer: add update-ref commandDerrick Stolee via GitGitGadget, Jul 12, 2022
  94. 07/12 rebase: add --update-refs optionDerrick Stolee via GitGitGadget, Jul 12, 2022
  95. Elijah NewrenJul 16, 2022
  96. Derrick StoleeJul 19, 2022
  97. SZEDER GáborJul 18, 2022
  98. Derrick StoleeJul 18, 2022
  99. Junio C HamanoJul 18, 2022
  100. Derrick StoleeJul 19, 2022
  101. Junio C HamanoJul 19, 2022
  102. Derrick StoleeJul 19, 2022
  103. 08/12 rebase: update refs from 'update-ref' commandsDerrick Stolee via GitGitGadget, Jul 12, 2022
  104. Phillip WoodJul 15, 2022
  105. Derrick StoleeJul 19, 2022
  106. 09/12 sequencer: rewrite update-refs as user edits todo listDerrick Stolee via GitGitGadget, Jul 12, 2022
  107. Phillip WoodJul 15, 2022
  108. Derrick StoleeJul 15, 2022
  109. Phillip WoodJul 18, 2022
  110. Elijah NewrenJul 16, 2022
  111. 11/12 sequencer: ignore HEAD ref under --update-refsDerrick Stolee via GitGitGadget, Jul 12, 2022
  112. 10/12 rebase: add rebase.updateRefs config optionDerrick Stolee via GitGitGadget, Jul 12, 2022
  113. 12/12 sequencer: notify user of --update-refs activityDerrick Stolee via GitGitGadget, Jul 12, 2022
  114. Phillip WoodJul 15, 2022
  115. Derrick StoleeJul 15, 2022
  116. Elijah NewrenJul 16, 2022
  117. Elijah NewrenJul 16, 2022
  118. Derrick StoleeJul 19, 2022
  119. Junio C HamanoJul 12, 2022
  120. Derrick StoleeJul 14, 2022
  121. Junio C HamanoJul 14, 2022
  122. Elijah NewrenJul 16, 2022
  123. Elijah NewrenJul 16, 2022
  124. Phillip WoodJul 15, 2022
  125. 00/12 rebase: update branches in multi-part topicDerrick Stolee via GitGitGadget, Jul 19, 2022
  126. 01/12 t2407: test bisect and rebase as black-boxesDerrick Stolee via GitGitGadget, Jul 19, 2022
  127. 02/12 t2407: test branches currently using apply backendDerrick Stolee via GitGitGadget, Jul 19, 2022
  128. 03/12 branch: consider refs under 'update-refs'Derrick Stolee via GitGitGadget, Jul 19, 2022
  129. 04/12 rebase-interactive: update 'merge' descriptionDerrick Stolee via GitGitGadget, Jul 19, 2022
  130. 05/12 sequencer: define array with enum valuesDerrick Stolee via GitGitGadget, Jul 19, 2022
  131. 06/12 sequencer: add update-ref commandDerrick Stolee via GitGitGadget, Jul 19, 2022
  132. 07/12 rebase: add --update-refs optionDerrick Stolee via GitGitGadget, Jul 19, 2022
  133. 08/12 rebase: update refs from 'update-ref' commandsDerrick Stolee via GitGitGadget, Jul 19, 2022
  134. Phillip WoodJul 21, 2022
  135. 09/12 sequencer: rewrite update-refs as user edits todo listDerrick Stolee via GitGitGadget, Jul 19, 2022
  136. Phillip WoodJul 21, 2022
  137. 10/12 rebase: add rebase.updateRefs config optionDerrick Stolee via GitGitGadget, Jul 19, 2022
  138. 12/12 sequencer: notify user of --update-refs activityDerrick Stolee via GitGitGadget, Jul 19, 2022
  139. 11/12 sequencer: ignore HEAD ref under --update-refsDerrick Stolee via GitGitGadget, Jul 19, 2022
  140. Elijah NewrenJul 21, 2022
  141. Derrick StoleeJul 21, 2022
  142. Elijah NewrenJul 21, 2022
  143. Derrick StoleeJul 21, 2022
  144. Phillip WoodJul 21, 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.