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

Re: An alternate model for preparing partial commits

From
DJDavid Jeske <jeske@willowmail.com>
Date
Aug 13, 2016, 23:23 UTC
Message-ID
<willow-jeske-01l7Zen6FEDjCbjR>
In-Reply-To
<9af502e50806262350t6e794a92g7751147f1882965@mail.gmail.com>
Robert, I'm new to git, but I understand where you are going.

Why limit it only to working tree changes? For me, the stash machinery is of no help here, because I commit super-often. What I end up with is 30 commits in a topic branch, but where not every point passes 100% of tests. I want to go back through and order them properly, and decide which points are sensible as upstream committs. (especially as I read more about bisect).

git has all the concepts I want except one. However, it makes the process pretty manual. Here is an idea about automating it. I'll talk about that one new concept at the bottom.

I think of this as reorder/merge/split...

reorder: Picture that a list of commits on this branch opens in an editor. You are free to rearrange the lines in any order you want, but you have to keep all the lines. When you are done reordering the lines, the tool creates a new topic branch and applies the changes (probably with cherrypick) to the new topic branch. If there are no conflicts, you're done.

merge: Picture now that in your editor you can create groupings of those individual commits that should make up separate topic-branches. The operation can still be performed automatically, and at the end, it can compose those topic branches into a single branch just like your original. At this point, you can "isolate" any one of those topic branches and test/push that topic branch.

split: Picture now that you can list the same commit in more than one of the topic-branches. This is a little more tricky, and there is no way to do it automatically.. It drops you into an editor and asks you to select the lines of the diff for the first topic. The remaining lines are put in the next topic. This can continue for multiple topics.

This seems like something that could be assembled pretty easily on top of the current git mechanisms, except for one thing.

If you use merge, the history will be a mess. If you use rebase, anyone else who pulled your topic branch will be in a world of hurt.

I've been thinking about a solution for this I think of as "supercede".

Once you have completed the above reorder/merge/split, your new topic branch should be EXACTLY the same as your old topic branch. (if it's not, it needs to be trued up to be so). At that point, it is safe to ask for that new line of commits to supercede the old line. Other people who have pulled in your older ordered topic branch would then be able to pull/rebase/etc, and the merge machinery would be able to back out their set of changes, and supercede them with your new ordering.

This mechanism is intended to combine the benefits of rebase-clean-history and the benefits of the dag-links for merging. I find it convenient to think of it as stack push/pop for portions of the dag. Because of the supercede - the history knows it can avoid showing you all the superceded dag nodes, however, because those nodes are there, it can still use them to compute merges.

If this behaves the way I think, this has another powerful effect. You can pull in a set of draft changes; you can build off them; you can periodically rebase them, and if those draft changes end up in the mainline, because the merge-history is still there, git can 'do the right thing' and remove those changes from your topic branch. In fact, because of the SHA1 strong naming, it doesn't even matter where you got them from. You could apply a patch from the mailing list and as long as everyone applies that patch as only a single commit, when the string of supercedes shows up on the main branch git will just 'do-the right thing' to remove them from your topic branch when you rebase (or skip them during a merge down to your topic branch).

Previous: David JeskeNext: Robert Anderson
Message 37 of 57 in “An alternate model for preparing partial commits”
  1. Robert AndersonJun 27, 2008
  2. Björn SteinbrinkJun 27, 2008
  3. stash: introduce 'stash save --keep-index' optionSZEDER Gábor, Jun 27, 2008
  4. Junio C HamanoJun 27, 2008
  5. Robert AndersonJun 27, 2008
  6. Björn SteinbrinkJun 27, 2008
  7. Robert AndersonJun 27, 2008
  8. Johannes SixtJun 27, 2008
  9. Robert AndersonJun 27, 2008
  10. Petr BaudisJun 27, 2008
  11. Robert AndersonJun 27, 2008
  12. Johannes SchindelinJun 27, 2008
  13. Miklos VajnaJun 27, 2008
  14. Robert AndersonJun 27, 2008
  15. Johannes SchindelinJun 27, 2008
  16. Robert AndersonJun 27, 2008
  17. Dana HowJun 27, 2008
  18. Stephen SinclairJun 27, 2008
  19. David JeskeJun 27, 2008
  20. David JeskeAug 13, 2016
  21. Wincent ColaiutaJun 28, 2008
  22. Dmitry PotapovJun 28, 2008
  23. Robert AndersonJun 28, 2008
  24. Dmitry PotapovJun 28, 2008
  25. Junio C HamanoJun 27, 2008
  26. Robert AndersonJun 27, 2008
  27. Jeff KingJun 28, 2008
  28. Robert AndersonJun 28, 2008
  29. Jeff KingJun 28, 2008
  30. Junio C HamanoJun 28, 2008
  31. Johannes SchindelinJun 28, 2008
  32. Jeff KingJul 8, 2008
  33. David JeskeJun 27, 2008
  34. Jakub NarebskiJun 27, 2008
  35. David JeskeJun 27, 2008
  36. David JeskeAug 13, 2016
  37. David JeskeAug 13, 2016
  38. Robert AndersonJun 27, 2008
  39. Robert AndersonJun 27, 2008
  40. Junio C HamanoJun 27, 2008
  41. Robert AndersonJun 28, 2008
  42. Dmitry PotapovJun 28, 2008
  43. Robert AndersonJun 28, 2008
  44. Stephen SinclairJun 28, 2008
  45. Robert AndersonJun 28, 2008
  46. Robert AndersonJun 28, 2008
  47. Jakub NarebskiJun 28, 2008
  48. Robert AndersonJun 28, 2008
  49. David JeskeJun 28, 2008
  50. David JeskeAug 13, 2016
  51. Stephen SinclairJun 28, 2008
  52. David JeskeJun 28, 2008
  53. David JeskeAug 13, 2016
  54. Fwd: An alternate model for preparing partial commitsRobert Anderson, Jun 28, 2008
  55. Dmitry PotapovJun 28, 2008
  56. Robert AndersonJun 28, 2008
  57. Dmitry PotapovJun 28, 2008

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.