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

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

From
Toon Claes <toon@iotcl.com>
Date
Jul 7, 2026, 15:09 UTC
Message-ID
<87ldbm3kh6.fsf@emacs.iotcl.com>
In-Reply-To
<xmqqbjcnhjvk.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 23 quoted lines
> Toon Claes <toon@iotcl.com> writes:
>
>> From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>> ...
>> Linearizing is a distinct operation, and flattening merge commits is
>> just one aspect of that. Recreating merges would be a separate mode, so
>> rather than mirror git-rebase(1)'s `--rebase-merges[=<mode>]` interface,
>> git-replay(1) uses its own `--linearize` option.
>>
>> Co-authored-by: Toon Claes <toon@iotcl.com>
>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>> Signed-off-by: Toon Claes <toon@iotcl.com>
>> ---
>>  Documentation/git-replay.adoc |  21 ++++++-
>>  builtin/replay.c              |   6 +-
>>  replay.c                      |  54 ++++++++++------
>>  replay.h                      |   5 ++
>>  t/t3650-replay-basics.sh      | 140 +++++++++++++++++++++++++++++++++++++++++-
>>  5 files changed, 203 insertions(+), 23 deletions(-)
>
> With such an extensive change in behaviour, I wonder if Dscho is
> still responsible for latent bugs in this round of implementation
> and documentation, or should you take the responsibility over?
I don't mind. But I don't want to steal credit.

Initially, when Dscho shared the patch with me, he already informed me he doesn't really care about authorship. So in the next version I'll be taking over authorship and add a Based-on-patches-by trailer.

@Dscho, let me know if you disagree?
Show 38 quoted lines
>> +--linearize::
>> +	In this mode, each replayed commit is stacked on top of the
>> +	previously replayed one, so all replayed commits are flattened into
>> +	a single linear history.
>> ++
>> +When a merge commit is encountered, the behavior of git-rebase(1)'s
>> +option `--no-rebase-merges` is imitated. All commits in the range
>> +reachable from the merge commit are replayed into a linear history, and
>> +the merge commit itself is dropped. A ref that pointed to a merge commit
>> +is updated to the merge's last replayed ancestor.
>> ++
>> +This flattens the `<revision-range>` as a whole. When multiple revision
>> +ranges are given they are stacked on top of each other into one linear
>> +history. Each of their refs is updated to point to its position in that
>> +history. To linearize ranges separately, replay them in separate `git
>> +replay` invocations.
>
> OK, very much understandable.
>
>> +This option is incompatible with `--revert`.
>
> Definitely it is OK to leave it outside the scope, but I am not sure
> if reverting a group of commits that happens to be "closed" and
> happens to contain merges, is inherently incompatible with
> flattening.  If you have
>
>     ----O--A
>          \  \
>           B--M--C
>
> and you want to revert what happened while the history advanced from
> O to M, I would naïvely expect that I can arrive at
>
>     ----O--A
>          \  \
>           B--M--C-B'-A'
>
> by linearly applying the inverse of A and B (in either order).

You're absolutely right. Personally I'm not sure why the limitation was introduced. I've done some testing and I cannot see why we wouldn't allow --revert and --linearize to be combined. So I'll be submitting v7 without this restriction.

-- 
Cheers,
Toon
Previous: Junio C HamanoNext: Junio C Hamano
Message 49 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. Justin ToblerJun 11, 2026
  10. Toon ClaesJun 12, 2026
  11. 2/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 10, 2026
  12. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 10, 2026
  13. Junio C HamanoJun 10, 2026
  14. Toon ClaesJun 16, 2026
  15. Elijah NewrenJun 14, 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. Patrick SteinhardtJun 22, 2026
  24. Junio C HamanoJun 22, 2026
  25. Toon ClaesJun 24, 2026
  26. 2/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 22, 2026
  27. Patrick SteinhardtJun 22, 2026
  28. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 22, 2026
  29. Patrick SteinhardtJun 22, 2026
  30. Toon ClaesJun 26, 2026
  31. Patrick SteinhardtJun 29, 2026
  32. Johannes SchindelinJun 30, 2026
  33. Patrick SteinhardtJun 30, 2026
  34. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jun 26, 2026
  35. 1/3 replay: add helper to put entry into mapped_commitsToon Claes, Jun 26, 2026
  36. Junio C HamanoJun 26, 2026
  37. 2/3 replay: better explain how pick_regular_commit() picks a baseToon Claes, Jun 26, 2026
  38. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jun 26, 2026
  39. Junio C HamanoJun 26, 2026
  40. Phillip WoodJun 27, 2026
  41. Toon ClaesJul 1, 2026
  42. Johannes SchindelinJun 28, 2026
  43. Toon ClaesJun 30, 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. Junio C HamanoJul 7, 2026
  51. 0/3 Teach git-replay(1) to linearize merge commitsToon Claes, Jul 7, 2026
  52. 1/3 replay: add helper to put entry into replayed_commitsToon Claes, Jul 7, 2026
  53. 2/3 replay: resolve the replay base outside pick_regular_commit()Toon Claes, Jul 7, 2026
  54. 3/3 replay: offer an option to linearize the commit topologyToon Claes, Jul 7, 2026
  55. Elijah NewrenJul 10, 2026
  56. Junio C HamanoJul 13, 2026
  57. Elijah NewrenJul 15, 2026
  58. Junio C HamanoJul 15, 2026
  59. Elijah NewrenJul 16, 2026
  60. Junio C HamanoJul 17, 2026
  61. Toon ClaesJul 27, 2026
  62. Junio C HamanoJul 8, 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. Justin ToblerAug 7, 2026
  68. Elijah NewrenAug 8, 2026
  69. Toon ClaesAug 31, 2026
  70. Junio C HamanoJul 28, 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.