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

Re: [PATCH v7 3/3] replay: offer an option to linearize the commit topology

From
Toon Claes <toon@iotcl.com>
Date
Jul 27, 2026, 13:07 UTC
Message-ID
<87bjbs4m43.fsf@emacs.iotcl.com>
In-Reply-To
<CABPp-BGdK8v8Qk5XB=QL_yJDPTNjSb2rN08GiPpK50V2gAj1QQ@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
> As I proposed last time, I'd be fine with erroring on multiple
> positive refs as an interim step (plus associated documentation and
> commit message updates) so this series lands, with per-branch
> linearization as the real fix later.

I appreciate you're open to this interim step, but I would like to understand the end goal better before we continue.

> TL;DR version; my problems with the current implementation of
> `--linearize` are that it:
>   * Makes the rare usecase easy, and ignores the common usecase

Cannot deny that, although I'm not sure git-replay(1) is a popular end-user command.

>   * Makes it asymmetrically difficult to recover for those that wanted
> the common usecase instead of the easy

I don't think many users would use --linearize anyway. I'm guessing properly replaying merges would be far more useful to most people. I'm adding it mostly to scratch my own itch: do a server-side non-interactive rebase that's identical git-rebase(1)'s --no-rebase-merges.

>   * Makes `--linearize` mean something other than "remove non-linearity"

It's debatable what it means, because you can think of it linearizing all reachable commits (see also below what you said context of gitrevisions(7)).

Show 5 quoted lines
>   * Turns multiple branches into one, but updates several branches anyway
>   * Ignores order specified by the user on the command line
>   * Introduces an inconsistency within git-replay between `--advance`
> and `--linearize --onto`
> (The last three items being minor compared to the first three.)

I'm surprised you consider these three more minor, because I have more issues with them personally (the ordering in particular).

I don't have a feasible example, but as I understand from your argumentation, v7 might make commits reachable from a branch where they weren't before:

Show 21 quoted lines
> M1  M2  M3  M4  M5
> *---*---*---*---* <- master
>                 |
>                 |  A1  A2  A3  A4
>                 |--*---*---*---* <- branchA
>                 |      \
>                 |       -*---* <- branchC
>                 |        C1  C2
>                 |
>                 \-*---*---* <- branchB
>                   B1  B2  B3
> 
> With the current implementation of --linearize, adding that flag, i.e.
>     git replay --linearize --onto master branchA branchB branchC
> would instead give something like:
> 
> M1  M2  M3  M4  M5  B1  B2  B3  A1  A2  C1  C2  A3  A4
> *---*---*---*---*---*---*---*---*---*---*---*---*---*
>                 ^           ^               ^       ^
>                 |           |               |       |
>               master     branchB         branchC  branchA

Before the replay, branchC didn't reach any commits in branchB, while it does now. It kind of makes sense though, because branchC is specified after branchB. But then again, why does now branchA contain branchB and branchC? That's the problem I have with the ordering.

Show 15 quoted lines
> I think I know what you mean, but this isn't quite right:
> git-replay(1) only ever accepts a single revision range.  From
> gitrevisions(7) (also in git-rev-parse(1)):
> 
>        Commands that are specifically designed to take two distinct ranges
>        (e.g. "git range-diff R1 R2" to compare two ranges) do exist, but they
>        are exceptions. Unless otherwise noted, all "git" commands that operate
>        on a set of commits work on a single revision range. In other words,
>        writing two "two-dot range notation" next to each other, e.g.
> 
>            $ git log A..B C..D
> 
>        does not specify two revision ranges for most commands. Instead it will
>        name a single connected set of commits, i.e. those that are reachable
>        from either B or D but are reachable from neither A or C.

You could think v7's implementation of --linearize converts the "distinct ranges" into a "single connected set of commits", but then the option name isn't very good.

Show 5 quoted lines
> The reason I am comfortable with erroring out as a stopgap: turning an
> error into working behavior later never breaks anyone, whereas letting the
> current concatenation semantics reach 'master' risks users coming to
> depend on them, which would make switching to the better behavior a
> compatibility break.
I absolutely agree with that approach.
> Erroring now keeps our options open; merging as-is
> quietly closes them.  (git-replay is still EXPERIMENTAL, so this is not
> fatal either way, but it seems better not to paint ourselves into a
> corner.)

Being EXPERIMENTAL allows us to break things if we discover we didn't think about before, that's not the case here.

But then again, what do we do about --contained?
M1  M2  M3  M4  M5
*---*---*---*---* <- master
     \
      \  A1  A2  A3  A4  A5  A6
       \-*---*---*---*---*---* <- branchA
          \   \     /   /
           \   *---*   /  <- branchB
            \  B1  B2 /
             \---*---/  <- branchC
                 C1
This would end up into something like:
M1  M2  M3  M4  M5
*---*---*---*---* <- master
                |
                |   A1  A2  A3  B1  B2  C1 A6
                \---*---*---*---*---*---*---* <- branchA
                           branchB -^   ^- branchC
Same issue, branchC suddenly contains the commits of branchB.

The only way we can linearize (as in flatten merges) these branches is by replaying some commits twice:

