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

Re: [RFC PATCH] add t3420-rebase-topology

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 18, 2012, 07:51 UTC
Message-ID
<7vzk4nojkd.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1347949878-12578-1-git-send-email-martinvonz@gmail.com>
Martin von Zweigbergk <martinvonz@gmail.com> writes:
> do you agree
> that 'rebase --onto does not re-apply patches in onto' is desirable?

This depends on how you look at --onto. Recall the most typical and the original use case of rebase:

                               A'--C' your rebased work
                              /
  ---o---o---o---F---B'--o---T master
     ^            \
     v1.7.12       A---B---C your work
You could view "git rebase master" as a short-hand for
        $ git rebase --onto $(git merge-base master HEAD) master
i.e.
        $ git rebase --onto F master

If you view "onto" that way, you would certainly do not want to see B replayed on top of T, which already contains another replay of B in its history.

The intended use case for "--onto", however, is primarily to replay a history to older base, i.e.

       A'--B'--C' your rebased work
      /
  ---o---o---o---F---B'--o---T master
     ^            \
     v1.7.12       A---B---C your work
        $ git rebase --onto v1.7.12 master
which is a moral equivalent of
        $ git checkout v1.7.12
        $ git cherry-pick A B C ;# or git cherry-pick master..HEAD

You could argue that you can compute the patch equivalence between the commits in "onto..master" and commits in "master..HEAD" and filter out the equivalent commits to reach the expected results in either cases, and at the logical level, it certainly will produce the result I showed in the above illustrations.

But there are two flaws in such an argument.

The "replay to an updated base" case (i.e. without "--onto") expects to see duplicated commits in the updated history. That is the only reason you would want to rebase---otherwise you can keep the old fork point and keep polishing your work and merge when it is truly ready. More importantly, the old master (the fork point F) and updated master (the current tip T) are expected to have some ancestry relationship between them. For these reasons, running the equivalent of "git cherry" to filter commits with patch equivalence makes perfect sense.

On the other hand, when the user replays to an older base, she has some idea what constitutes "a series" that she is replaying (i.e. "$(git merge-base master HEAD)..HEAD"). It smells to go against the user's world model if the command silently filtered commits by patch equivalence. The user wanted to replay A, B and C in that case, and it is better to stop the process and make her inspect the history when the older base happened to have a patch-equivalent commit that would cause a conflict. That would give her a chance to assess the situation, instead of silently dropping some of these three commits that she initially thought constitutes the series and ending up with a series with only two commits.

Besides, the whole point of a separate "onto" is to allow the user to specify a commit that does not have a straightforward ancestry relationship with the bottom of the series (i.e. either "master" or "F"), and computation of patch equivalence is expected to be much higher. Given that it is unlikely to find any match, it feels doubly wrong to always run "git cherry" equivalent in that case.

So I dunno, as I can argue both ways.

My gut feeling is that "git rebase master" and "git rebase --onto F master" should not be identical in this regard and an explicit "onto" should omit the patch equivalence filtering, but I can be persuaded otherwise with good arguments.

> How about 'rebase --root is not a no-op'?
  ---o---o---o---F---B'--o---T master
     ^            \
     v1.7.12       A---B---C your work

If "git rebase F" when you are at C in the above illustration (reproduced only the relevant parts) is a no-op (and I think it should be), "git rebase --root" in the illustration below ought to be as well, no?

                 F---B'--o---T master
                  \
                   A---B---C your work
