]> git.ipfire.org Git - thirdparty/git.git/commit
replay: drop commits that become empty
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 18 Dec 2025 16:50:26 +0000 (16:50 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Dec 2025 03:56:37 +0000 (12:56 +0900)
commit55e54fe49021958124f8a3ebba730f572cf48e76
tree304629372d4ef72266b35d48334adcbcd9a43bc0
parentbdddf4b651758021ca55370bb31a7cb700cd91ef
replay: drop commits that become empty

If the changes in a commit being replayed are already in the branch
that the commits are being replayed onto, then "git replay" creates an
empty commit. This is confusing because the commit message no longer
matches the contents of the commit. Drop the commit instead. Commits
that start off empty are not dropped. This matches the behavior of
"git rebase --reapply-cherry-pick --empty=drop" and "git cherry-pick
--empty-drop".

If a branch points to a commit that is dropped it will be updated
to point to the last commit that was not dropped. This can be seen
in the new test where "topic1" is updated to point to the rebased
"C" as "F" is dropped because it is already upstream. While this is
a breaking change, "git replay" is marked as experimental to allow
improvements like this that change the behavior.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-replay.adoc
replay.c
t/t3650-replay-basics.sh