M1  M2  M3  M4  M5
*---*---*---*---* <- master
                |
                |   A1  A2  A3  B1  B2  C1 A6
                \---*---*---*---*---*---*---* <- branchA
                     \   \
                      \   \---*---*           <- branchB
                       \     B1'  B2'
                        \---*                 <- branchC
                            C1'

But is that what the user wants? They could achieve that with running git-replay(1) once for every single branch separately (let's assume they set COMMITTER_DATE). Is this the end goal we want for --linearize with multiple revision ranges? I don't think that's doable with the last_commit per branch.

But for now, I would say --contained is not allowed with --linearize as well.

And maybe, maybe we should make --ref required when --linearize is given. Then the user would do something like:

    $ git replay --onto master branchA branchB branchC --ref branchA

This makes the end result unambiguous: take all commits reachable from these 3 branches, replay them linearly onto 'master' and *only* update ref 'branchA'.

-- 
Cheers,
Toon
Previous: Junio C HamanoNext: Toon Claes
Message 62 of 75 in “Teach git-replay(1) to linearize merge commits”
  1. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jun 8, 2026
  2. 1/3 replay: refactor enum replay_mode into a boolToon Claes, Jun 8, 2026
  3. 2/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 8, 2026
  4. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 8, 2026
  5. Junio C HamanoJun 8, 2026
  6. Toon ClaesJun 10, 2026
  7. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jun 10, 2026
  8. 1/3 replay: refactor enum replay_mode into a boolToon Claes, Jun 10, 2026
  9. 2/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 10, 2026
  10. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 10, 2026
  11. Junio C HamanoJun 10, 2026
  12. Justin ToblerJun 11, 2026
  13. Toon ClaesJun 12, 2026
  14. Elijah NewrenJun 14, 2026
  15. Toon ClaesJun 16, 2026
  16. Toon ClaesJun 16, 2026
  17. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jun 16, 2026
  18. 1/3 replay: refactor enum replay_mode into a boolToon Claes, Jun 16, 2026
  19. 2/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 16, 2026
  20. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 16, 2026
  21. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jun 22, 2026
  22. 1/3 replay: refactor enum replay_mode into a boolToon Claes, Jun 22, 2026
  23. 2/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 22, 2026
  24. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 22, 2026
  25. Patrick SteinhardtJun 22, 2026
  26. Patrick SteinhardtJun 22, 2026
  27. Patrick SteinhardtJun 22, 2026
  28. Junio C HamanoJun 22, 2026
  29. Toon ClaesJun 24, 2026
  30. Toon ClaesJun 26, 2026
  31. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jun 26, 2026
  32. 1/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 26, 2026
  33. 2/3 replay: better explain how pick_regular_commit() picks a baseToon Claes, Jun 26, 2026
  34. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 26, 2026
  35. Junio C HamanoJun 26, 2026
  36. Junio C HamanoJun 26, 2026
  37. Phillip WoodJun 27, 2026
  38. Johannes SchindelinJun 28, 2026
  39. Patrick SteinhardtJun 29, 2026
  40. Johannes SchindelinJun 30, 2026
  41. Patrick SteinhardtJun 30, 2026
  42. Toon ClaesJun 30, 2026
  43. Toon ClaesJul 1, 2026
  44. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jul 2, 2026
  45. 1/3 replay: add helper to put entry into replayed_commitsToon Claes, Jul 2, 2026
  46. 2/3 replay: resolve the replay base outside pick_regular_commit()Toon Claes, Jul 2, 2026
  47. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jul 2, 2026
  48. Junio C HamanoJul 3, 2026
  49. Toon ClaesJul 7, 2026
  50. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jul 7, 2026
  51. 1/3 replay: add helper to put entry into replayed_commitsToon Claes, Jul 7, 2026
  52. 2/3 replay: resolve the replay base outside pick_regular_commit()Toon Claes, Jul 7, 2026
  53. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jul 7, 2026
  54. Junio C HamanoJul 7, 2026
  55. Junio C HamanoJul 8, 2026
  56. Elijah NewrenJul 10, 2026
  57. Junio C HamanoJul 13, 2026
  58. Elijah NewrenJul 15, 2026
  59. Junio C HamanoJul 15, 2026
  60. Elijah NewrenJul 16, 2026
  61. Junio C HamanoJul 17, 2026
  62. Toon ClaesJul 27, 2026
  63. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jul 28, 2026
  64. 1/3 replay: add helper to put entry into replayed_commitsToon Claes, Jul 28, 2026
  65. 2/3 replay: resolve the replay base outside pick_regular_commit()Toon Claes, Jul 28, 2026
  66. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jul 28, 2026
  67. Junio C HamanoJul 28, 2026
  68. Justin ToblerAug 7, 2026
  69. Elijah NewrenAug 8, 2026
  70. Toon ClaesAug 31, 2026
  71. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Aug 31, 2026
  72. 1/3 replay: add helper to put entry into replayed_commitsToon Claes, Aug 31, 2026
  73. 2/3 replay: resolve the replay base outside pick_regular_commit()Toon Claes, Aug 31, 2026
  74. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Aug 31, 2026
  75. Elijah NewrenSep 1, 2026

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.