Previous: Martin von ZweigbergkNext: Martin von Zweigbergk
Message 2 of 75 in “add t3420-rebase-topology”
  1. add t3420-rebase-topologyMartin von Zweigbergk, Sep 18, 2012
  2. Junio C HamanoSep 18, 2012
  3. Martin von ZweigbergkSep 21, 2012
  4. Johannes SixtSep 18, 2012
  5. Martin von ZweigbergkSep 26, 2012
  6. Chris WebbSep 27, 2012
  7. Martin von ZweigbergkSep 28, 2012
  8. Chris WebbSep 29, 2012
  9. 0/7 Rebase topology testMartin von Zweigbergk, May 29, 2013
  10. 1/7 add simple tests of consistency across rebase typesMartin von Zweigbergk, May 29, 2013
  11. Martin von ZweigbergkJun 3, 2013
  12. Junio C HamanoJun 3, 2013
  13. Martin von ZweigbergkJun 3, 2013
  14. 2/7 add tests for rebasing with patch-equivalence presentMartin von Zweigbergk, May 29, 2013
  15. Johannes SixtMay 29, 2013
  16. Martin von ZweigbergkMay 30, 2013
  17. Felipe ContrerasMay 30, 2013
  18. Martin von ZweigbergkMay 30, 2013
  19. Felipe ContrerasMay 30, 2013
  20. Martin von ZweigbergkMay 30, 2013
  21. Johannes SixtMay 30, 2013
  22. Martin von ZweigbergkMay 30, 2013
  23. 3/7 add tests for rebasing of empty commitsMartin von Zweigbergk, May 29, 2013
  24. 4/7 add tests for rebasing rootMartin von Zweigbergk, May 29, 2013
  25. Johannes SixtMay 29, 2013
  26. Martin von ZweigbergkMay 30, 2013
  27. 5/7 add tests for rebasing merged historyMartin von Zweigbergk, May 29, 2013
  28. Johannes SixtMay 29, 2013
  29. Martin von ZweigbergkMay 31, 2013
  30. Johannes SixtMay 29, 2013
  31. 6/7 t3406: modernize styleMartin von Zweigbergk, May 29, 2013
  32. 7/7 tests: move test for rebase messages from t3400 to t3406Martin von Zweigbergk, May 29, 2013
  33. Felipe ContrerasMay 29, 2013
  34. Ramkumar RamachandraMay 29, 2013
  35. Felipe ContrerasMay 29, 2013
  36. 0/7 Rebase topology testMartin von Zweigbergk, May 31, 2013
  37. 1/7 add simple tests of consistency across rebase typesMartin von Zweigbergk, May 31, 2013
  38. 2/7 add tests for rebasing with patch-equivalence presentMartin von Zweigbergk, May 31, 2013
  39. 3/7 add tests for rebasing of empty commitsMartin von Zweigbergk, May 31, 2013
  40. 4/7 add tests for rebasing rootMartin von Zweigbergk, May 31, 2013
  41. 5/7 add tests for rebasing merged historyMartin von Zweigbergk, May 31, 2013
  42. Johannes SixtMay 31, 2013
  43. 5/7 add tests for rebasing merged historyMartin von Zweigbergk, Jun 1, 2013
  44. 6/7 t3406: modernize styleMartin von Zweigbergk, May 31, 2013
  45. 7/7 tests: move test for rebase messages from t3400 to t3406Martin von Zweigbergk, May 31, 2013
  46. 0/7 Rebase topology testMartin von Zweigbergk, Jun 3, 2013
  47. 1/7 add simple tests of consistency across rebase typesMartin von Zweigbergk, Jun 3, 2013
  48. Junio C HamanoJun 3, 2013
  49. Martin von ZweigbergkJun 4, 2013
  50. Junio C HamanoJun 4, 2013
  51. Johannes SixtJun 4, 2013
  52. Martin von ZweigbergkJun 5, 2013
  53. 2/7 add tests for rebasing with patch-equivalence presentMartin von Zweigbergk, Jun 3, 2013
  54. 3/7 add tests for rebasing of empty commitsMartin von Zweigbergk, Jun 3, 2013
  55. 4/7 add tests for rebasing rootMartin von Zweigbergk, Jun 3, 2013
  56. 5/7 add tests for rebasing merged historyMartin von Zweigbergk, Jun 3, 2013
  57. Junio C HamanoJun 4, 2013
  58. Martin von ZweigbergkJun 5, 2013
  59. Johannes SixtJun 5, 2013
  60. 6/7 t3406: modernize styleMartin von Zweigbergk, Jun 3, 2013
  61. 7/7 tests: move test for rebase messages from t3400 to t3406Martin von Zweigbergk, Jun 3, 2013
  62. 0/8 Rebase topology testMartin von Zweigbergk, Jun 7, 2013
  63. 1/7 add simple tests of consistency across rebase typesMartin von Zweigbergk, Jun 7, 2013
  64. 2/7 add tests for rebasing with patch-equivalence presentMartin von Zweigbergk, Jun 7, 2013
  65. 3/7 add tests for rebasing of empty commitsMartin von Zweigbergk, Jun 7, 2013
  66. 4/7 add tests for rebasing rootMartin von Zweigbergk, Jun 7, 2013
  67. 5/7 add tests for rebasing merged historyMartin von Zweigbergk, Jun 7, 2013
  68. 6/7 t3406: modernize styleMartin von Zweigbergk, Jun 7, 2013
  69. 7/7 tests: move test for rebase messages from t3400 to t3406Martin von Zweigbergk, Jun 7, 2013
  70. Junio C HamanoJun 7, 2013
  71. Johannes SixtJun 7, 2013
  72. rebase topology tests: fix commit names on case-insensitive file systemsJohannes Sixt, Jun 18, 2013
  73. Junio C HamanoJun 18, 2013
  74. Martin von ZweigbergkJun 18, 2013
  75. Johannes SixtJun 19, 2013

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.