git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] replay: add --revert option to reverse commit changes
@ 2025-11-25 17:00 Siddharth Asthana
  2025-11-25 17:00 ` [PATCH 1/1] " Siddharth Asthana
                   ` (2 more replies)
  0 siblings, 3 replies; 44+ messages in thread
From: Siddharth Asthana @ 2025-11-25 17:00 UTC (permalink / raw)
  To: git
  Cc: christian.couder, ps, newren, gitster, phillip.wood123,
	phillip.wood, karthik.188, code, rybak.a.v, jltobler, toon,
	johncai86, johannes.schindelin, Siddharth Asthana

The `git replay` command currently supports cherry-picking commits for
server-side history rewriting, but lacks the ability to revert them.
This patch adds a `--revert` option to enable reversing commits directly
on bare repositories.

At GitLab, we use replay in Gitaly for efficient server-side operations.
Adding revert functionality enables us to reverse problematic commits
without client-side roundtrips, reducing network overhead.

The implementation leverages the insight that cherry-pick and revert are
essentially the same merge operation with swapped arguments. By swapping
the base and pickme trees when calling `merge_incore_nonrecursive()`, we
effectively reverse the diff direction. The existing conflict handling,
ref updates, and atomic transaction support work unchanged.

The revert message generation logic is extracted into a new shared
`sequencer_format_revert_header()` function in `sequencer.c`, allowing
code reuse between `sequencer.c` and `builtin/replay.c`. The commit
messages follow `git revert` conventions, including "Revert"/"Reapply"
prefixes and the original commit SHA.

This patch includes comprehensive tests covering various scenarios:
bare repositories, --advance mode, conflicts, reapply behavior, and
multiple commits.

Siddharth Asthana (1):
  replay: add --revert option to reverse commit changes

 Documentation/git-replay.adoc |  35 +++++++-
 builtin/replay.c              |  86 ++++++++++++++----
 sequencer.c                   |  23 +++++
 sequencer.h                   |   8 ++
 t/t3650-replay-basics.sh      | 160 ++++++++++++++++++++++++++++++++++
 5 files changed, 295 insertions(+), 17 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2025-12-16 16:23 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-25 17:00 [PATCH 0/1] replay: add --revert option to reverse commit changes Siddharth Asthana
2025-11-25 17:00 ` [PATCH 1/1] " Siddharth Asthana
2025-11-25 19:22   ` Junio C Hamano
2025-11-25 19:30     ` Junio C Hamano
2025-11-25 19:39       ` Junio C Hamano
2025-11-25 20:06         ` Junio C Hamano
2025-11-26 19:31           ` Siddharth Asthana
2025-11-26 19:28         ` Siddharth Asthana
2025-11-26 19:26     ` Siddharth Asthana
2025-11-26 21:13       ` Junio C Hamano
2025-11-27 19:23         ` Siddharth Asthana
2025-11-26 11:10   ` Phillip Wood
2025-11-26 17:35     ` Elijah Newren
2025-11-26 18:41       ` Junio C Hamano
2025-11-26 21:17         ` Junio C Hamano
2025-11-26 23:06           ` Elijah Newren
2025-11-26 23:14             ` Junio C Hamano
2025-11-26 23:57               ` Elijah Newren
2025-11-26 19:50       ` Siddharth Asthana
2025-11-26 19:39     ` Siddharth Asthana
2025-11-27 16:21       ` Phillip Wood
2025-11-27 19:24         ` Siddharth Asthana
2025-11-25 17:25 ` [PATCH 0/1] " Johannes Schindelin
2025-11-25 18:02   ` Junio C Hamano
2025-11-26 19:18   ` Siddharth Asthana
2025-11-26 21:04     ` Junio C Hamano
2025-11-27 19:21       ` Siddharth Asthana
2025-11-27 20:17         ` Junio C Hamano
2025-11-28  8:07         ` Elijah Newren
2025-11-28  8:24           ` Siddharth Asthana
2025-11-28 16:35             ` Junio C Hamano
2025-11-28 17:07               ` Elijah Newren
2025-11-28 20:50                 ` Junio C Hamano
2025-11-28 22:03                   ` Elijah Newren
2025-11-29  5:59                     ` Junio C Hamano
2025-12-02 20:16 ` [PATCH v2 0/2] replay: add --revert mode " Siddharth Asthana
2025-12-02 20:16   ` [PATCH v2 1/2] sequencer: extract revert message formatting into shared function Siddharth Asthana
2025-12-05 11:33     ` Patrick Steinhardt
2025-12-07 23:00       ` Siddharth Asthana
2025-12-08  7:07         ` Patrick Steinhardt
2025-12-02 20:16   ` [PATCH v2 2/2] replay: add --revert mode to reverse commit changes Siddharth Asthana
2025-12-05 11:33     ` Patrick Steinhardt
2025-12-07 23:03       ` Siddharth Asthana
2025-12-16 16:23     ` Phillip Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).